L iK}UddlmZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl mZmZmZmZmZddlmZddlmZmZmZdd lmZdd lmZdd lmZdd lm Z dd l!m"Z"m#Z#ddl$m%Z%ddl&m'Z'm(Z(ddl)m*Z*ddl+m,Z,m-Z-ddl.m/Z/m0Z0m1Z1ddl2m3Z3m4Z4m5Z5ddl6m7Z7m8Z8m9Z9ddl:m;Z;erddlZ>ddl?m@Z@ddl)m*Z*ddlAmBZBeeCZDdeEd<Gdde ZF d"dZGGddZHd#d ZId$d!ZJy)%) annotationsN)contextmanager)Enum) default_timer) TYPE_CHECKINGAnyFinalLiteralcast)Signal)configruntimeutil)FragmentStorageKeyError) get_logger) ClientState) ForwardMsg)create_page_profile_messageto_microseconds) PagesManager)exec_func_with_error_handlingmodified_sys_path) ScriptCache)RerunException StopException) RerunDataScriptRequestsScriptRequestType)ScriptRunContextadd_script_run_ctxget_script_run_ctx)SCRIPT_RUN_WITHOUT_ERRORS_KEYSafeSessionState SessionState) page_sort_key)Callable Generator)FragmentStorage)UploadedFileManagerr _LOGGERc(eZdZdZdZdZdZdZdZdZ y) ScriptRunnerEventSCRIPT_STARTED!SCRIPT_STOPPED_WITH_COMPILE_ERRORSCRIPT_STOPPED_WITH_SUCCESSSCRIPT_STOPPED_FOR_RERUNFRAGMENT_STOPPED_WITH_SUCCESSSHUTDOWNENQUEUE_FORWARD_MSGN) __name__ __module__ __qualname__r-r.r/r0r1r2r3r/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/streamlit/runtime/scriptrunner/script_runner.pyr,r,Js;&N)L%#@ :%D!H 0r8r,cRddlm}ddlm}m}ddlm}||j}|jdz }t|jdDcgc]I}|jjdr,|jjds|jd k7r|Kc}t }||d } | g|Dcgc]}|||jz c}z} tj d durdnd} |t#d| | d}|j%ycc}wcc}w)Nr)Path)PageType _navigation) StreamlitPagepagesz*.pyz.py.z __init__.py)keyT)defaultzclient.showSidebarNavigationFhiddensidebarzlist[PageType])positionexpanded)pathlibr;streamlit.commands.navigationr<r=streamlit.navigation.pager>resolveparentsortedglobnameendswith startswithr%r get_optionr run) main_script_pathr;r<r=r>resolved_main_script_path pages_folderpager? main_page all_pagesrEs r9_mpa_v1rY~s'C7(,,<'='E'E'G3::WDL %))&1 yy!!%(II((- ]*    E7FI &>&@@@r8c||j|jj|tj|y)zEnqueue a ForwardMsg to our browser queue. This private function is called by ScriptRunContext only. It may be called from the script thread OR the main thread. )r forward_msgN)rarjrr,r3)rmmsgs r9rz!ScriptRunner._enqueue_forward_msgs7 446  )==3  r8c\|jsy|jsy|jj}|y|jt j k(rt|j|jt jk7rtd|jdt)asCheck our current ScriptRequestState to see if we have a pending STOP or RERUN request. This function is called every time the app script enqueues a ForwardMsg, which means that most `st.foo` commands - which generally involve sending a ForwardMsg to the frontend - act as implicit yield points in the script's execution. Nrr) rrkrhon_scriptrunner_yieldrrrrrrrr)rmrs r9raz4ScriptRunner._maybe_handle_execution_control_requests((* }} ..668 ?  <<,22 2 !3!34 4 <<,11 127<<.@[\ or8c#xK|jr tdd|_ dd|_y#d|_wxYww)zA context for setting the ScriptRunner._execing flag. Used by _maybe_handle_execution_control_request to ensure that we only handle requests while we're inside an exec() call zNested set_execing_flag callTNF)rkrrzs r9_set_execing_flagzScriptRunner._set_execing_flags8 ===> >  " !DMEDMs:.: 7:c js td tjd|t }d}|j s,t jjjjj|j|jjj|j}jj}||dn|d}j!}|j}||k7rtt#} |j$C|j$j&-|j$j&D chc]} | j(} } j*j-| t/|j } |j1|j2|| |j4|j6j8j;t<j>|| jjA ||d} n;|d} tC} |j| jD_ |jG| jHjK| }jUd }|tVjXd <| |jZd<||||f dfd }t |z }t]||\}}}}}|j*tP<|rt<j^}n-|j rt<j`}nt<jb}|jdr] |jGtg|jhtkt |z tk||rtm|jnndjq|||tstt||}nycc} w#tL$r`}tjOd | d j*tP<j8j;t<jR| Yd}~yd}~wwxYw#tL$r!}tjd| Yd}~d}~wwxYw)zRun our script. Parameters ---------- rerun_data: RerunData The RerunData to use. z?ScriptRunner._run_script must be called from the script thread.zRunning script %srNr)rrfragment_ids_this_runcached_message_hashesr)rrrr? script_pathzScript compilation error)exc_infoF)r exception__main____file__cVtj5j5|j%jj |j|j |jr5|jD]%} jj|}|'nbt"j$rt'jnt)||j*jj-|j.jj1j3ddddddy#t$r%|jstjd|Yttf$rt $rY wxYw#1swY]xYw#1swYyxYw)NaCouldn't find fragment with id %s. This can happen if the fragment does not exist anymore when this request is processed, for example because a full app rerun happened that did not register the fragment. Usually this doesn't happen or no action is required, so its mainly for debugging.)new_fragment_ids)rr`r widget_statesrbon_script_will_rerunon_script_startfragment_id_queuerfgetr is_auto_rerunr*warningrr Exceptionruses_pages_directoryrYexec__dict__clearrmaybe_check_serializablera)codemodulerr fragment_idwrapped_fragmentrms r9 code_to_execz.ScriptRunner._run_script..code_to_exec^s&d&<&<=@C**,@C "//;++@@&44'')!33+5+G+G&%K%%373I3I3M3M$/4" 0!1 2 &%R(<<#D$:$:; v7..44-0-A-A5''@@B@@BA@C@C@C($;&(2'?'?$+OO)R)4 %&%3M#B&!&#,% !% %]@C@C@C@CsTFAF"E(BF7F+F 3F5F FF FF FF()commands exec_time prep_timeuncaught_exceptionzFailed to create page profile) rstrrtypes.ModuleTyperrrrreturnNone);rrr*rtimerrr get_instancemedia_file_mgrclear_session_refsrgset_script_intentr page_nameget_initial_active_script get_main_pagersetrwidgetsidrbon_script_finishedlistresetrrrrjrr,r- get_pagesrpage_not_foundenqueuerd get_bytecoderrr"r. _new_modulesysmodulesrrr0r1r/rrtracked_commandsrrr4_on_script_finished _log_if_error_clean_problem_modules)rmr start_timer active_scriptmain_page_inforrprevious_page_script_hash widget_idswrrrrexrr_run_without_errorsrerun_exception_datapremature_stoprfinished_events` r9rzScriptRunner._run_scripts`((*Q   MM-z : %J I// $$&55HHJ    1 1++Z-A-A !//II++M"00>>@N!,01#$67  **,C),(<(< %(,<<(+u ,,8"0088D0:0H0H0P0P!Q1!$$!QJ!Q##66zB$()E)E$F ! II'44!1&;&0&F&F'44   MM  '66!1&;))335    ,"/ ">K#1"?K%,C3=3G3GC&&0KK$))66{C&%%j1F'-CKK #+6FOOJ '!+1(+(2 F CF C(F C&F C& F C  F CP*,I.lC@  "$"BTD   = >#"3!K!K--!2!P!P!2!N!N%%PKK3%(%9%9&5eg 6J&K&5i&@$6!%%7 8 A A%)    $ $S.. I 0 1#/1 eX"RX !!"r s#  %);;++4'759D   03:GKH%%00>*'TL &L &^,r8