+L i4ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl m Z ddlmZddlmZddlZddlmZmZddlmZddlmZed Zd ZeDcic]}||c}Zej;d d id ZdZdZ d#dZ!Gdde"Z#e#Z$[#Gdde"Z%e%Z&[%e dZ'dZ(dZ)ejTZ+dddZ,ejZdZ.dZ/dZ0e!dddd Z1d$d!Z2 d$d"Z3ycc}w)%N)contextmanager)copy)Path)which) PLOTLY_DIRensure_writable_plotly_dir)validate_coerce_fig_to_dict) get_modulepsutil)pngjpegwebpsvgpdfepsjpgr c tdjt||ttj )Nz Invalid value of type {typ} receive as an image format specification. Received value: {v} An image format must be specified as one of the following string values: {valid_formats})typv valid_formats) ValueErrorformattypesortedformat_conversionskeys)vals U/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/plotly/io/_orca.pyraise_format_value_errorr!s?   vS S7I7N7N7P0Q  c|yt|tr|s t||j}|ddk(r|dd}|tvr t|t|S)a Validate / coerce a user specified image format, and raise an informative exception if format is invalid. Parameters ---------- fmt A value that may or may not be a valid image format string. Returns ------- str or None A valid image format string as supported by orca. This may not be identical to the input image designation. For example, the resulting string will always be lower case and 'jpg' is converted to 'jpeg'. If the input format value is None, then no exception is raised and None is returned. Raises ------ ValueError if the input `fmt` cannot be interpreted as a valid image format. Nr.) isinstancestrrlowerrfmts rvalidate_coerce_formatr).sg8 { c3 s % ))+C 1v}!"g $$ % c ""r ctj}|jtjtjd|j d|j \}}|j |S)zk Use the socket module to find an open port. Returns ------- int An open port r#)r)socket setsockopt SOL_SOCKET SO_REUSEADDRbind getsocknameclose)s_ports rfind_open_portr6asS  ALL""F$7$7;FF7OmmoGAtGGI Kr  `cfd}|S)NcJtjfd}|S)NcHtj} |i|S#t$rw}tj|z }|dzk\rtdd|tj }t d|dd|dtj |Yd}~nd}~wwxYw)NizRetry limit of z milliseconds reached.z Retrying in z.2fz seconds due to z...)time Exception TimeoutErrorrandomuniformprintsleep) argskwargs start_timee elapsed_time wait_timefunc max_delaymax_waitmin_waits rwrapperz)retry..decorator..wrapperusJ *000 *#'99;#;L#d*i7*-i[8NO !!'x BIL37Gs#NOJJy)) *s B A-BB ) functoolswraps)rJrNrKrLrMs` r decoratorzretry..decoratorts%   *  *"r )rMrLrKrQs``` rretryrSss* r ceZdZdZdZd#dZifdZd#dZdZe dZ e jdZ e d Z e jd Z e d Z e jd Z e d ZejdZe dZejdZe dZejdZe dZejdZe dZejdZe dZejdZe dZejdZe dZejdZe dZejdZe dZe d Zd!Zy")$ OrcaConfiga Singleton object containing the current user defined configuration properties for orca. These parameters may optionally be saved to the user's ~/.plotly directory using the `save` method, in which case they are automatically restored in future sessions. ci|_tjjtjj t j }tjj|d|_|jdtjj|jd}|tjjtdd|_ y)N package_dataF)warnz plotly.min.js.orca)plotlyjs config_file) _propsospathdirnameabspathplotly__file__join package_dirreloadr _constants)selfroot_dirrZs r__init__zOrcaConfig.__init__s 77??277??6??#CD77<<.A  77<< 0 0/B 77<< G< r c,i|_|r tyy)zQ Reset all orca configuration properties to their default values N)r\ reset_status)rg reset_servers rrestore_defaultszOrcaConfig.restore_defaultss  N r c Pt|ts%tdjt ||t |}|j ||D]+}||jvstdj||jD]\}}t|||y)a Update one or more properties from a dict or from input keyword arguments. Parameters ---------- d: dict Dictionary from property names to new property values. kwargs Named argument value pairs where the name is a configuration property name and the value is the new property value. Returns ------- None Examples -------- Update configuration properties using a dictionary >>> import plotly.io as pio >>> pio.orca.config.update({'timeout': 30, 'default_format': 'svg'}) Update configuration properties using keyword arguments >>> pio.orca.config.update(timeout=30, default_format='svg'}) zi The first argument to update must be a dict, but received value of type {typ}l Received value: {val}rrzInvalid property name: {k})kN) r$dictrrrrupdater\itemssetattr)rgdrEupdatesrprs rrrzOrcaConfig.updates<!T"$VQQV7  q'v KA # !=!D!Dq!D!IJJ K MMO DAq D!Q  r ctjj|jrn t |jd5}|j }ddd tj}|jD]\}}||j|<y|r0tjdj|jyy#1swYzxYw#t $r4|r/tjdj|jYywxYw#t$r4|r/tjdj|jYywxYw)a# Reload orca settings from ~/.plotly/.orca, if any. Note: Settings are loaded automatically when plotly is imported. This method is only needed if the setting are changed by some outside process (e.g. a text editor) during an interactive session. Parameters ---------- warn: bool If True, raise informative warnings if settings cannot be restored. If False, do not raise warnings if setting cannot be restored. Returns ------- None rNz0Unable to read orca configuration file at {path}r^z3Orca configuration file at {path} is not valid JSONz+Orca configuration file at {path} not found)r]r^existsr[openreadr>warningsrXrjsonloadsrrsr\)rgrXforca_str orca_propsrprs rrezOrcaConfig.reloads0$ 77>>$** + $**C0(A vvxH( !ZZ1 #((* #1!" A # MM//5v4;K;Kv/L 3(( MM44:F@P@PF4Q   MM77=v4CSCSv7T  s;CC CD CC:DD:EEctrBt|jd5}tj|j |ddddyt jdj|jy#1swYyxYw)a Attempt to save current settings to disk, so that they are automatically restored for future sessions. This operation requires write access to the path returned by in the `config_file` property. Returns ------- None w)indentNz3Failed to write orca configuration file at '{path}'ry) rr{r[r~dumpr\r}rXr)rgrs rsavezOrcaConfig.saveso & 'd&&, 4 $++q3 4 4 MM77=v4CSCSv7T  4 4s #A==Bc:|jjddS)a  The server URL to use for an external orca server, or None if orca should be managed locally Overrides executable, port, timeout, mathjax, topojson, and mapbox_access_token Returns ------- str or None server_urlNr\getrgs rrzOrcaConfig.server_url/s{{|T22r c||jjddyt|ts%t dj t |||jds|jdsd|z}td|_ d|_ d|_ d|_ d|_ d|_||jd<y)Nrzf The server_url property must be a string, but received value of type {typ}. Received value: {val}rozhttp://zhttps://)r\popr$r%rrr startswithshutdown_server executabler5timeoutmathjaxtopojsonmapbox_access_tokenrgrs rrzOrcaConfig.server_url>s ; KKOOL$ / #s##VS sV;  ~~i( 1Kc/C    #' $' L!r c:|jjddS)a3 The specific port to use to communicate with the orca server, or None if the port is to be chosen automatically. If an orca server is active, the port in use is stored in the plotly.io.orca.status.port property. Returns ------- int or None r5Nrrs rr5zOrcaConfig.portVs{{vt,,r c||jjddyt|ts%t dj t ||||jd<y)Nr5zb The port property must be an integer, but received value of type {typ}. Received value: {val}ror\rr$intrrrrs rr5zOrcaConfig.portesZ ; KKOOFD ) #s##VS sV;  " Fr cd|jjddg}|ydj|S)a  The name or full path of the orca executable. - If a name (e.g. 'orca'), then it should be the name of an orca executable on the PATH. The directories on the PATH can be displayed by running the following command: >>> import os >>> print(os.environ.get('PATH').replace(os.pathsep, os.linesep)) - If a full path (e.g. '/path/to/orca'), then it should be the full path to an orca executable. In this case the executable does not need to reside on the PATH. If an orca server has been validated, then the full path to the validated orca executable is stored in the plotly.io.orca.status.executable property. Returns ------- str executable_listorcaN )r\rrcrgrs rrzOrcaConfig.executabless30++//*;fXF  "88O, ,r c|'|jjddtyt|ts%t dj t ||t|tr|g}||jd<ty)Nrzf The executable property must be a string, but received value of type {typ}. Received value: {val}ror)r\rr$r%rrrrkrs rrzOrcaConfig.executablesy ; KKOOL$ / c3' #VS sV; #s#e-0DKK) * r c:|jjddS)ad The number of seconds of inactivity required before the orca server is shut down. For example, if timeout is set to 20, then the orca server will shutdown once is has not been used for at least 20 seconds. If timeout is set to None, then the server will not be automatically shut down due to inactivity. Regardless of the value of timeout, a running orca server may be manually shut down like this: >>> import plotly.io as pio >>> pio.orca.shutdown_server() Returns ------- int or float or None rNrrs rrzOrcaConfig.timeouts*{{y$//r c|'|jjddtyt|ttfs%t dj t||||jd<ty)Nrzc The timeout property must be a number, but received value of type {typ}. Received value: {val}ro) r\rr$rfloatrrrrrs rrzOrcaConfig.timeoutsm ; KKOOIt , cC<0 #VS sV; &)DKK " r c:|jjddS)z The default width to use on image export. This value is only applied if no width value is supplied to the plotly.io to_image or write_image functions. Returns ------- int or None default_widthNrrs rrzOrcaConfig.default_widths{{55r c||jjddyt|ts%t dj t ||||jd<y)Nrzg The default_width property must be an int, but received value of type {typ}. Received value: {val}rorrs rrzOrcaConfig.default_widthsZ ; KKOOOT 2 #s##VS sV;  (+ O$r c:|jjddS)z The default height to use on image export. This value is only applied if no height value is supplied to the plotly.io to_image or write_image functions. Returns ------- int or None default_heightNrrs rrzOrcaConfig.default_heights{{/66r c||jjddyt|ts%t dj t ||||jd<y)Nrzh The default_height property must be an int, but received value of type {typ}. Received value: {val}rorrs rrzOrcaConfig.default_heights\ ; KKOO,d 3 #s##VS sV;  ), $%r c:|jjddS)a The default image format to use on image export. Valid image formats strings are: - 'png' - 'jpg' or 'jpeg' - 'webp' - 'svg' - 'pdf' - 'eps' (Requires the poppler library to be installed) This value is only applied if no format value is supplied to the plotly.io to_image or write_image functions. Returns ------- str or None default_formatr rrs rrzOrcaConfig.default_formats({{/77r cv||jjddyt|}||jd<y)Nr)r\rr)rs rrzOrcaConfig.default_formats6 ; KKOO,d 3 $S)(+ $%r c:|jjddS)z The default image scaling factor to use on image export. This value is only applied if no scale value is supplied to the plotly.io to_image or write_image functions. Returns ------- int or None default_scaler#rrs rrzOrcaConfig.default_scales{{22r c||jjddyt|ttfs%t dj t||||jd<y)Nrzi The default_scale property must be a number, but received value of type {typ}. Received value: {val}ro)r\rr$rrrrrrs rrzOrcaConfig.default_scale*s^ ; KKOOOT 2 #U|,#VS sV;  (+ O$r c:|jjddS)z Path to the topojson files needed to render choropleth traces. If None, topojson files from the plot.ly CDN are used. Returns ------- str rNrrs rrzOrcaConfig.topojson7s{{z400r c|'|jjddtyt|ts%t dj t ||||jd<ty)Nrzd The topojson property must be a string, but received value of type {typ}. Received value: {val}ror\rr$r%rrrrrs rrzOrcaConfig.topojsonDsi ; KKOOJ - c3' #VS sV; '*DKK # r c:|jjddS)z{ Path to the MathJax bundle needed to render LaTeX characters Returns ------- str rz?https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.jsrrs rrzOrcaConfig.mathjaxTs{{  M  r c|'|jjddtyt|ts%t dj t ||||jd<ty)Nrzc The mathjax property must be a string, but received value of type {typ}. Received value: {val}rorrs rrzOrcaConfig.mathjaxbsi ; KKOOIt , c3' #VS sV; &)DKK " r c:|jjddS)zt Mapbox access token required to render mapbox traces. Returns ------- str rNrrs rrzOrcaConfig.mapbox_access_tokenrs{{4d;;r c|'|jjddtyt|ts%t dj t ||||jd<ty)Nrzo The mapbox_access_token property must be a string, but received value of type {typ}. Received value: {val}rorrs rrzOrcaConfig.mapbox_access_token}sm ; KKOO14 8 c3' $VS sV;  25DKK- . r c>d}|jjd|S)Nautouse_xvfbr)rgdflts rrzOrcaConfig.use_xvfbs{{z400r c gd}|'|jjddt y||vr/tdj|t |t |||jd<t y)N)TFrrzZ The use_xvfb property must be one of {valid_vals} Received value of type {typ}: {val}) valid_valsrr)r\rrrrreprrk)rgrrs rrzOrcaConfig.use_xvfbsv* ; KKOOJ - *$ ++16#-49$s),2,'*DKK # r c:|jjddS)zs The plotly.js bundle being used for image rendering. Returns ------- str rZN)rfrrs rrZzOrcaConfig.plotlyjss"":t44r cJtjjtdS)a# Path to orca configuration file Using the `plotly.io.config.save()` method will save the current configuration settings to this file. Settings in this file are restored at the beginning of each sessions. Returns ------- str rY)r]r^rcrrs rr[zOrcaConfig.config_filesww||J00r cXdj|j|j|j|j|j |j |j|j|j|j|j|j|j|jS)zR Display a nice representation of the current orca configuration. aorca configuration ------------------ server_url: {server_url} executable: {executable} port: {port} timeout: {timeout} default_width: {default_width} default_height: {default_height} default_scale: {default_scale} default_format: {default_format} mathjax: {mathjax} topojson: {topojson} mapbox_access_token: {mapbox_access_token} use_xvfb: {use_xvfb} constants --------- plotlyjs: {plotlyjs} config_file: {config_file} )rr5rrrrrrrrrrZr[r)rrr5rrrrrrrrrrZr[rrs r__repr__zOrcaConfig.__repr__s* FLL,,..,,..LL]] $ 8 8]]((]]  +$ r N)T)__name__ __module__ __qualname____doc__rirmrrrerpropertyrsetterr5rrrrrrrrrrrZr[rrRr rrUrUsr $0 d2h* 3 3((. - - [[ " "--:"00, ^^   6 6 + + 7 7 , ,88*,, 3 3 + + 1 1__       ^^  <<  11__&55 1 1( r rUceZdZdZdddddddZedZedZedZedZ ed Z ed Z d Z y) OrcaStatuszQ Class to store information about the current status of the orca server. unvalidatedN)staterversionpidr5commandc |jdS)a A string representing the state of the orca server process One of: - unvalidated: The orca executable has not yet been searched for or tested to make sure its valid. - validated: The orca executable has been located and tested for validity, but it is not running. - running: The orca server process is currently running. rr\rs rrzOrcaStatus.states{{7##r cH|jd}|ydj|S)aS If the `state` property is 'validated' or 'running', this property contains the full path to the orca executable. This path can be specified explicitly by setting the `executable` property of the `plotly.io.orca.config` object. This property will be None if the `state` is 'unvalidated'. rNr)r\rcrs rrzOrcaStatus.executables+++&78  "88O, ,r c |jdS)z If the `state` property is 'validated' or 'running', this property contains the version of the validated orca executable. This property will be None if the `state` is 'unvalidated'. rrrs rrzOrcaStatus.version!s{{9%%r c |jdS)z The process id of the orca server process, if any. This property will be None if the `state` is not 'running'. rrrs rrzOrcaStatus.pid+s {{5!!r c |jdS)a The port number that the orca server process is listening to, if any. This property will be None if the `state` is not 'running'. This port can be specified explicitly by setting the `port` property of the `plotly.io.orca.config` object. r5rrs rr5zOrcaStatus.port3s{{6""r c |jdS)z The command arguments used to launch the running orca server, if any. This property will be None if the `state` is not 'running'. rrrs rrzOrcaStatus.command>s {{9%%r cdj|j|j|j|j|j |j S)zR Display a nice representation of the current orca server status. zorca status ----------- state: {state} executable: {executable} version: {version} port: {port} pid: {pid} command: {command} )rrr5rrr)rrrr5rrrrs rrzOrcaStatus.__repr__FsG  FLL**LL    r ) rrrrr\rrrrrr5rrrRr rrrs  F $ $-- &&""##&& r rc #Kgd}i} |j|Dcic]5}|tjvs|tjj|7c}d|j D]\}}|tj|<ycc}w#|j D]\}}|tj|<wxYww)a Context manager to clear and restore environment variables that are problematic for orca to function properly NODE_OPTIONS: When this variable is set, orca >> plotly.io.orca.config.executable = '/path/to/orca' After updating this executable property, try the export operation again. If it is successful then you may want to save this configuration so that it will be applied automatically in future sessions. You can do this as follows: >>> plotly.io.orca.config.save() If you're still having trouble, feel free to ask for help on the forums at https://community.plot.ly/c/api/python PATHz z The orca executable is required to export figures as static images, but it could not be found on the system path. Searched for executable '{executable}' on the following path: {formatted_path} {instructions})rformatted_path instructionsz--auto-servernumz --server-argsz4-screen 0 640x480x24 +extension RANDR +extension GLXzxvfb-runz The plotly.io.orca.config.use_xvfb property is set to True, but the xvfb-run executable could not be found on the system path. Searched for the executable 'xvfb-run' on the following path: {formatted_path})rrlinuxDISPLAYa  The orca executable is required in order to export figures as static images, but the executable that was found at '{executable}' does not seem to be a valid plotly orca executable. Please refer to the end of this message for details on what went wrong. {instructions})rrz--helpstdoutstderrrzu Here is the error that was returned by the command $ {executable} --help [Return code: {returncode}] {err_msg} rutf-8)rerr_msg returncodeaNote: When used on Linux, orca requires an X11 display server, but none was detected. Please install Xvfb and configure plotly.py to run orca using Xvfb as follows: >>> import plotly.io as pio >>> pio.orca.config.use_xvfb = True You can save this configuration for use in future sessions as follows: >>> pio.orca.config.save() See https://www.x.org/releases/X11R7.6/doc/man/man1/Xvfb.1.xhtml for more info on Xvfb z_ The error encountered is that no output was returned by the command $ {executable} --help )rz"Plotly's image-exporting utilitieszv The error encountered is that unexpected output was returned by the command $ {executable} --help {help_result} )r help_resultz --versiona An error occurred while trying to get the version of the orca executable. Here is the command that plotly.py ran to request the version $ {executable} --version This command returned the following error: [Return code: {returncode}] {err_msg} z The error encountered is that no version was reported by the orca executable. Here is the command that plotly.py ran to request the version: $ {executable} --version rr validatedr)statusrrconfigrr]rrdefpathreplacepathseprrrsysplatformrr subprocessPopenPIPE communicaterrcdecoder\strip)install_location_instructionsrr^r xvfb_argsxvfb_run_executablerinvalid_executable_msgpr help_errorrversion_result version_errors rvalidate_executablers6||}$%!:v(()J ::>>&"** -D\\"**h7N &!,,-:  $ > I#J/" n=  //);6! LL # #G , y) * $J/./);&, &,I  2    xj ( #$--/ Z 2 ||q "  F88O4"))'2<<    << " "7 +BJJNN94M  G!!  " Fchh/F0  1  ,;3E3Eg3NN "  Fchh/[FI  J   8    {m +????  )* % 8 ||q "   F88O4%,,W5<<     $  "  Fchh/F0  1  (..0'6FMM#$-335FMM)(FMM'Y22B88s>A P(A P'P$'P0ctdtjd<dtjd<dtjd<y)z Shutdown the running orca server, if any, and reset the orca status to unvalidated. This command is only needed if the desired orca executable is changed during an interactive session. Returns ------- None Nrrrr)rrr\rRr rrkrkvs5'+FMM#$#FMM)*FMM'r )procshutdown_timercty)N)rrRr rcleanupr sr ctdt5tdtjtdj}|j dD]} |j  tdj tdjdtd<td tdjdtd<dtd<dtjd<dtjd <dtjd<dtjd <dddyy#t$rYwxYw#t$rYwxYw#1swYyxYw) z\ Shutdown the running orca server process, if any Returns ------- None rNT) recursiverr5rrrr) orca_state orca_lockr Processrchildren terminater>waitcancelrr\)parentchilds rrrsJ&% ' 0&!-   6(:(>(>?#__t_<E)v&002v&++- &* 6"./;/077937J/0%) 6"*5 g&'+ e$(, f%+/ i(O' 0' 0&%!+' 0' 0sUAED*(E+.D9BE* D63E5D66E9 EEEEEct tdtds tdtjs{t j dk(r tt5tdtdjtdtjttd<ntjtd<t jd d d ttdd tjd gz}tj r!|j#dtj gtj$r!|j#dtj$gtj&r!|j#dtj&gt)t*j,d}t/5dt*j0vr|nd}t3j4|||td<ddddt jd<tdj6t jd<tdt jd<|t jd<tj8Ht;j<tj8t>}d|_ |jC|td<dddyy#1swYxYw#1swYyxYw)z Start an orca server if none is running. If a server is already running, then reset the timeout countdown Returns ------- None NzImage generation requires the psutil package. Install using pip: $ pip install psutil Install using conda: $ conda install psutil requestszImage generation requires the requests package. Install using pip: $ pip install requests Install using conda: $ conda install requests rrrr5rservez-pz--plotlyz --graph-onlyz --topojsonz --mathjaxz--mapbox-access-tokenwbCIrrunningrrrT)"r rr rrrrrr r rr5r6r\r%rZrextendrrr{r]devnullrrrrrr threadingTimerrdaemonstart)cmd_listDEVNULLrts r ensure_serverr$sD~    j !       <<= (  !9 1*+7+,335&!);;&)7)9Jv&)/Jv&"==):; 6*+OO" ???OO\6??$CD>>OO[&..$AB--OO0&2L2LM rzz40Z(, (:WF)3)9)9 *Jv&*3 g&'1&'9'='= e$(26(: f%+3 i(~~)OOFNNOD  /0 +,s9 19 1 VK9 19 1s&EK16J5'CK5J> :KK )rMrLrKc rddlm}ddlm}tj rtj }ndj dtd}|jDcic] \}}| || }}}||}||dz| }|jd k(rtttd |Scc}}w) zm Helper method to perform an image request to a running orca server process with retrying logic. r)post)to_json_plotlyzhttp://{hostname}:{port} localhostr5)hostnamer5/)datai z522: client socket timeout) rr&plotly.io.jsonr'rrrr rs status_coderr$OSError) rEr&r'rrprrequest_paramsjson_strresponses rrequest_image_with_retryingr25s - && /66 z&'97 (.||~Gtq!adGNGn-HJ$84Hs"233 OHs  B3&B3c t|tj}t|}|tj}|tj }|tj }t||} t|||||}|j&dk(r |j(Sd j|j&|j(j+d  } |j&d k(r"t-|t.r|s| d z } t| |j&dk(r^t1|j3dgD cgc]} | j3dddk(c} } | r9tj4)| dz } t| |j&dk(r |dk(r| dz } t| #t$rtt}tjr)tdjtjtj!tj"} | rtdj|t%tdj|wxYwcc} w)a5 Convert a figure to a static image bytes string Parameters ---------- fig: Figure object or dict representing a figure format: str or None The desired image format. One of - 'png' - 'jpg' or 'jpeg' - 'webp' - 'svg' - 'pdf' - 'eps' (Requires the poppler library to be installed) If not specified, will default to `plotly.io.config.default_format` width: int or None The width of the exported image in layout pixels. If the `scale` property is 1.0, this will also be the width of the exported image in physical pixels. If not specified, will default to `plotly.io.config.default_width` height: int or None The height of the exported image in layout pixels. If the `scale` property is 1.0, this will also be the height of the exported image in physical pixels. If not specified, will default to `plotly.io.config.default_height` scale: int or float or None The scale factor to use when exporting the figure. A scale factor larger than 1.0 will increase the image resolution with respect to the figure's layout pixel dimensions. Whereas as scale factor of less than 1.0 will decrease the image resolution. If not specified, will default to `plotly.io.config.default_scale` validate: bool True if the figure should be validated before being converted to an image, False otherwise. Returns ------- bytes The image data N)figurerscalewidthheightz Plotly.py was unable to communicate with the orca server at {server_url} Please check that the server is running and accessible. )rz For some reason plotly.py was unable to communicate with the local orca server process, even though the server process seems to be running. Please review the process and connection information below: {info} )infoz For some reason the orca server process is no longer running. Please review the process and connection information below: {info} plotly.py will attempt to start the local server process again the next time an image export operation is performed. zl The image request was rejected by the orca conversion utility with the following error: {status}: {msg} r)rmsgiz\ Try setting the `validate` argument to True to check for errors in the figure specificationi r+r scattermapboxaX Exporting scattermapbox traces requires a mapbox access token. Create a token in your mapbox account and then set it using: >>> plotly.io.orca.config.mapbox_access_token = 'pk.abc...' If you would like this token to be applied automatically in future sessions, then save your orca configuration as follows: >>> plotly.io.orca.config.save() ira Exporting to EPS format requires the poppler library. You can install poppler on MacOS or Linux with: $ conda install poppler Or, you can install it on MacOS using homebrew with: $ brew install poppler Or, you can install it on Linux using your distribution's package manager to install the 'poppler-utils' package. Unfortunately, we don't yet know of an easy way to install poppler on Windows. )r$rrr)rrrr r2r.rrrrrr pid_existsrrkr-contentrr$rqanyrr) figrr6r7r5validatefig_dictr1 status_strr< err_messagetrace any_mapboxs rto_imagerFRsbjO ~&& #F +F }$$ }$$ ~&&+39H/.F%uV ds" F(&&H,<,<,C,CG,LFM    3 &:c4+@  KL%%G ! !S ("*fb!9IIfd+>J f88@   6%%! ! !S (Vu_  K%%W +&\    Ff''F(   **6::6J  F F    F F  C+Ts+F%IB7Ict|tr t|}nt|tr|}nd}|=|;|j}|r|j d}nt dj |t||||||} | |j| y|j| y#t$rYnwxYwt dj |)ak Convert a figure to a static image and write it to a file or writeable object Parameters ---------- fig: Figure object or dict representing a figure file: str or writeable A string representing a local file path or a writeable object (e.g. a pathlib.Path object or an open file descriptor) format: str or None The desired image format. One of - 'png' - 'jpg' or 'jpeg' - 'webp' - 'svg' - 'pdf' - 'eps' (Requires the poppler library to be installed) If not specified and `file` is a string then this will default to the file extension. If not specified and `file` is not a string then this will default to `plotly.io.config.default_format` width: int or None The width of the exported image in layout pixels. If the `scale` property is 1.0, this will also be the width of the exported image in physical pixels. If not specified, will default to `plotly.io.config.default_width` height: int or None The height of the exported image in layout pixels. If the `scale` property is 1.0, this will also be the height of the exported image in physical pixels. If not specified, will default to `plotly.io.config.default_height` scale: int or float or None The scale factor to use when exporting the figure. A scale factor larger than 1.0 will increase the image resolution with respect to the figure's layout pixel dimensions. Whereas as scale factor of less than 1.0 will decrease the image resolution. If not specified, will default to `plotly.io.config.default_scale` validate: bool True if the figure should be validated before being converted to an image, False otherwise. Returns ------- None Nr"z Cannot infer image type from output path '{file}'. Please add a file extension or specify the type using the format parameter. For example: >>> import plotly.io as pio >>> pio.write_image(fig, file_path, format='png') )file)rr5r6r7r@zX The 'file' argument '{file}' is not a string, pathlib.Path object, or file descriptor. ) r$r%rsuffixlstriprrrFwriteAttributeError write_bytes) r?rHrr5r6r7r@r^extimg_datas r write_imagerPs|$Dz D$  FNkk ZZ_F FF   F%uVhH  |  JJx  "     FF  sB)) B54B5)r7r8r9)NNNNT)4atexitrOr~r]r@r,rrrr=r} contextlibrrpathlibrshutilrra plotly.filesrrplotly.io._utilsr plotly.optional_importsr r rrrrrr)r6rSobjectrUrrrrrrkLockr r registerr rr$r2rFrPr's0rr[sW    % ?8. H = *783c3h85&/* 0#f$6[  [  @  g g X ""