o
    2h{                     @   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_utilhparams)r   )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)plugin_namecontent)plugin_data)
isinstancer   HParamsPluginData	TypeErrortypeCopyFromPLUGIN_DATA_VERSIONversionr   SummaryMetadata
PluginDataPLUGIN_NAMESerializeToString)hparams_plugin_data_pbr    r   _/var/www/html/chatgem/venv/lib/python3.10/site-packages/tensorboard/plugins/hparams/metadata.pycreate_summary_metadata)   s    
r   c                 C   
   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.
    
experiment_parse_plugin_data_asr   r   r   r   parse_experiment_plugin_dataE   s   

r!   c                 C   r   )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.
    session_start_infor   r    r   r   r   $parse_session_start_info_plugin_dataR      
	r#   c                 C   r   )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.
    session_end_infor   r    r   r   r   "parse_session_end_info_plugin_data^   r$   r&   c                 C   sR   t j| }|jtkrtdt|j|f ||s$t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   
FromStringr   r   r   HParamsErrorHasFieldgetattr)r   data_oneof_fieldr   r   r   r   r   j   s   




r   N)__doc__tensorboard.compat.protor   r   tensorboard.plugins.hparamsr   r   tensorboard.utilr   r   r   make_tensor_protoDT_FLOATNULL_TENSOREXPERIMENT_TAGSESSION_START_INFO_TAGSESSION_END_INFO_TAGr   r!   r#   r&   r   r   r   r   r   <module>   s&   