o
    -wi                      @   s~  d 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( ddl)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0 ddl1m2Z2m3Z3 ddl4m5Z6 dZ7ede8Z9ed Z:G dd deZ;erddl<m=Z= e>dZ?d&dd Z@d'd"d#ZAG d$d% d%ZBdS )(a4  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
    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)HandleAbandonedErrorMailboxHandle)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   )summary_recordi 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   Z/home/ubuntu/sommelier/.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_enumE   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_policyO   s   rA   c                   @   s
  e Zd ZU eed< d$ddZd$ddZedej	ddfd	d
Z
deej fddZedejdeej 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"d-edej#fd.d/Z$d0ed1edddefd2d3Z%d4e&j#dddej#fd5d6Z'ddd4e&j#ddfd7d8Z(ed9ej#ddfd:d;Z)d<d=dej*fd>d?Z+d(d@dAZ,edBej*ddfdCdDZ-d$dEdFZ.edGej/ddfdHdIZ0dJdKdej1fdLdMZ2	d)dNe3deej3 dej3fdOdPZ4dQe3defdRdSZ5			d'dJdKdTedUe6e dVee dWee dXee deej fdYdZZ7ed[ej8deej fd\d]Z9e:d^ed_e;eef d`e;eef defdadbZ<dcej=dded_e;eef d`e;eef dej=f
dedfZ>	J	K		d*dgdhZ?ediej=ddfdjdkZ@			l	l	md+dddJdKdUe6e dnee6e  doeeA dpedqedredeej fdsdtZBeduejCdeej fdvdwZDdxedyedzed{ed|ee deej fd}d~ZEedejFdeej fddZG		l	l	md,dddJdKdUe6e dnee6e  dpedqedreddfddZHediej1ddfddZId-dedededdfddZJedejKddfddZLedeMjNddfddZOdejPddfddZQedejPddfddZR			md.dddedeAdeeA dee deddfddZSedejTddfddZU		md/dddedeeA deddf
ddZVedejWddfddZXd$ddZYedejZddfddZ[dededdfddZ\edej]ddfddZ^dededdfddZ_edej`ddfddZad$ddZbedejcddfddZdd$ddZeedejfddfddZgdedededeAddf
ddZhedejiddfddńZjdeeA dejkfddȄZldeeA ddfddʄZmedejkddfdd̈́Znd$ddτZoedejpddfdd҄Zq	l	d0derere  derere  dee dedef
ddلZsedejtdeej fdd܄Zud$ddބZvedeej fddZwdddeej fddZxdeej fddZyedejzdeej fddZ{edejdeej fddZ|dddeej fddZ}edej~deej fddZdedeej fddZedejdeej fddZdeej fddZedejdeej fddZdeej fddZedejdeej fddZdeej fddZedejdeej fdd Zdeej fddZedejdeej fddZdeej fddZedejdeej fdd	ZdeeA deej fd
dZedejkdeej fddZedeej fddZdeej fddZedejdeej fddZdeej fddZedejdeej fddZdeej fddZedejdeej fddZdeej fdd Zed!ejdeej fd"d#ZdS (1  InterfaceBase_dropr5   Nc                 C   s
   d| _ d S )NF)rC   selfr0   r0   r1   __init__\   s   
zInterfaceBase.__init__c                 C      t  }| | d S N)r9   HeaderRecord_publish_headerrE   headerr0   r0   r1   publish_header_      zInterfaceBase.publish_headerrL   c                 C      t rH   NotImplementedErrorrK   r0   r0   r1   rJ   c      zInterfaceBase._publish_headerc                 C   s   |  t S rH   )_deliver_statusr9   StatusRequestrD   r0   r0   r1   deliver_statusg      zInterfaceBase.deliver_statusstatusc                 C   rO   rH   rP   rE   rW   r0   r0   r1   rS   j      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)	rE   rZ   r[   r\   r]   configkvr`   r0   r0   r1   _make_configq   s   


zInterfaceBase._make_configrunr2   c                 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r_|j|jj |jd uro|jt|jd  |jd urx|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jr|jj}|j|j _|j!|j _!|j"|j _"|jj#r|jj#}|j|j _|j!|j _!|j"|j _"|j$r|j$|_%|j&d ur|j&' }| j(||j)d |j*r|j+,|j* |j-r|j-|_.|S )Ng    .A)rZ   r]   )/r9   	RunRecord	_settingsentityproject	run_grouprun_job_typejob_typerun_idrun_namedisplay_name	run_notesnotesrun_tagstagsextend_start_time
start_timeFromMicrosecondsint_starting_stepstarting_stepgit_remote_urlgit
remote_url
git_commitcommitsweep_idhostresumed	fork_fromrk   branch_pointmetricvalueresume_from_forkedforked_config_as_dictrj   rg   _telemetry_obj	telemetry	MergeFrom_start_runtimeruntime)rE   rk   	proto_run
run_momentconfig_dictr0   r0   r1   	_make_run   sf   



















zInterfaceBase._make_runc                 C      |  |}| | d S rH   )r   _publish_runrE   rk   
run_recordr0   r0   r1   publish_run      
zInterfaceBase.publish_runc                 C   rO   rH   rP   rE   rk   r0   r0   r1   r      rR   zInterfaceBase._publish_runcancel_slotc                 C   s   t j|d}| | d S )N)r   )r9   CancelRequest_publish_cancel)rE   r   cancelr0   r0   r1   publish_cancel   s   zInterfaceBase.publish_cancelr   c                 C   rO   rH   rP   )rE   r   r0   r0   r1   r      rR   zInterfaceBase._publish_cancelc                 C   s   | j |||d}| | d S )N)rZ   r[   r\   )rj   _publish_config)rE   rZ   r[   r\   cfgr0   r0   r1   publish_config   s   zInterfaceBase.publish_configr   c                 C   rO   rH   rP   )rE   r   r0   r0   r1   r      rR   zInterfaceBase._publish_configr   c                 C   rO   rH   rP   )rE   r   r0   r0   r1   _publish_metric   rR   zInterfaceBase._publish_metricsummary_dictc                 C   s:   t  }| D ]\}}|j }||_t||_q|S rH   )	r9   SummaryRecordr_   r`   ra   r[   jsondumpsrb   )rE   r   summaryrh   ri   r`   r0   r0   r1   _make_summary_from_dict   s   
z%InterfaceBase._make_summary_from_dictr   path_from_rootc           	      C   st   t |tr i }| D ]\}}| j||d | |d||< q|S tt|||dd\}}t|t|\}}|r8	 |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.
        .rk   r   )	namespace)rc   dictr_   _summary_encoder   r"   r   r   )	rE   r   r   rk   
json_valuer[   friendly_value	converted
compressedr0   r0   r1   r      s$   

zInterfaceBase._summary_encoder$   c           
      C   s   t  }|jD ]A}|j }t|j}|dksJ |dkr%|j|j n|jd |_d|j}| j	|j
||d}t|\}}	tj|td|_q|jD ]$}|j }t|j}|dks^J |dkrj|j|j qL|jd |_qL|S )Nr   r#   r   r   )cls)r9   r   r`   ra   lenr[   re   rz   joinr   r   r   r   r   r   rb   remove)
rE   r$   rk   pb_summary_recorditempb_summary_item
key_lengthr   r   _r0   r0   r1   _make_summary  s6   






zInterfaceBase._make_summaryc                 C   s   | j ||d}| | d S Nr   )r   _publish_summary)rE   rk   r$   r   r0   r0   r1   publish_summary=  s   zInterfaceBase.publish_summaryr   c                 C   rO   rH   rP   )rE   r   r0   r0   r1   r   E  rR   zInterfaceBase._publish_summary
files_dictr)   c                 C   s8   t  }|d D ]\}}|j }||_t||_q|S )Nr*   )r9   FilesRecordr*   ra   pathr@   r4   )rE   r   r*   r   r4   fr0   r0   r1   _make_filesI  s   
zInterfaceBase._make_filesc                 C   r   rH   )r   _publish_files)rE   r   r*   r0   r0   r1   publish_filesQ  r   zInterfaceBase.publish_filesr*   c                 C   rO   rH   rP   )rE   r*   r0   r0   r1   r   U  rR   zInterfaceBase._publish_filesc                 C   s4   t  }|D ]}|jj|j|jd q| | d S )N)nameversion)r9   PythonPackagesRequestpackagera   r[   r   _publish_python_packages)rE   working_setpython_packagespkgr0   r0   r1   publish_python_packagesY  s   z%InterfaceBase.publish_python_packagesr   c                 C   rO   rH   rP   )rE   r   r0   r0   r1   r   _     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)r]   )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)rE   r   proto_artifactttl_duration_inputr0   r0   r1   _make_artifacte  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 rH   r   )rh   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_pathrg   r_   storage_policy_configra   r[   r   r   rb   sortedentriesvaluescontentsr   r   sizebirth_artifact_idref
local_path
skip_cacheextra)rE   r   r]   proto_manifestr   rh   ri   r   entryproto_entryproto_extrar0   r0   r1   r   |  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)rE   r   manifest_dirfilenamer   r   r  r0   r0   r1   r     s   
z+InterfaceBase._write_artifact_manifest_fileportfolio_namealiasesrn   ro   organizationc                 C   sf   t  }| r|j|_n	|jr|jnd|_||_|pd|_|p!d|_	|p&d|_
|j| | |S N )r9   LinkArtifactRequestis_draftr   r   id	server_idr  portfolio_entityportfolio_organizationportfolio_projectportfolio_aliasesrz   _deliver_link_artifact)rE   r   r  r  rn   ro   r  link_artifactr0   r0   r1   deliver_link_artifact  s   	




z#InterfaceBase.deliver_link_artifactr$  c                 C   rO   rH   rP   )rE   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)  rz   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(  r   )r&  r'  r   )
partialr:  r1  source_infor;  r(  r   r8  r&  ParseFromString)rE   r9  r:  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, : )r9  r:  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)rE   r   r9  r'  r   r   er0   r0   r1   publish_use_artifact  sL   

	
z"InterfaceBase.publish_use_artifactr   c                 C   rO   rH   rP   rE   r   r0   r0   r1   rI  0  rR   z#InterfaceBase._publish_use_artifactFTry   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 rH   )r   r   rs   ro   rn   user_createdrO  rP  r  rz   ry   r9   LogArtifactRequestr   CopyFromrM  r   staging_dir_deliver_artifact)rE   rk   r   r  ry   rM  rN  rO  rP  r   r   log_artifactrespr0   r0   r1   deliver_artifact4  s"   


zInterfaceBase.deliver_artifactrV  c                 C   rO   rH   rP   )rE   rV  r0   r0   r1   rU  S  rY   zInterfaceBase._deliver_artifactartifact_iddownload_rootallow_missing_referencesr   path_prefixc                 C   s8   t  }||_||_||_||_|pd|_| |}|S r  )r9   DownloadArtifactRequestrY  rZ  r[  r   r\  _deliver_download_artifact)rE   rY  rZ  r[  r   r\  download_artifactrW  r0   r0   r1   deliver_download_artifactZ  s   

z'InterfaceBase.deliver_download_artifactr_  c                 C   rO   rH   rP   )rE   r_  r0   r0   r1   r^  k  r   z(InterfaceBase._deliver_download_artifactc           
      C   sl   |  |}| |}	|j|	_|j|	_|j|	_||	_||	_||	_|	j	|p%g  |	j
	|p-g  | |	 d S rH   )r   r   rs   ro   rn   rQ  rO  rP  r  rz   ry   _publish_artifact)
rE   rk   r   r  ry   rN  rO  rP  r   r   r0   r0   r1   publish_artifactq  s   


zInterfaceBase.publish_artifactc                 C   rO   rH   rP   rL  r0   r0   r1   ra    rR   zInterfaceBase._publish_artifactr  log_dirsaveroot_logdirc                 C   s(   t  }||_||_||_| | d S rH   )r9   TBRecordrc  rd  root_dir_publish_tbdata)rE   rc  rd  re  tbrecordr0   r0   r1   publish_tbdata  s
   zInterfaceBase.publish_tbdatari  c                 C   rO   rH   rP   )rE   ri  r0   r0   r1   rh    rR   zInterfaceBase._publish_tbdatatelemc                 C   rO   rH   rP   )rE   rk  r0   r0   r1   _publish_telemetry  rR   z InterfaceBase._publish_telemetryenvironmentc                 C   s   |  | d S rH   )_publish_environmentrE   rm  r0   r0   r1   publish_environment  rV   z!InterfaceBase.publish_environmentc                 C   rO   rH   rP   ro  r0   r0   r1   rn    rR   z"InterfaceBase._publish_environment	user_stepstepflushpublish_stepc                 C   s   t |||dd}|dd  d|vrt |d< t }| D ]\}}	|j }
||
_t	|	|
_
q |r<|d ur<||j_|d urD||j_| | d S )NT)rr  ignore_copy_err_step
_timestamp)r!   popr  r9   PartialHistoryRequestr_   r   ra   r[   r   rb   rr  numactionrs  _publish_partial_history)rE   rk   rZ   rq  rr  rs  rt  partial_historyrh   ri   r   r0   r0   r1   publish_partial_history  s   	
z%InterfaceBase.publish_partial_historyhistoryc                 C   rO   rH   rP   rE   r  r0   r0   r1   r|    rR   z&InterfaceBase._publish_partial_historyc           	      C   st   t |||d}t }|r|d usJ ||j_|dd  | D ]\}}|j }||_	t
||_q!| | d S )N)rr  rv  )r!   r9   HistoryRecordrr  rz  rx  r_   r   ra   r[   r   rb   _publish_history)	rE   rk   rZ   rr  rt  r  rh   ri   r   r0   r0   r1   publish_history  s   
zInterfaceBase.publish_historyc                 C   rO   rH   rP   r  r0   r0   r1   r    rR   zInterfaceBase._publish_historyc                 C   rG   rH   )r9   RunPreemptingRecord_publish_preemptingrE   preempt_recr0   r0   r1   publish_preempting  rN   z InterfaceBase.publish_preemptingr  c                 C   rO   rH   rP   r  r0   r0   r1   r    rR   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STDERRr   	timestampGetCurrentTime_publish_outputrE   r   rZ   otypeor0   r0   r1   publish_output     
zInterfaceBase.publish_outputoutdatac                 C   rO   rH   rP   rE   r  r0   r0   r1   r    rR   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   rO   rH   rP   r  r0   r0   r1   r    rR   z!InterfaceBase._publish_output_rawc                 C   rG   rH   )r9   PauseRequest_publish_pauserE   pauser0   r0   r1   publish_pause	  rN   zInterfaceBase.publish_pauser  c                 C   rO   rH   rP   r  r0   r0   r1   r    rR   zInterfaceBase._publish_pausec                 C   rG   rH   )r9   ResumeRequest_publish_resumerE   resumer0   r0   r1   publish_resume  rN   zInterfaceBase.publish_resumer  c                 C   rO   rH   rP   r  r0   r0   r1   r    rR   zInterfaceBase._publish_resumetitletextlevelwait_durationc                 C   s.   t  }||_||_||_||_| | d S rH   )r9   AlertRecordr  r  r  r  _publish_alert)rE   r  r  r  r  proto_alertr0   r0   r1   publish_alert  s   zInterfaceBase.publish_alertalertc                 C   rO   rH   rP   )rE   r  r0   r0   r1   r  #  rR   zInterfaceBase._publish_alert	exit_codec                 C   s   t  }|d ur||_|S rH   )r9   RunExitRecordr  )rE   r  exitr0   r0   r1   
_make_exit'  s   zInterfaceBase._make_exitc                 C   r   rH   )r  _publish_exitrE   r  	exit_datar0   r0   r1   publish_exit-  r   zInterfaceBase.publish_exitr  c                 C   rO   rH   rP   rE   r  r0   r0   r1   r  1  rR   zInterfaceBase._publish_exitc                 C   rG   rH   )r9   KeepaliveRequest_publish_keepaliverE   	keepaliver0   r0   r1   publish_keepalive5  rN   zInterfaceBase.publish_keepaliver  c                 C   rO   rH   rP   r  r0   r0   r1   r  9  rR   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>]      z3InterfaceBase.publish_job_input.<locals>.<listcomp>c                 S   r  r  r  r  r0   r0   r1   r  ^  r  )r  r   )r4  r9   JobInputRequestr  rz   r  JobInputSourceRunConfigSourcer  rS  fileConfigFileSourceinput_sourcer   r  _publish_job_input)
rE   r  r  r  r  r  requestinclude_recordsexclude_recordsr&  r0   r0   r1   publish_job_input=  s*   

zInterfaceBase.publish_job_inputr  c                 C   rO   rH   rP   )rE   r  r0   r0   r1   r  p  r   z InterfaceBase._publish_job_inputc                 C   s`   | j rd S |  }z	|jdd W d S  ty!   td Y d S  ty/   td Y d S w )N   )timeoutz timed out communicating shutdownz-handle abandoned while communicating shutdown)rC   _deliver_shutdownwait_orTimeoutErrorrG  rH  r   )rE   handler0   r0   r1   r   v  s   zInterfaceBase.joinc                 C   rO   rH   rP   rD   r0   r0   r1   r    rR   zInterfaceBase._deliver_shutdownc                 C      |  |}| |S rH   )r   _deliver_runr   r0   r0   r1   deliver_run     

zInterfaceBase.deliver_runc                 C      t  }| |S rH   )r9   SyncFinishRequest_deliver_finish_syncrE   syncr0   r0   r1   deliver_finish_sync  s   
z!InterfaceBase.deliver_finish_syncr  c                 C   rO   rH   rP   r  r0   r0   r1   r    r   z"InterfaceBase._deliver_finish_syncc                 C   rO   rH   rP   r   r0   r0   r1   r    rR   zInterfaceBase._deliver_runc                 C   s   t j| |d}| |S r   )r9   RunStartRequestr   _deliver_run_start)rE   rk   	run_startr0   r0   r1   deliver_run_start  s   
zInterfaceBase.deliver_run_startr  c                 C   rO   rH   rP   )rE   r  r0   r0   r1   r    r   z InterfaceBase._deliver_run_start	attach_idc                 C   s   t j|d}| |S )N)r  )r9   AttachRequest_deliver_attach)rE   r  attachr0   r0   r1   deliver_attach  s   
zInterfaceBase.deliver_attachc                 C   rO   rH   rP   rX   r0   r0   r1   r    rY   zInterfaceBase._deliver_attachc                 C   r  rH   )r9   StopStatusRequest_deliver_stop_statusrX   r0   r0   r1   deliver_stop_status     
z!InterfaceBase.deliver_stop_statusc                 C   rO   rH   rP   rX   r0   r0   r1   r    rY   z"InterfaceBase._deliver_stop_statusc                 C   r  rH   )r9   NetworkStatusRequest_deliver_network_statusrX   r0   r0   r1   deliver_network_status  r  z$InterfaceBase.deliver_network_statusc                 C   rO   rH   rP   rX   r0   r0   r1   r    rY   z%InterfaceBase._deliver_network_statusc                 C   r  rH   )r9   InternalMessagesRequest_deliver_internal_messagesrE   internal_messager0   r0   r1   deliver_internal_messages  r  z'InterfaceBase.deliver_internal_messagesr  c                 C   rO   rH   rP   r  r0   r0   r1   r    r   z(InterfaceBase._deliver_internal_messagesc                 C   r  rH   )r9   GetSummaryRequest_deliver_get_summaryrE   get_summaryr0   r0   r1   deliver_get_summary  r  z!InterfaceBase.deliver_get_summaryr  c                 C   rO   rH   rP   r   r0   r0   r1   r    rY   z"InterfaceBase._deliver_get_summaryc                 C   r  rH   )r9   GetSystemMetricsRequest_deliver_get_system_metrics)rE   get_system_metricsr0   r0   r1   deliver_get_system_metrics  r  z(InterfaceBase.deliver_get_system_metricsc                 C   rO   rH   rP   r   r0   r0   r1   r    r   z)InterfaceBase._deliver_get_system_metricsc                 C   r  rH   )r  _deliver_exitr  r0   r0   r1   deliver_exit  r  zInterfaceBase.deliver_exitc                 C   rO   rH   rP   r  r0   r0   r1   r    rY   zInterfaceBase._deliver_exitc                 C   rO   rH   rP   rD   r0   r0   r1   deliver_operation_stats  rR   z%InterfaceBase.deliver_operation_statsc                 C   r  rH   )r9   PollExitRequest_deliver_poll_exitrE   	poll_exitr0   r0   r1   deliver_poll_exit  r  zInterfaceBase.deliver_poll_exitr  c                 C   rO   rH   rP   r  r0   r0   r1   r    rY   z InterfaceBase._deliver_poll_exitc                 C   r  rH   )r9   RunFinishWithoutExitRequest_deliver_finish_without_exitrE   run_finish_without_exitr0   r0   r1   deliver_finish_without_exit  r  z)InterfaceBase.deliver_finish_without_exitr  c                 C   rO   rH   rP   r  r0   r0   r1   r    r   z*InterfaceBase._deliver_finish_without_exitc                 C   r  rH   )r9   SampledHistoryRequest _deliver_request_sampled_historyrE   sampled_historyr0   r0   r1   deliver_request_sampled_history  r  z-InterfaceBase.deliver_request_sampled_historyr  c                 C   rO   rH   rP   r  r0   r0   r1   r    r   z.InterfaceBase._deliver_request_sampled_historyc                 C   r  rH   )r9   RunStatusRequest_deliver_request_run_statusrE   
run_statusr0   r0   r1   deliver_request_run_status  r  z(InterfaceBase.deliver_request_run_statusr  c                 C   rO   rH   rP   r  r0   r0   r1   r    r   z)InterfaceBase._deliver_request_run_status)r5   N)NNNN)rk   r2   r5   N)NNN)r   r)   r5   NrH   )r   r   r5   N)NNFFT)NFFT)r  )NNT)NT)Fr  )r+   r,   r-   boolr/   rF   rM   r   r9   rI   rJ   r   ResultrU   rT   rS   r   r   r   r   r  r   r^   rj   rl   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   r8  rB  r@  rK  rI  r~   rX  rR  rU  r`  r]  r^  rb  ra  rj  rf  rh  tpbTelemetryRecordrl  EnvironmentRecordrp  rn  r~  ry  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  r  r  r0   r0   r0   r1   rB   Y   sH  
 
5


*
,

'


#


,
	




	







3
 rB   )r4   r.   r5   r6   )r?   r6   r5   r.   )C__doc__r  loggingr  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.sdk.mailboxr   r   
wandb.utilr   r   r   r   r   r   r   data_types.utilsr!   r"   r  r$   r!  r   r  r%   r.   r)   	wandb_runr2   	getLoggerrG  r@   rA   rB   r0   r0   r0   r1   <module>   s:    4$






