o
    ni                     @   s  d Z ddlZddlZddlZddlZddlmZ ddlmZ ddl	m
Z
 ddlmZmZmZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddl m!Z! ddl"m#Z# ddl$m%Z& ddl'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z. ddl/m0Z0m1Z1 ddl2m3Z3 ddl4m5Z6 ddl7m8Z8 dZ9ede:Z;ed Z<G dd deZ=erddl>m?Z? e@dZAd'd d!ZBd(d#d$ZCG d%d& d&ZDdS ))a  Interface base class - Used to send messages to the internal process.

InterfaceBase: The abstract class
InterfaceShared: Common routines for socket and queue based implementations
InterfaceQueue: Use multiprocessing queues to send and receive messages
InterfaceSock: Use socket to send and receive messages
InterfaceRelay: Responses are routed to a relay queue (not matching uuids)

    N)abstractmethod)Path)	token_hex)TYPE_CHECKINGAnyDictIterableListLiteralNewTypeOptionalTuple	TypedDictUnion)termwarn)wandb_internal_pb2)wandb_telemetry_pb2)Artifact)ArtifactManifest)get_staging_dir)	json_util)WandBJSONEncoderOldget_h5_typenamejson_dumps_saferjson_dumps_safer_historyjson_friendlyjson_friendly_valmaybe_compress_summary   )history_dict_to_jsonval_to_json)MailboxHandle   )summary_record)MessageFuturei GlobStr)nowliveendc                   @   s"   e Zd ZU eeeef  ed< dS )	FilesDictfilesN)__name__
__module____qualname__r   r   r%   
PolicyName__annotations__ r0   r0   [/home/ubuntu/SoloSpeech/.venv/lib/python3.10/site-packages/wandb/sdk/interface/interface.pyr)   >   s   
 r)   )Runwandbpolicyr.   returnpb.FilesItem.PolicyType.Vc                 C   sB   | dkrt jjj}|S | dkrt jjj}|S | dkrt jjj}|S Nr&   r(   r'   pb	FilesItem
PolicyTypeNOWENDLIVE)r4   enumr0   r0   r1   file_policy_to_enumI   s   


r@   r?   c                 C   sB   | t jjjkrd}|S | t jjjkrd}|S | t jjjkrd}|S r7   r8   )r?   r4   r0   r0   r1   file_enum_to_policyS   s   rA   c                   @   s
  e Zd ZU ed ed< eed< d$ddZd%d	d
Zd$ddZe	de
jddfddZdefddZe	de
jdefddZ				d&dee deeeedf ef  dee dee
j de
jf
ddZddde
jfddZd%ddZe	de
jddfd d!Zd"eddfd#d$Ze	d%e
jddfd&d'Z			d'dee deeeedf ef  dee ddfd(d)Ze	d*e
jddfd+d,Z e	d-e
j!ddfd.d/Z"d0ede
j#fd1d2Z$d3ed4edefd5d6Z%d7e&j#de
j#fd8d9Z'd7e&j#ddfd:d;Z(e	d<e
j#ddfd=d>Z)d?d@de
j*fdAdBZ+d(dCdDZ,e	dEe
j*ddfdFdGZ-d$dHdIZ.e	dJe
j/ddfdKdLZ0dMdNde
j1fdOdPZ2	d)dQe3dee
j3 de
j3fdRdSZ4dTe3defdUdVZ5			d'dddMdNdWedXe6e dYee dZee d[ee defd\d]Z7e	d^e
j8defd_d`Z9e:daedbe;eef dce;eef defdddeZ<dfe
j=dgedbe;eef dce;eef de
j=f
dhdiZ>	M	N		d*djdkZ?e	dle
j=ddfdmdnZ@			o	o	pd+dddMdNdXe6e dqee6e  dreeA dsedteduedeBfdvdwZCe	dxe
jDdeBfdydzZEd{ed|ed}ed~edee defddZFe	de
jGdefddZH		o	o	pd,dddMdNdXe6e dqee6e  dsedtedueddfddZIe	dle
j1ddfddZJd-dedededdfddZKe	de
jLddfddZMe	deNjOddfddZP			p	d.dedeAdeeA dee deded ddfddZQe	de
jRddfddZS			pd/dedeeA ded deddf
ddZTe	de
jUddfddZVd$ddZWe	de
jXddfddZYdededdfddZZe	de
j[ddfddZ\dededdfddZ]e	de
j^ddfddZ_d$ddZ`e	de
jaddfddZbd$ddZce	de
jdddfddZededededeAddf
ddZfe	de
jgddfddÄZhdeeA de
jifddƄZjdeeA ddfddȄZke	de
jiddfdd˄Zld$dd̈́Zme	de
jnddfddЄZo	o	d0depepe  depepe  dee dedef
ddׄZqe	de
jrdefddڄZsd$dd܄Zte	d$ddބZudddefddZv				d&deAdeAdYee dZee dee dee defddZwe	de
jxdefddZye	de
jdefddZzdddefddZ{e	de
j|defddZ}dedefddZ~e	de
jdefddZdefddZe	de
jdefddZdefddZe	de
jdefddZdefddZe	d e
jdefddZdefddZe	de
jdefddZdefdd	Ze	de
jdefd
dZdeeA defddZe	de
jidefddZdefddZe	de
jdefddZdefddZe	de
jdefddZdefddZe	de
jdefddZdefdd Ze	d!e
jdefd"d#ZdS (1  InterfaceBaser2   _run_dropr5   Nc                 C   s   d | _ d| _d S )NF)rC   rD   selfr0   r0   r1   __init__a   s   
zInterfaceBase.__init__runc                 C   s   || _ t }| j | d S N)rC   osgetpid_set_iface_pid)rF   rH   current_pidr0   r0   r1   _hack_set_rune   s   zInterfaceBase._hack_set_runc                 C      t  }| | d S rI   )r9   HeaderRecord_publish_headerrF   headerr0   r0   r1   publish_headerj      zInterfaceBase.publish_headerrS   c                 C      t rI   NotImplementedErrorrR   r0   r0   r1   rQ   n      zInterfaceBase._publish_headerc                 C   s   |  t S rI   )_deliver_statusr9   StatusRequestrE   r0   r0   r1   deliver_statusr   s   zInterfaceBase.deliver_statusstatusc                 C   rV   rI   rW   rF   r]   r0   r0   r1   rZ   u   s   zInterfaceBase._deliver_statusdatakey.valobjc           	      C   s   |pt  }|r"| D ]\}}|j }||_tt|d |_q|rF|j }t	|t
r:|D ]}|j| q0n||_tt|d |_|S )Nr   )r9   ConfigRecorditemsupdateaddr`   r   r   
value_json
isinstancetuple
nested_keyappend)	rF   r_   r`   ra   rb   configkvre   r0   r0   r1   _make_config|   s   


zInterfaceBase._make_configc                 C   s  t  }|jjd ur|jj|_|jjd ur|jj|_|jjd ur%|jj|_|jjd ur0|jj|_|jjd ur;|jj|_|jj	d urF|jj	|_
|jjd urQ|jj|_|jjd urd|jjD ]}|j| q[|jd urt|jt|jd  |jd ur}|j|_|jjd ur|jj|j_|jjd ur|jj|j_|jjd ur|jj|_|jjr|jj|_|jjr|jj|_|jr|j|_|j d ur|j ! }| j"||j#d |j$r|j%&|j$ |S )Ng    .A)r_   rb   )'r9   	RunRecord	_settingsentityproject	run_grouprun_job_typejob_typerun_idrun_namedisplay_name	run_notesnotesrun_tagstagsrk   _start_time
start_timeFromMicrosecondsint_starting_stepstarting_stepgit_remote_urlgit
remote_url
git_commitcommitsweep_idhostresumed_forkedforked_config_as_dictro   rl   _telemetry_obj	telemetry	MergeFrom)rF   rH   	proto_runtagconfig_dictr0   r0   r1   	_make_run   sP   













zInterfaceBase._make_runc                 C      |  |}| | d S rI   )r   _publish_runrF   rH   
run_recordr0   r0   r1   publish_run      
zInterfaceBase.publish_runc                 C   rV   rI   rW   rF   rH   r0   r0   r1   r      rY   zInterfaceBase._publish_runcancel_slotc                 C   s   t j|d}| | d S )N)r   )r9   CancelRequest_publish_cancel)rF   r   cancelr0   r0   r1   publish_cancel   s   zInterfaceBase.publish_cancelr   c                 C   rV   rI   rW   )rF   r   r0   r0   r1   r      rY   zInterfaceBase._publish_cancelc                 C   s   | j |||d}| | d S )N)r_   r`   ra   )ro   _publish_config)rF   r_   r`   ra   cfgr0   r0   r1   publish_config   s   zInterfaceBase.publish_configr   c                 C   rV   rI   rW   )rF   r   r0   r0   r1   r      rY   zInterfaceBase._publish_configmetricc                 C   rV   rI   rW   )rF   r   r0   r0   r1   _publish_metric   rY   zInterfaceBase._publish_metricsummary_dictc                 C   s:   t  }| D ]\}}|j }||_t||_q|S rI   )	r9   SummaryRecordrd   re   rf   r`   jsondumpsrg   )rF   r   summaryrm   rn   re   r0   r0   r1   _make_summary_from_dict   s   
z%InterfaceBase._make_summary_from_dictvaluepath_from_rootc                 C   sr   t |tri }| D ]\}}| ||d | ||< q|S tt| j||dd\}}t|t|\}}|r7	 |S )a  Normalize, compress, and encode sub-objects for backend storage.

        value: Object to encode.
        path_from_root: `str` dot separated string from the top-level summary to the
            current `value`.

        Returns:
            A new tree of dict's with large objects replaced with dictionaries
            with "_type" entries that say which type the original data was.
        .r   )	namespace)	rh   dictrd   _summary_encoder   r    rC   r   r   )rF   r   r   
json_valuer`   friendly_value	converted
compressedr0   r0   r1   r      s    

zInterfaceBase._summary_encoder#   c           	      C   s   t  }|jD ]?}|j }t|j}|dksJ |dkr%|j|j n|jd |_d|j}| 	|j
|}t|\}}tj|td|_q|jD ]$}|j }t|j}|dks\J |dkrh|j|j qJ|jd |_qJ|S )Nr   r"   r   )cls)r9   r   re   rf   lenr`   rj   extendjoinr   r   r   r   r   r   rg   remove)	rF   r#   pb_summary_recorditempb_summary_item
key_lengthr   r   _r0   r0   r1   _make_summary
  s.   






zInterfaceBase._make_summaryc                 C   r   rI   )r   _publish_summary)rF   r#   r   r0   r0   r1   publish_summary.  r   zInterfaceBase.publish_summaryr   c                 C   rV   rI   rW   )rF   r   r0   r0   r1   r   2  rY   zInterfaceBase._publish_summary
files_dictr)   c                 C   s8   t  }|d D ]\}}|j }||_t||_q|S )Nr*   )r9   FilesRecordr*   rf   pathr@   r4   )rF   r   r*   r   r4   fr0   r0   r1   _make_files6  s   
zInterfaceBase._make_filesc                 C   r   rI   )r   _publish_files)rF   r   r*   r0   r0   r1   publish_files>  r   zInterfaceBase.publish_filesr*   c                 C   rV   rI   rW   )rF   r*   r0   r0   r1   r   B  rY   zInterfaceBase._publish_filesc                 C   s4   t  }|D ]}|jj|j|jd q| | d S )N)nameversion)r9   PythonPackagesRequestpackagerf   r`   r   _publish_python_packages)rF   working_setpython_packagespkgr0   r0   r1   publish_python_packagesF  s   z%InterfaceBase.publish_python_packagesr   c                 C   rV   rI   rW   )rF   r   r0   r0   r1   r   L     z&InterfaceBase._publish_python_packagesartifactr   c                 C   s   t  }|j|_|j|_|j|_|j|_|j|_|j	r|j	|_	|j
r&|j
|_
|jr2tt|j|_|jr9|j|_| }|rB||_|j|_| j|j|jd |S )N)rb   )r9   ArtifactRecordtyper   
_client_id	client_id_sequence_client_idsequence_client_iddigestdistributed_iddescriptionmetadatar   r   r   _base_idbase_id_ttl_duration_seconds_to_gqlttl_duration_secondsincrementalincremental_beta1_make_artifact_manifestmanifest)rF   r   proto_artifactttl_duration_inputr0   r0   r1   _make_artifactR  s(   zInterfaceBase._make_artifactartifact_manifestc                 C   s(  |pt  }| |_|j |_t|tkr!| |}||_|S |j	 
 p+i 
 D ]\}}|j }||_t||_q,t|j dd dD ]G}|j }	|j|	_|j|	_|jr`|j|	_|jrg|j|	_|jrn|j|	_|jru|j|	_|j|	_|j
 D ]\}}|	j }
||
_t||
_q~qJ|S )Nc                 S   s   | j S rI   r   )rm   r0   r0   r1   <lambda>}  s    z7InterfaceBase._make_artifact_manifest.<locals>.<lambda>)r`   )r9   r   r   storage_policyr   r   MANIFEST_FILE_SIZE_THRESHOLD_write_artifact_manifest_filemanifest_file_pathrl   rd   storage_policy_configrf   r`   r   r   rg   sortedentriesvaluescontentsr   r   sizebirth_artifact_idref
local_path
skip_cacheextra)rF   r   rb   proto_manifestr   rm   rn   r   entryproto_entryproto_extrar0   r0   r1   r   i  s<   




z%InterfaceBase._make_artifact_manifestr   c                 C   s   t t d }|jddd t  dtd d}|| }tj|ddd	 }|j D ]}|	t
|  d
 q,W d    t|S 1 sIw   Y  t|S )Nartifact_manifestsT)parentsexist_okr      z.manifest_contents.jl.gzwtr"   )modecompresslevel
)r   r   mkdirtimer   gzipopenr   r   writer   r   to_jsonstr)rF   r   manifest_dirfilenamer   r   r   r0   r0   r1   r     s   
z+InterfaceBase._write_artifact_manifest_fileportfolio_namealiasesrr   rs   organizationc           	      C   sj   t  }| r|j|_n	|jr|jnd|_||_|p|j|_	|p"d|_
|p(|j|_|j| | |S N )r9   LinkArtifactRequestis_draftr   r   id	server_idr  rr   portfolio_entityportfolio_organizationrs   portfolio_projectportfolio_aliasesr   _deliver_link_artifact)	rF   rH   r   r  r  rr   rs   r  link_artifactr0   r0   r1   deliver_link_artifact  s   



z#InterfaceBase.deliver_link_artifactr!  c                 C   rV   rI   rW   )rF   r!  r0   r0   r1   r     r   z$InterfaceBase._deliver_link_artifactsourcejob_infor   c                 C   sF  | dd }|dkrD| di }| dd| j_| jj| dg  | dd| j_| d}|r8|| j_| d	}|rC|| j_nY|d
kr| di  dd| jj	_
| di  dd| jj	_| jj| dg  | dd| j_| d}|r|| j_| d	}|r|| j_n|dkr| dd| j_ntd|  }|S )z9Construct use_artifact.partial.source_info.source as str.source_typer  r   r#  
entrypointnotebookFbuild_context
dockerfilerepor   remoter   imagedockerzInvalid source type)getstripr   r&  r   r'  r(  r)  r   git_infor+  r   r,  
ValueErrorSerializeToString)r#  r$  r   r%  info_sourcer(  r)  
source_strr0   r0   r1   _make_partial_source_str  s<   



z&InterfaceBase._make_partial_source_struse_artifactjob_namec                 C   sh   ||j _|dd|j j_|dd|j j_|dd|j j_| j|j jj||d}|j jj	| |S )N_versionr  r%  runtime)r#  r$  r   )
partialr7  r.  source_infor8  r%  r9  r5  r#  ParseFromString)rF   r6  r7  r$  r   src_strr0   r0   r1   _make_proto_use_artifact  s   z&InterfaceBase._make_proto_use_artifactc              
   C   s:  |j d us	J dtj|j |j|jd}d|jv ri }z"|d }t|}t	
|}W d    n1 s7w   Y  W n( tye } ztd| d|  td| d|  W Y d }~d S d }~ww z| j||j||jd}W n" ty } ztd|  td|  W Y d }~d S d }~ww | | d S )	NzArtifact must have an id)r  r   r   _partialzwandb-job.jsonz2Failed to download partial job info from artifact z, : )r6  r7  r$  r   z(Failed to construct use artifact proto: )r  r9   UseArtifactRecordr   r   r   	get_entrydownloadr  r   load	Exceptionloggerwarningr   r>  _publish_use_artifact)rF   r   r6  r$  r   r   er0   r0   r1   publish_use_artifact  sL   

	
z"InterfaceBase.publish_use_artifactr   c                 C   rV   rI   rW   rF   r   r0   r0   r1   rG    rY   z#InterfaceBase._publish_use_artifactFTr}   history_stepis_user_createduse_after_commitfinalizec	                 C   s   |  |}	| |}
|	j|
_|	j|
_|	j|
_||
_||
_||
_|
j	|p%g  |
j
	|p-g  t }|j|
 |d ur@||_t |_| |}|S rI   )r   r   rw   rs   rr   user_createdrM  rN  r  r   r}   r9   LogArtifactRequestr   CopyFromrK  r   staging_dir_communicate_artifact)rF   rH   r   r  r}   rK  rL  rM  rN  r   r   log_artifactrespr0   r0   r1   communicate_artifact"  s"   


z"InterfaceBase.communicate_artifactrT  c                 C   rV   rI   rW   )rF   rT  r0   r0   r1   rS  A  r   z#InterfaceBase._communicate_artifactartifact_iddownload_rootallow_missing_referencesr   path_prefixc                 C   s8   t  }||_||_||_||_|pd|_| |}|S r  )r9   DownloadArtifactRequestrW  rX  rY  r   rZ  _deliver_download_artifact)rF   rW  rX  rY  r   rZ  download_artifactrU  r0   r0   r1   deliver_download_artifactG  s   

z'InterfaceBase.deliver_download_artifactr]  c                 C   rV   rI   rW   )rF   r]  r0   r0   r1   r\  X  r   z(InterfaceBase._deliver_download_artifactc           
      C   sl   |  |}| |}	|j|	_|j|	_|j|	_||	_||	_||	_|	j	|p%g  |	j
	|p-g  | |	 d S rI   )r   r   rw   rs   rr   rO  rM  rN  r  r   r}   _publish_artifact)
rF   rH   r   r  r}   rL  rM  rN  r   r   r0   r0   r1   publish_artifact^  s   


zInterfaceBase.publish_artifactc                 C   rV   rI   rW   rJ  r0   r0   r1   r_  t  rY   zInterfaceBase._publish_artifactr  log_dirsaveroot_logdirc                 C   s(   t  }||_||_||_| | d S rI   )r9   TBRecordra  rb  root_dir_publish_tbdata)rF   ra  rb  rc  tbrecordr0   r0   r1   publish_tbdatax  s
   zInterfaceBase.publish_tbdatarg  c                 C   rV   rI   rW   )rF   rg  r0   r0   r1   rf    rY   zInterfaceBase._publish_tbdatatelemc                 C   rV   rI   rW   )rF   ri  r0   r0   r1   _publish_telemetry  rY   z InterfaceBase._publish_telemetry	user_stepstepflushpublish_stepc                 C   s   |p| j }t|||dd}|dd  d|vrt |d< t }| D ]\}}	|j }
||
_	t
|	|
_q%|rA|d urA||j_|d urI||j_| | d S )NT)rl  ignore_copy_err_step
_timestamp)rC   r   popr  r9   PartialHistoryRequestrd   r   rf   r`   r   rg   rl  numactionrm  _publish_partial_history)rF   r_   rk  rl  rm  rn  rH   partial_historyrm   rn   r   r0   r0   r1   publish_partial_history  s   
	
z%InterfaceBase.publish_partial_historyhistoryc                 C   rV   rI   rW   rF   ry  r0   r0   r1   rv    rY   z&InterfaceBase._publish_partial_historyc           	      C   s~   |p| j }t|||d}t }|r|d usJ ||j_|dd  | D ]\}}|j	 }||_
t||_q&| | d S )N)rl  rp  )rC   r   r9   HistoryRecordrl  rt  rr  rd   r   rf   r`   r   rg   _publish_history)	rF   r_   rl  rH   rn  ry  rm   rn   r   r0   r0   r1   publish_history  s   

zInterfaceBase.publish_historyc                 C   rV   rI   rW   rz  r0   r0   r1   r|    rY   zInterfaceBase._publish_historyc                 C   rO   rI   )r9   RunPreemptingRecord_publish_preemptingrF   preempt_recr0   r0   r1   publish_preempting  rU   z InterfaceBase.publish_preemptingr  c                 C   rV   rI   rW   r  r0   r0   r1   r    rY   z!InterfaceBase._publish_preemptingr   c                 C   V   |dkr
t jjj}n|dkrt jjj}ntd t j||d}|j  | | d S Nstdoutstderrzunknown type)output_typeline)	r9   OutputRecord
OutputTypeSTDOUTSTDERRprint	timestampGetCurrentTime_publish_outputrF   r   r_   otypeor0   r0   r1   publish_output     
zInterfaceBase.publish_outputoutdatac                 C   rV   rI   rW   rF   r  r0   r0   r1   r    rY   zInterfaceBase._publish_outputc                 C   r  r  )	r9   OutputRawRecordr  r  r  r  r  r  _publish_output_rawr  r0   r0   r1   publish_output_raw  r  z InterfaceBase.publish_output_rawc                 C   rV   rI   rW   r  r0   r0   r1   r    rY   z!InterfaceBase._publish_output_rawc                 C   rO   rI   )r9   PauseRequest_publish_pauserF   pauser0   r0   r1   publish_pause  rU   zInterfaceBase.publish_pauser  c                 C   rV   rI   rW   r  r0   r0   r1   r    rY   zInterfaceBase._publish_pausec                 C   rO   rI   )r9   ResumeRequest_publish_resumerF   resumer0   r0   r1   publish_resume  rU   zInterfaceBase.publish_resumer  c                 C   rV   rI   rW   r  r0   r0   r1   r    rY   zInterfaceBase._publish_resumetitletextlevelwait_durationc                 C   s.   t  }||_||_||_||_| | d S rI   )r9   AlertRecordr  r  r  r  _publish_alert)rF   r  r  r  r  proto_alertr0   r0   r1   publish_alert  s   zInterfaceBase.publish_alertalertc                 C   rV   rI   rW   )rF   r  r0   r0   r1   r    rY   zInterfaceBase._publish_alert	exit_codec                 C   s   t  }|d ur||_|S rI   )r9   RunExitRecordr  )rF   r  exitr0   r0   r1   
_make_exit  s   zInterfaceBase._make_exitc                 C   r   rI   )r  _publish_exitrF   r  	exit_datar0   r0   r1   publish_exit  r   zInterfaceBase.publish_exitr  c                 C   rV   rI   rW   rF   r  r0   r0   r1   r    rY   zInterfaceBase._publish_exitc                 C   rO   rI   )r9   KeepaliveRequest_publish_keepaliverF   	keepaliver0   r0   r1   publish_keepalive  rU   zInterfaceBase.publish_keepaliver  c                 C   rV   rI   rW   r  r0   r0   r1   r  "  rY   z InterfaceBase._publish_keepaliveinclude_pathsexclude_pathsinput_schema
run_config	file_pathc           
      C   s   |r|rt dt }dd |D }dd |D }|j| |j| tjtj d}	|r;|	j	tj  n|	j
	tjj|d |j	|	 |rSt||_| |S )a  Publishes a request to add inputs to the job.

        If run_config is True, the wandb.config will be added as a job input.
        If file_path is provided, the file at file_path will be added as a job
        input.

        The paths provided as arguments are sequences of dictionary keys that
        specify a path within the wandb.config. If a path is included, the
        corresponding field will be treated as a job input. If a path is
        excluded, the corresponding field will not be treated as a job input.

        Args:
            include_paths: paths within config to include as job inputs.
            exclude_paths: paths within config to exclude as job inputs.
            input_schema: A JSON Schema describing which attributes will be
                editable from the Launch drawer.
            run_config: bool indicating whether wandb.config is the input source.
            file_path: path to file to include as a job input.
        z:run_config and file_path are mutually exclusive arguments.c                 S      g | ]}t j|d qS r   r9   JobInputPath.0r   r0   r0   r1   
<listcomp>F      z3InterfaceBase.publish_job_input.<locals>.<listcomp>c                 S   r  r  r  r  r0   r0   r1   r  G  r  )r  r   )r1  r9   JobInputRequestr  r   r  JobInputSourceRunConfigSourcer  rQ  fileConfigFileSourceinput_sourcer   r  _publish_job_input)
rF   r  r  r  r  r  requestinclude_recordsexclude_recordsr#  r0   r0   r1   publish_job_input&  s*   

zInterfaceBase.publish_job_inputr  c                 C   rV   rI   rW   )rF   r  r0   r0   r1   r  Y  rY   z InterfaceBase._publish_job_inputc                 C   s   | j rd S |  }d S rI   )rD   _communicate_shutdown)rF   r   r0   r0   r1   r   ]  s   zInterfaceBase.joinc                 C   rV   rI   rW   rE   r0   r0   r1   r  c  rY   z#InterfaceBase._communicate_shutdownc                 C      |  |}| |S rI   )r   _deliver_runr   r0   r0   r1   deliver_rung     

zInterfaceBase.deliver_runstart_offsetfinal_offsetrw   skip_output_rawc                 C   sH   t j||d}|r||j_|r||j_|r||j_|r||j_| |S )N)r  r  )	r9   SyncRequest	overwriterr   rs   rw   skip
output_raw_deliver_sync)rF   r  r  rr   rs   rw   r  syncr0   r0   r1   deliver_synck  s   	
zInterfaceBase.deliver_syncr  c                 C   rV   rI   rW   )rF   r  r0   r0   r1   r    rY   zInterfaceBase._deliver_syncc                 C   rV   rI   rW   r   r0   r0   r1   r    rY   zInterfaceBase._deliver_runc                 C   s   t j| |d}| |S )N)rH   )r9   RunStartRequestr   _deliver_run_start)rF   rH   	run_startr0   r0   r1   deliver_run_start  s   
zInterfaceBase.deliver_run_startr  c                 C   rV   rI   rW   )rF   r  r0   r0   r1   r    rY   z InterfaceBase._deliver_run_start	attach_idc                 C   s   t j|d}| |S )N)r  )r9   AttachRequest_deliver_attach)rF   r  attachr0   r0   r1   deliver_attach  s   
zInterfaceBase.deliver_attachc                 C   rV   rI   rW   r^   r0   r0   r1   r    rY   zInterfaceBase._deliver_attachc                 C      t  }| |S rI   )r9   StopStatusRequest_deliver_stop_statusr^   r0   r0   r1   deliver_stop_status     
z!InterfaceBase.deliver_stop_statusc                 C   rV   rI   rW   r^   r0   r0   r1   r    rY   z"InterfaceBase._deliver_stop_statusc                 C   r  rI   )r9   NetworkStatusRequest_deliver_network_statusr^   r0   r0   r1   deliver_network_status  r  z$InterfaceBase.deliver_network_statusc                 C   rV   rI   rW   r^   r0   r0   r1   r    rY   z%InterfaceBase._deliver_network_statusc                 C   r  rI   )r9   InternalMessagesRequest_deliver_internal_messagesrF   internal_messager0   r0   r1   deliver_internal_messages  r  z'InterfaceBase.deliver_internal_messagesr  c                 C   rV   rI   rW   r  r0   r0   r1   r    r   z(InterfaceBase._deliver_internal_messagesc                 C   r  rI   )r9   GetSummaryRequest_deliver_get_summaryrF   get_summaryr0   r0   r1   deliver_get_summary  r  z!InterfaceBase.deliver_get_summaryr  c                 C   rV   rI   rW   r  r0   r0   r1   r    rY   z"InterfaceBase._deliver_get_summaryc                 C   r  rI   )r9   GetSystemMetricsRequest_deliver_get_system_metricsr  r0   r0   r1   deliver_get_system_metrics  r  z(InterfaceBase.deliver_get_system_metricsc                 C   rV   rI   rW   r  r0   r0   r1   r    r   z)InterfaceBase._deliver_get_system_metricsc                 C   r  rI   )r  _deliver_exitr  r0   r0   r1   deliver_exit  r  zInterfaceBase.deliver_exitc                 C   rV   rI   rW   r  r0   r0   r1   r    rY   zInterfaceBase._deliver_exitc                 C   r  rI   )r9   PollExitRequest_deliver_poll_exitrF   	poll_exitr0   r0   r1   deliver_poll_exit  r  zInterfaceBase.deliver_poll_exitr  c                 C   rV   rI   rW   r  r0   r0   r1   r    rY   z InterfaceBase._deliver_poll_exitc                 C   r  rI   )r9   RunFinishWithoutExitRequest_deliver_finish_without_exitrF   run_finish_without_exitr0   r0   r1   deliver_finish_without_exit  r  z)InterfaceBase.deliver_finish_without_exitr  c                 C   rV   rI   rW   r
  r0   r0   r1   r	    r   z*InterfaceBase._deliver_finish_without_exitc                 C   r  rI   )r9   SampledHistoryRequest _deliver_request_sampled_historyrF   sampled_historyr0   r0   r1   deliver_request_sampled_history  r  z-InterfaceBase.deliver_request_sampled_historyr  c                 C   rV   rI   rW   r  r0   r0   r1   r    r   z.InterfaceBase._deliver_request_sampled_historyc                 C   r  rI   )r9   RunStatusRequest_deliver_request_run_statusrF   
run_statusr0   r0   r1   deliver_request_run_status  r  z(InterfaceBase.deliver_request_run_statusr  c                 C   rV   rI   rW   r  r0   r0   r1   r    r   z)InterfaceBase._deliver_request_run_status)r5   N)rH   r2   r5   N)NNNN)NNN)r   r)   r5   NrI   )r   r   r5   N)NNFFT)NFFT)r  )NNTN)NNT)Fr  )r+   r,   r-   r   r/   boolrG   rN   rT   r   r9   rP   rQ   r!   r\   r[   rZ   r   r   r   r  r   rc   ro   rp   r   r   r   r   r   r   r   r   MetricRecordr   r   r   r   srr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r"  r  r   staticmethodr   r5  r@  r>  rI  rG  r   r$   rV  rP  rS  r^  r[  r\  r`  r_  rh  rd  rf  tpbTelemetryRecordrj  rx  rs  rv  r}  r{  r|  r  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	   r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r  r  r  r  r  r  r  r  r  r	  r  r  r  r  r  r  r0   r0   r0   r1   rB   ]   s  
 
*

#$
'	


#


,
	




	







3
rB   )r4   r.   r5   r6   )r?   r6   r5   r.   )E__doc__r  loggingrJ   r  abcr   pathlibr   secretsr   typingr   r   r   r   r	   r
   r   r   r   r   r   r3   r   wandb.protor   r9   r   r  wandb.sdk.artifacts.artifactr   %wandb.sdk.artifacts.artifact_manifestr   wandb.sdk.artifacts.stagingr   wandb.sdk.libr   r   
wandb.utilr   r   r   r   r   r   r   data_types.utilsr   r    lib.mailboxr!   r  r#   r  message_futurer$   r   r  r%   r.   r)   	wandb_runr2   	getLoggerrE  r@   rA   rB   r0   r0   r0   r1   <module>   s>    
4$






