a
    d=ic{                     @   s   d 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Z	dZ
ejg ejdd	Zd
ZdZdZdd Zdd Zdd Zdd Zdd ZdS )z%Constants used in the HParams plugin.    )summary_pb2)	types_pb2)error)plugin_data_pb2)tensor_utilZhparams)r   )Zdtypeshapez_hparams_/experimentz_hparams_/session_start_infoz_hparams_/session_end_infoc                 C   sP   t | tjstdt|  t }||  t|_tj	tj	j
t| ddS )ak  Returns a summary metadata for the HParams plugin.

    Returns a summary_pb2.SummaryMetadata holding a copy of the given
    HParamsPluginData message in its plugin_data.content field.
    Sets the version field of the hparams_plugin_data_pb copy to
    PLUGIN_DATA_VERSION.

    Args:
      hparams_plugin_data_pb: the HParamsPluginData protobuffer to use.
    z@Needed an instance of plugin_data_pb2.HParamsPluginData. Got: %s)Zplugin_namecontent)plugin_data)
isinstancer   HParamsPluginData	TypeErrortypeZCopyFromPLUGIN_DATA_VERSIONversionr   ZSummaryMetadataZ
PluginDataPLUGIN_NAMEZSerializeToString)Zhparams_plugin_data_pbr    r   u/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/tensorboard/plugins/hparams/metadata.pycreate_summary_metadata)   s     
r   c                 C   s
   t | dS )a,  Returns the experiment from HParam's
    SummaryMetadata.plugin_data.content.

    Raises HParamsError if the content doesn't have 'experiment' set or
    this file is incompatible with the version of the metadata stored.

    Args:
      content: The SummaryMetadata.plugin_data.content to use.
    Z
experiment_parse_plugin_data_asr   r   r   r   parse_experiment_plugin_dataE   s    
r   c                 C   s
   t | dS )a  Returns session_start_info from the plugin_data.content.

    Raises HParamsError if the content doesn't have 'session_start_info' set or
    this file is incompatible with the version of the metadata stored.

    Args:
      content: The SummaryMetadata.plugin_data.content to use.
    Zsession_start_infor   r   r   r   r   $parse_session_start_info_plugin_dataR   s    	r   c                 C   s
   t | dS )a  Returns session_end_info from the plugin_data.content.

    Raises HParamsError if the content doesn't have 'session_end_info' set or
    this file is incompatible with the version of the metadata stored.

    Args:
      content: The SummaryMetadata.plugin_data.content to use.
    Zsession_end_infor   r   r   r   r   "parse_session_end_info_plugin_data^   s    	r   c                 C   sR   t j| }|jtkr,tdt|j|f ||sHtd||f t||S )ag  Returns a data oneof's field from plugin_data.content.

    Raises HParamsError if the content doesn't have 'data_oneof_field' set or
    this file is incompatible with the version of the metadata stored.

    Args:
      content: The SummaryMetadata.plugin_data.content to use.
      data_oneof_field: string. The name of the data oneof field to return.
    z7Only supports plugin_data version: %s; found: %s in: %sz*Expected plugin_data.%s to be set. Got: %s)	r   r   Z
FromStringr   r   r   ZHParamsErrorZHasFieldgetattr)r   Zdata_oneof_fieldr	   r   r   r   r   j   s    



r   N)__doc__Ztensorboard.compat.protor   r   Ztensorboard.plugins.hparamsr   r   Ztensorboard.utilr   r   r   Zmake_tensor_protoZDT_FLOATZNULL_TENSORZEXPERIMENT_TAGZSESSION_START_INFO_TAGZSESSION_END_INFO_TAGr   r   r   r   r   r   r   r   r   <module>   s$   