L i ddlmZddlZddlmZddlmZddlmZddl m Z ddl m Z ddl mZdd lmZej"rdd l mZeeZGd d eZGd deZdddZddZddZdddZddZddZy)) annotationsN) NamedTuple) get_logger)_CONSTRAINTS_KEY)Study) TrialState)_imports)_make_hovertext)gocJeZdZUded<ded<ded<ded<ded <d ed <y ) _TimelineBarInfointnumberdatetime.datetimestartcompleterstatestr hovertextbool infeasibleN__name__ __module__ __qualname____annotations__d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/optuna/visualization/_timeline.pyr r s$ K  Nrr ceZdZUded<y) _TimelineInfolist[_TimelineBarInfo]barsNrrrrr!r!s  rr!c~||dkr tdtjt||}t |S)a'Plot the timeline of a study. Args: study: A :class:`~optuna.study.Study` object whose trials are plotted with their lifetime. n_recent_trials: The number of recent trials to plot. If :obj:`None`, all trials are plotted. If specified, only the most recent ``n_recent_trials`` will be displayed. Must be a positive integer. Returns: A :class:`plotly.graph_objects.Figure` object. Raises: ValueError: if ``n_recent_trials`` is 0 or negative. rz3n_recent_trials must be a positive integer or None.)n_recent_trials) ValueErrorr check_get_timeline_info_get_timeline_plot)studyr%infos r plot_timeliner,!s>&"!';NOO NN e_ ED d ##rct|jDcgc]3}|j%|j|j|jz 5c}d}t ||rt j j St|jDcgc]}|j|jc}t j j Scc}wcc}w)N)default)maxtrialsdatetime_completedatetime_start_is_running_trials_in_studydatetimenow)r*tmax_run_durations r_get_max_datetime_completer8<s\\ "".13C3C3O   !"2"2 2  #5*:;  $$&& &+llVa6I6I6U  V!!%%'   Ws8CC$Cc|jtjfd}t|dkDStjj t fd|DS)NF)statesdeepcopyrc3`K|]%}|j|jz dzk'yw)N)r2).0r6r7r5s r z._is_running_trials_in_study..Vs;   ' a%5!55s+.) get_trialsrRUNNINGlenr4r5any)r*r7running_trialsr5s ` @rr3r3Nsg%%j.@.@-BU%SN>"Q&&      !C  rc g}t|}tjd}|jd}||| d}|D]}|jxs|}|j t jk(r||zn|jxs||z}t|jvrdn,t|jtD cgc]} | dkD c} } ||kr)tjd|jd|d|d |jt!|j|||j t#|| t%|dk(rtjd t'|Scc} w) N)secondsF)r;rz"The start and end times for Trial z( seem to be reversed. The start time is z and the end time is .)rrrrrrz$Your study does not have any trials.)r8r4 timedeltar@r2rrrAr1r system_attrsrC_loggerwarningrappendr r rBr!) r*r%r# max_datetimetimedelta_for_small_barr0trialr2r1xrs rr(r(^s~ D-e4L&00;   u  -F"()* --={{j000 2 2((TN=T,T  u'9'99 U%7%78H%IJa!eJK  ~ - OO8G))7(88MN_M``ac  ||$*kk)%0%   ' < 4yA~>?  /Ks6 E$ c&dddddd}tj}ttdD]}|jd k(r|j Dcgc]!}|j |k(s|js |#}}|j Dcgc]!}|j |k(s|jr |#}}t|d d |t|||j|j||j Dcgc]}|j |k(s|}}t|||j|j||jd |jtjdddiddi|jd|Scc}wcc}wcc}w)Nblueredorangegreengray)COMPLETEFAILPRUNEDrAWAITINGc|jSN)name)rQs rz$_get_timeline_plot..s !&&r)keyrXz#cccccc INFEASIBLEdate)typez Timeline PlottitleDatetimeTrial)rdxaxisyaxisT) showlegend) r Figuresortedrr^r#rr _plot_bars update_xaxes update_layoutLayout)r+_cmfigrbinfeasible_bars feasible_barsr#s rr)r)sb  C ))+C (89? :: #*.))YQqww%7GALLqYOY(, [1QWW5EallQ[M[  < E }c%**ouzz3 G#yy=!AGGu,?&! !J'G$ & J!Z[>s0F% F2FF  F (F 0FFct|dk(ry|jtj||Dcgc],}|j|j z j dz.c}|Dcgc]}|jc}|Dcgc]}|j jc}|Dcgc]}|jc}d|zdzdt|d ycc}wcc}wcc}wcc}w) Nriz%{text}zh)colornone) r^rQybasetext hovertemplate orientationmarker textposition) rB add_tracer Barrr total_secondsr isoformatrdict)r#rwr^rqrrs rrlrls 4yA~MM FJK QWW$335<K!%&Aqxx&/34!!''##%4'+,!!++,*T1J>e$  L&4,s1C&C?!C$&C)r])r*rr% int | Nonereturn 'go.Figure')r*rrr)r*rr7zdatetime.timedelta | Nonerr)r*rr%rrr!)r+r!rr) r#r"rwrr^rrqz go.FigurerNone) __future__rr4typingroptuna.loggingroptuna.samplers._baser optuna.studyr optuna.trialr$optuna.visualization._plotly_importsr optuna.visualization._utilsr is_successfulr rrKr r!r,r8r3r(r)rlrrrrst"%2#9787 X z!J!$6$  +\>r