
    1VhĽ                        d Z ddlmZmZmZmZ ddlZddlZddlZddl	Z
 G d dej                        Z G d d      Z G d	 d
      Z G d dej                        Z ej"                  d       G d d             Z ej"                  d       G d d             Z ej"                  d       G d d             Z ej"                  d       G d d             Z G d dej                        Z ej"                  d       G d d             Z G d dej                        Z ej"                  d       G d d             Z ej"                  d       G d d              Z G d! d"      Z G d# d$e      Z G d% d&      Z G d' d(e      Z G d) d*      Z G d+ d,e      Z  G d- d.      Z! G d/ d0      Z" G d1 d2      Z#y)3z>Experimental framework for generic TensorBoard data providers.    )
CollectionSequenceTupleUnionNc                   @   e Zd ZdZddZddZej                  dd       Zej                  	 dddd       Z	ej                  	 ddddd	       Z
ej                  	 dddd
       Z	 ddddZ	 dddddZ	 ddddZ	 dddddZddZddddZ	 ddddddZy)DataProvidera}  Interface for reading TensorBoard scalar, tensor, and blob data.

    These APIs are under development and subject to change. For instance,
    providers may be asked to implement more filtering mechanisms, such as
    downsampling strategies or domain restriction by step or wall time.

    The data provider interface specifies three *data classes*: scalars,
    tensors, and blob sequences. All data is stored in *time series* for
    one of these data classes. A time series is identified by run name and
    tag name (each a non-empty text string), as well as an experiment ID
    and plugin name (see below). Points in a time series are uniquely
    indexed by *step*, an arbitrary non-negative integer. Each point in a
    time series also has an associated wall time, plus its actual value,
    which is drawn from the corresponding data class.

    Each point in a scalar time series contains a single scalar value, as
    a 64-bit floating point number. Scalars are "privileged" rather than
    being subsumed under tensors because there are useful operations on
    scalars that don't make sense in the general tensor case: e.g., "list
    all scalar time series with tag name `accuracy` whose exponentially
    weighted moving average is at least 0.999".

    Each point in a tensor time series contains a tensor of arbitrary
    dtype (including byte strings and text strings) and shape (including
    rank-0 tensors, a.k.a. scalars). Each tensor is expected to be
    "reasonably small" to accommodate common database cell size limits.
    For instance, a histogram with a bounded number of buckets (say, 30)
    occupies about 500 bytes, and a PR curve with a bounded number of
    thresholds (say, 201) occupies about 5000 bytes. These are both well
    within typical database tolerances (Google Cloud Spanner: 10 MiB;
    MySQL: 64 KiB), and would be appropriate to store as tensors. By
    contrast, image, audio, or model graph data may easily be multiple
    megabytes in size, and so should be stored as blobs instead. The
    tensors at each step in a time series need not have the same dtype or
    shape.

    Each point in a blob sequence time series contains an ordered sequence
    of zero or more blobs, which are arbitrary data with no tensor
    structure. These might represent PNG-encoded image data, protobuf wire
    encodings of TensorFlow graphs, or PLY-format 3D mesh data, for some
    examples. This data class provides blob *sequences* rather than just
    blobs because it's common to want to take multiple homogeneous samples
    of a given time series: say, "show me the bounding box classifications
    for 3 random inputs from this batch". A single blob can of course be
    represented as a blob sequence that always has exactly one element.

    When reading time series, *downsampling* refers to selecting a
    subset of the points in each time series. Downsampling only occurs
    across the step axis (rather than, e.g., the blobs in a single blob
    sequence datum), and occurs individually within each time series.
    When downsampling, the latest datum should always be included in the
    sample, so that clients have a view of metrics that is maximally up
    to date. Implementations may choose to force the first (oldest)
    datum to be included in each sample as well, but this is not
    required; clients should not make assumptions either way. The
    remainder of the points in the sample should be selected uniformly
    at random from available points. Downsampling should be
    deterministic within a time series. It is also useful for the
    downsampling behavior to depend only on the set of step values
    within a time series, such that two "parallel" time series with data
    at exactly the same steps also retain the same steps after
    downsampling.

    Every time series belongs to a specific experiment and is owned by a
    specific plugin. (Thus, the "primary key" for a time series has four
    components: experiment, plugin, run, tag.) The experiment ID is an
    arbitrary URL-safe non-empty text string, whose interpretation is at
    the discretion of the data provider. As a special case, the empty
    string as an experiment ID denotes that no experiment was given. Data
    providers may or may not fully support an empty experiment ID. The
    plugin name should correspond to the `plugin_data.plugin_name` field
    of the `SummaryMetadata` proto passed to `tf.summary.write`.

    Additionally, the data provider interface specifies one *hyperparameter*
    class, which is metadata about the parameters used to generate the data for
    one or more runs within one or more experiments. Each hyperparameter has a
    value type -- one of string, bool, and float. Each one also has a domain,
    which describes the set of known values for that hyperparameter across the
    given set of experiments.

    There is a corresponding *hyperparameter value* class, which describes an
    actual value of a hyperparameter that was logged during experiment
    execution.

    Each run within an experiment may specify its own value for a
    hyperparameter. Runs that were logically executed together with the same set
    of hyperparameter values form a hyperparameter `session`. Sessions that
    include the same hyperparameter values can be grouped together in a
    hyperparameter `session group`. Often a session group will contain only a
    single session. However, in some scenarios, the same hyperparameters will be
    used to execute multiple jobs with the idea to aggregate the metrics across
    those jobs and analyze non-deterministic factors. In that case, a session
    group will contain multiple sessions. The result will group runs by
    hyperparameter session group and provide one set of hyperparameter values
    for each group.

    All methods on this class take a `RequestContext` parameter as the
    first positional argument. This argument is temporarily optional to
    facilitate migration, but will be required in the future.

    Unless otherwise noted, any methods on this class may raise errors
    defined in `tensorboard.errors`, like `tensorboard.errors.NotFoundError`.

    If not implemented, optional methods may return `None`.
    Nc                    t               S )a  Retrieve metadata of a given experiment.

        The metadata may include fields such as name and description
        of the experiment, as well as a timestamp for the experiment.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_id:  ID of the experiment in question.

        Returns:
          An `ExperimentMetadata` object containing metadata about the
          experiment.
        )ExperimentMetadataselfctxexperiment_ids      I/home/dcms/DCMS/lib/python3.12/site-packages/tensorboard/data/provider.pyexperiment_metadataz DataProvider.experiment_metadata   s     "##    c                     y)a  List all plugins that own data in a given experiment.

        This should be the set of all plugin names `p` such that calling
        `list_scalars`, `list_tensors`, or `list_blob_sequences` for the
        given `experiment_id` and plugin name `p` gives a non-empty
        result.

        This operation is optional, but may later become required.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_id: ID of enclosing experiment.

        Returns:
          A collection of strings representing plugin names, or `None`
          if this operation is not supported by this data provider.
        N r   s      r   list_pluginszDataProvider.list_plugins   s    $ r   c                     y)a>  List all runs within an experiment.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_id: ID of enclosing experiment.

        Returns:
          A collection of `Run` values.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        Nr   r   s      r   	list_runszDataProvider.list_runs        	r   )run_tag_filterc                     y)a  List metadata about scalar time series.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_id: ID of enclosing experiment.
          plugin_name: String name of the TensorBoard plugin that created
            the data to be queried. Required.
          run_tag_filter: Optional `RunTagFilter` value. If omitted, all
            runs and tags will be included.

        The result will only contain keys for run-tag combinations that
        actually exist, which may not include all entries in the
        `run_tag_filter`.

        Returns:
          A nested map `d` such that `d[run][tag]` is a `ScalarTimeSeries`
          value.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        Nr   r   r   r   plugin_namer   s        r   list_scalarszDataProvider.list_scalars   s    2 	r   )
downsampler   c                     y)a  Read values from scalar time series.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_id: ID of enclosing experiment.
          plugin_name: String name of the TensorBoard plugin that created
            the data to be queried. Required.
          downsample: Integer number of steps to which to downsample the
            results (e.g., `1000`). The most recent datum (last scalar)
            should always be included. See `DataProvider` class docstring
            for details about this parameter. Required.
          run_tag_filter: Optional `RunTagFilter` value. If provided, a time
            series will only be included in the result if its run and tag
            both pass this filter. If `None`, all time series will be
            included.

        The result will only contain keys for run-tag combinations that
        actually exist, which may not include all entries in the
        `run_tag_filter`.

        Returns:
          A nested map `d` such that `d[run][tag]` is a list of
          `ScalarDatum` values sorted by step.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        Nr   r   r   r   r   r   r   s         r   read_scalarszDataProvider.read_scalars   s    J 	r   c                     y)a  Read the most recent values from scalar time series.

        The most recent scalar value for each tag under each run is retrieved
        from the latest event (at the latest timestamp). Note that this is
        different from the sorting used in `read_scalars`, which is by step.
        This was an accidental misalignment that would need considerable effort
        to change across our implementations, so we're leaving it as is for now.
        In most cases this should not matter, but if the same log dir is used
        for multiple runs, this might not match the last data point returned by
        the `read_scalars`.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_id: ID of enclosing experiment.
          plugin_name: String name of the TensorBoard plugin that created
            the data to be queried. Required.
          run_tag_filter: Optional `RunTagFilter` value. If provided, a datum
            series will only be included in the result if its run and tag
            both pass this filter. If `None`, all time series will be
            included.

        The result will only contain keys for run-tag combinations that
        actually exist, which may not include all entries in the
        `run_tag_filter`.

        Returns:
          A nested map `d` such that `d[run][tag]` is a `ScalarDatum`
          representing the latest scalar in the time series.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        Nr   r   s        r   read_last_scalarszDataProvider.read_last_scalars   s    R 	r   c                     y)a  List metadata about tensor time series.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_id: ID of enclosing experiment.
          plugin_name: String name of the TensorBoard plugin that created
            the data to be queried. Required.
          run_tag_filter: Optional `RunTagFilter` value. If omitted, all
            runs and tags will be included.

        The result will only contain keys for run-tag combinations that
        actually exist, which may not include all entries in the
        `run_tag_filter`.

        Returns:
          A nested map `d` such that `d[run][tag]` is a `TensorTimeSeries`
          value.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        Nr   r   s        r   list_tensorszDataProvider.list_tensors&  s    0 	r   c                     y)a]  Read values from tensor time series.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_id: ID of enclosing experiment.
          plugin_name: String name of the TensorBoard plugin that created
            the data to be queried. Required.
          downsample: Integer number of steps to which to downsample the
            results (e.g., `1000`). See `DataProvider` class docstring
            for details about this parameter. Required.
          run_tag_filter: Optional `RunTagFilter` value. If provided, a time
            series will only be included in the result if its run and tag
            both pass this filter. If `None`, all time series will be
            included.

        The result will only contain keys for run-tag combinations that
        actually exist, which may not include all entries in the
        `run_tag_filter`.

        Returns:
          A nested map `d` such that `d[run][tag]` is a list of
          `TensorDatum` values sorted by step.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        Nr   r   s         r   read_tensorszDataProvider.read_tensors@  s    F 	r   c                     y)a  List metadata about blob sequence time series.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_id: ID of enclosing experiment.
          plugin_name: String name of the TensorBoard plugin that created the data
            to be queried. Required.
          run_tag_filter: Optional `RunTagFilter` value. If omitted, all runs and
            tags will be included. The result will only contain keys for run-tag
            combinations that actually exist, which may not include all entries in
            the `run_tag_filter`.

        Returns:
          A nested map `d` such that `d[run][tag]` is a `BlobSequenceTimeSeries`
          value.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        Nr   r   s        r   list_blob_sequencesz DataProvider.list_blob_sequencese  s    , 	r   c                     y)a]  Read values from blob sequence time series.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_id: ID of enclosing experiment.
          plugin_name: String name of the TensorBoard plugin that created the data
            to be queried. Required.
          downsample: Integer number of steps to which to downsample the
            results (e.g., `1000`). See `DataProvider` class docstring
            for details about this parameter. Required.
          run_tag_filter: Optional `RunTagFilter` value. If provided, a time series
            will only be included in the result if its run and tag both pass this
            filter. If `None`, all time series will be included. The result will
            only contain keys for run-tag combinations that actually exist, which
            may not include all entries in the `run_tag_filter`.

        Returns:
          A nested map `d` such that `d[run][tag]` is a list of
          `BlobSequenceDatum` values sorted by step.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        Nr   r   s         r   read_blob_sequencesz DataProvider.read_blob_sequences}  s    @ 	r   c                     y)ao  Read data for a single blob.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          blob_key: A key identifying the desired blob, as provided by
            `read_blob_sequences(...)`.

        Returns:
          Raw binary data as `bytes`.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        Nr   )r   r   blob_keys      r   	read_blobzDataProvider.read_blob  r   r   )limitc                    t        g g       S )aC  List hyperparameters metadata.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_ids: A Collection[string] of IDs of the enclosing
            experiments.
          limit: Optional number of hyperparameter metadata to include in the
            result. If unset or zero, all metadata will be included.

        Returns:
          A ListHyperparametersResult describing the hyperparameter-related
          metadata for the experiments.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        )hyperparameterssession_groups)ListHyperparametersResult)r   r   experiment_idsr.   s       r   list_hyperparametersz!DataProvider.list_hyperparameters  s    " )BOOr   )filterssorthparams_to_includec                    g S )a  Read hyperparameter values.

        Args:
          ctx: A TensorBoard `RequestContext` value.
          experiment_ids: A Collection[string] of IDs of the enclosing
            experiments.
          filters: A Collection[HyperparameterFilter] that constrain the
            returned session groups based on hyperparameter value.
          sort: A Sequence[HyperparameterSort] that specify how the results
            should be sorted.
          hparams_to_include: An optional Collection[str] of the full names of
            hyperparameters to include in the results. This collection will be
            augmented to include all the hyperparameters specified in `filters`
            and `sort`. If None, all hyperparameters will be returned.

        Returns:
          A Sequence[HyperparameterSessionGroup] describing the groups and
          their hyperparameter values.

        Raises:
          tensorboard.errors.PublicError: See `DataProvider` class docstring.
        r   )r   r   r3   r5   r6   r7   s         r   read_hyperparametersz!DataProvider.read_hyperparameters  s	    > 	r   N)__name__
__module____qualname____doc__r   r   abcabstractmethodr   r   r    r"   r$   r&   r(   r*   r-   r4   r9   r   r   r   r   r      s*   hT$ ( 	  	FJ 4 	 $ $ $L 	 ( ( (V FJ8 # #L FJ4    D Pd P* 
 r   r   )	metaclassc                   z    e Zd ZdZddddddZed        Zed        Zed        Zed	        Z	d
 Z
d Zd Zd Zy)r
   aI  Metadata about an experiment.

    All fields have default values: i.e., they will always be present on
    the object, but may be omitted in a constructor call.

    Attributes:
      data_location: A human-readable description of the data source, such as a
        path to a directory on disk.
      experiment_name: A user-facing name for the experiment (as a `str`).
      experiment_description: A user-facing description for the experiment
        (as a `str`).
      creation_time: A timestamp for the creation of the experiment, as `float`
        seconds since the epoch.
     r   )data_locationexperiment_nameexperiment_descriptioncreation_timec                <    || _         || _        || _        || _        y r:   _data_location_experiment_name_experiment_description_creation_time)r   rD   rE   rF   rG   s        r   __init__zExperimentMetadata.__init__  s$     , /'=$+r   c                     | j                   S r:   )rJ   r   s    r   rD   z ExperimentMetadata.data_location      """r   c                     | j                   S r:   )rK   rP   s    r   rE   z"ExperimentMetadata.experiment_name  s    $$$r   c                     | j                   S r:   )rL   rP   s    r   rF   z)ExperimentMetadata.experiment_description	  s    +++r   c                     | j                   S r:   )rM   rP   s    r   rG   z ExperimentMetadata.creation_time  rQ   r   c                 ^    | j                   | j                  | j                  | j                  fS )z#Helper for `__eq__` and `__hash__`.rI   rP   s    r   	_as_tuplezExperimentMetadata._as_tuple  s2     !!((	
 	
r   c                 f    t        |t              sy| j                         |j                         k(  S )NF)
isinstancer
   rV   r   others     r   __eq__zExperimentMetadata.__eq__  s)    %!34~~5??#444r   c                 4    t        | j                               S r:   )hashrV   rP   s    r   __hash__zExperimentMetadata.__hash__  s    DNN$%%r   c                     ddj                  d| j                  d| j                  d| j                  d| j                  f      z  S )NzExperimentMetadata(%s), zdata_location=zexperiment_name=zexperiment_description=zcreation_time=)joinrD   rK   rL   rM   rP   s    r   __repr__zExperimentMetadata.__repr__"  sO    '$))&*&8&8:(,(=(=?/3/K/KM&*&9&9;	+
 
 	
r   N)r;   r<   r=   r>   rN   propertyrD   rE   rF   rG   rV   r[   r^   rb   r   r   r   r
   r
     s~    $ !, # # % % , , # #
5
&
r   r
   c                   \    e Zd ZdZdZd Zed        Zed        Zed        Z	d Z
d Zd	 Zy
)RunaQ  Metadata about a run.

    Attributes:
      run_id: A unique opaque string identifier for this run.
      run_name: A user-facing name for this run (as a `str`).
      start_time: The wall time of the earliest recorded event in this
        run, as `float` seconds since epoch, or `None` if this run has no
        recorded events.
    _run_id	_run_name_start_timec                 .    || _         || _        || _        y r:   rf   )r   run_idrun_name
start_times       r   rN   zRun.__init__:  s    !%r   c                     | j                   S r:   )rg   rP   s    r   rk   z
Run.run_id?      ||r   c                     | j                   S r:   )rh   rP   s    r   rl   zRun.run_nameC      ~~r   c                     | j                   S r:   )ri   rP   s    r   rm   zRun.start_timeG      r   c                     t        |t              sy| j                  |j                  k7  ry| j                  |j                  k7  ry| j                  |j                  k7  ryyNFT)rX   re   rg   rh   ri   rY   s     r   r[   z
Run.__eq__K  sO    %%<<5==(>>U__,u000r   c                 Z    t        | j                  | j                  | j                  f      S r:   )r]   rg   rh   ri   rP   s    r   r^   zRun.__hash__V  s"    T\\4>>43C3CDEEr   c                 ~    ddj                  d| j                  d| j                  d| j                  f      z  S )NzRun(%s)r`   zrun_id=z	run_name=zstart_time=)ra   rg   rh   ri   rP   s    r   rb   zRun.__repr__Y  s?    499#||-!%1#'#3#35
 
 	
r   N)r;   r<   r=   r>   	__slots__rN   rc   rk   rl   rm   r[   r^   rb   r   r   r   re   re   -  s_     8I&
        	F
r   re   c                        e Zd ZdZdZdZdZdZy)HyperparameterDomainTypezHDescribes how to represent the set of known values for a hyperparameter.intervaldiscrete_floatdiscrete_stringdiscrete_boolN)r;   r<   r=   r>   INTERVALDISCRETE_FLOATDISCRETE_STRINGDISCRETE_BOOLr   r   r   rz   rz   c  s    R H%N'O#Mr   rz   T)frozenc                       e Zd ZU dZeed<   eed<   dZeedf   ed<   dZ	ee
eef   ee   ee   ee   df   ed<   dZeed<   y)	Hyperparametera#  Metadata about a hyperparameter.

    Attributes:
      hyperparameter_name: A string identifier for the hyperparameter that
        should be unique in any result set of Hyperparameter objects.
      hyperparameter_display_name: A displayable name for the hyperparameter.
        Unlike hyperparameter_name, there is no uniqueness constraint.
      domain_type: A HyperparameterDomainType describing how we represent the
        set of known values in the `domain` attribute.
      domain: A representation of the set of known values for the
        hyperparameter.

        If domain_type is INTERVAL, a Tuple[float, float] describing the
          range of numeric values.
        If domain_type is DISCRETE_FLOAT, a Collection[float] describing the
          finite set of numeric values.
        If domain_type is DISCRETE_STRING, a Collection[string] describing the
          finite set of string values.
        If domain_type is DISCRETE_BOOL, a Collection[bool] describing the
          finite set of bool values.

      differs: Describes whether there are two or more known values for the
        hyperparameter for the set of experiments specified in the
        list_hyperparameters() request. Hyperparameters for which this is
        true are made more prominent or easier to discover in the UI.
    hyperparameter_namehyperparameter_display_nameNdomain_typedomainFdiffers)r;   r<   r=   r>   str__annotations__r   r   rz   r   r   floatr   boolr   r   r   r   r   r   p  sw    6 !$$9=K/56= 	 EeUl534		  GTr   r   c                   P    e Zd ZU dZeed<   dZeedf   ed<   dZ	ee
eedf   ed<   y)HyperparameterValuea|  A hyperparameter value.

    Attributes:
      hyperparameter_name: A string identifier for the hyperparameters. It
        corresponds to the hyperparameter_name field in the Hyperparameter
        class.
      domain_type: A HyperparameterDomainType describing how we represent the
        set of known values in the `domain` attribute.
      value: The value of the hyperparameter.

        If domain_type is INTERVAL or DISCRETE_FLOAT, value is a float.
        If domain_type is DISCRETE_STRING, value is a str.
        If domain_type is DISCRETE_BOOL, value is a bool.
        If domain_type is unknown (None), value is None.
    r   Nr   value)r;   r<   r=   r>   r   r   r   r   rz   r   r   r   r   r   r   r   r     s<      9=K/56=+/E5T4'(/r   r   c                   &    e Zd ZU dZeed<   eed<   y)HyperparameterSessionRunzA single run in a HyperparameterSessionGroup.

    Attributes:
      experiment_id: The id of the experiment to which the run belongs.
      run: The name of the run.
    r   runN)r;   r<   r=   r>   r   r   r   r   r   r   r     s     	Hr   r   c                   <    e Zd ZU dZeed<   ee   ed<   ee   ed<   y)HyperparameterSessionGroupa  A group of sessions logically executed together with the same hparam values.

    A `session` generally represents a particular execution of a job with a given
    set of hyperparameter values. A session may contain multiple related runs
    executed together to train and/or validate a model.

    Often a `session group` will contain only a single session. However, in some
    scenarios, the same hyperparameters will be used to execute multiple jobs
    with the idea to aggregate the metrics across those jobs and analyze
    non-deterministic factors. In that case, a session group will contain multiple
    sessions.

    Attributes:
      root: A descriptor of the common ancestor of all sessions in this
        group.

        In the case where the group contains all runs in the experiment, this
        would just be a HyperparameterSessionRun with the experiment_id property
        set to the experiment's id but run property set to empty.

        In the case where the group contains a subset of runs in the experiment,
        this would be a HyperparameterSessionRun with the experiment_id property
        set and the run property set to the largest common prefix for runs.

        The root might correspond to a session within the group but it is not
        necessary.
      sessions: A sequence of all sessions in this group.
      hyperparameter_values: A collection of all hyperparameter values in this
        group.
    rootsessionshyperparameter_valuesN)	r;   r<   r=   r>   r   r   r   r   r   r   r   r   r   r     s'    > #"/00%&9::r   r   c                       e Zd ZdZdZdZdZy)HyperparameterFilterTypez)Describes how to represent filter values.regexr{   discreteN)r;   r<   r=   r>   REGEXr   DISCRETEr   r   r   r   r     s    3 EHHr   r   c                   X    e Zd ZU dZeed<   eed<   eeee	e	f   e
ee	eef      f   ed<   y)HyperparameterFiltera  A constraint based on hyperparameter value.

    Attributes:
      hyperparameter_name: A string identifier for the hyperparameter to use for
        the filter. It corresponds to the hyperparameter_name field in the
        Hyperparameter class.
      filter_type: A HyperparameterFilterType describing how we represent the
        filter values in the 'filter' attribute.
      filter: A representation of the set of the filter values.

        If filter_type is REGEX, a str containing the regular expression.
        If filter_type is INTERVAL, a Tuple[float, float] describing the min and
          max values of the filter interval.
        If filter_type is DISCRETE a Collection[float|str|bool] describing the
          finite set of filter values.
    r   filter_typefilterN)r;   r<   r=   r>   r   r   r   r   r   r   r   r   r   r   r   r   r     sJ    " ))eUl5T)*+	- r   r   c                       e Zd ZdZdZdZy)HyperparameterSortDirectionz*Describes which direction to sort a value.	ascending
descendingN)r;   r<   r=   r>   	ASCENDING
DESCENDINGr   r   r   r   r     s    4 IJr   r   c                   &    e Zd ZU dZeed<   eed<   y)HyperparameterSorta*  A sort criterium based on hyperparameter value.

    Attributes:
      hyperparameter_name: A string identifier for the hyperparameter to use for
        the sort. It corresponds to the hyperparameter_name field in the
        Hyperparameter class.
      sort_direction: The direction to sort.
    r   sort_directionN)r;   r<   r=   r>   r   r   r   r   r   r   r   r     s     //r   r   c                   2    e Zd ZU dZee   ed<   ee   ed<   y)r2   a  The result from calling list_hyperparameters().

    Attributes:
      hyperparameters: The hyperparameteres belonging to the experiments in the
        request.
      session_groups: The session groups present in the experiments in the
        request.
    r0   r1   N)r;   r<   r=   r>   r   r   r   r   r   r   r   r2   r2   #  s       //9::r   r2   c                       e Zd ZdZdZdddZed        Zed        Zed        Z	ed	        Z
ed
        Zed        Zy)_TimeSerieszMetadata about time series data for a particular run and tag.

    Superclass of `ScalarTimeSeries`, `TensorTimeSeries`, and
    `BlobSequenceTimeSeries`.
    	_max_step_max_wall_time_plugin_content_description_display_name_last_valueN)
last_valuec                X    || _         || _        || _        || _        || _        || _        y r:   r   )r   max_stepmax_wall_timeplugin_contentdescriptiondisplay_namer   s          r   rN   z_TimeSeries.__init__B  s3     "+-')%r   c                     | j                   S r:   )r   rP   s    r   r   z_TimeSeries.max_stepS  rq   r   c                     | j                   S r:   )r   rP   s    r   r   z_TimeSeries.max_wall_timeW  rQ   r   c                     | j                   S r:   )r   rP   s    r   r   z_TimeSeries.plugin_content[  s    ###r   c                     | j                   S r:   )r   rP   s    r   r   z_TimeSeries.description_  s       r   c                     | j                   S r:   )r   rP   s    r   r   z_TimeSeries.display_namec  s    !!!r   c                     | j                   S r:   )r   rP   s    r   r   z_TimeSeries.last_valueg  rs   r   )r;   r<   r=   r>   rx   rN   rc   r   r   r   r   r   r   r   r   r   r   r   2  s    I" &"   # # $ $ ! ! " "    r   r   c                   "    e Zd ZdZd Zd Zd Zy)ScalarTimeSeriesa
  Metadata about a scalar time series for a particular run and tag.

    Attributes:
      max_step: The largest step value of any datum in this scalar time series; a
        nonnegative integer.
      max_wall_time: The largest wall time of any datum in this time series, as
        `float` seconds since epoch.
      plugin_content: A bytestring of arbitrary plugin-specific metadata for this
        time series, as provided to `tf.summary.write` in the
        `plugin_data.content` field of the `metadata` argument.
      description: An optional long-form Markdown description, as a `str` that is
        empty if no description was specified.
      display_name: An optional long-form Markdown description, as a `str` that is
        empty if no description was specified. Deprecated; may be removed soon.
      last_value: An optional value for the latest scalar in the time series,
        corresponding to the scalar at `max_step`. Note that this field might NOT
        be populated by all data provider implementations.
    c                 ^   t        |t              sy| j                  |j                  k7  ry| j                  |j                  k7  ry| j                  |j                  k7  ry| j
                  |j
                  k7  ry| j                  |j                  k7  ry| j                  |j                  k7  ryyru   )rX   r   r   r   r   r   r   r   rY   s     r   r[   zScalarTimeSeries.__eq__  s    %!12>>U__,%"6"665#8#88 2 22!4!44u000r   c                     t        | j                  | j                  | j                  | j                  | j
                  | j                  f      S r:   )r]   r   r   r   r   r   r   rP   s    r   r^   zScalarTimeSeries.__hash__  sH    ##$$!!""  	
 		
r   c           
          ddj                  d| j                  d| j                  d| j                  d| j                  d| j
                  d| j                  f      z  S )	NzScalarTimeSeries(%s)r`   	max_step=max_wall_time=plugin_content=description=display_name=zlast_value=)ra   r   r   r   r   r   r   rP   s    r   rb   zScalarTimeSeries.__repr__  se    %		!%1&*&9&9;'+';';=$($5$57%)%7%79#'#3#35	)
 	
 		
r   Nr;   r<   r=   r>   r[   r^   rb   r   r   r   r   r   l  s    &"



r   r   c                   \    e Zd ZdZdZd Zed        Zed        Zed        Z	d Z
d Zd	 Zy
)ScalarDatumav  A single datum in a scalar time series for a run and tag.

    Attributes:
      step: The global step at which this datum occurred; an integer. This
        is a unique key among data of this time series.
      wall_time: The real-world time at which this datum occurred, as
        `float` seconds since epoch.
      value: The scalar value for this datum; a `float`.
    _step
_wall_time_valuec                 .    || _         || _        || _        y r:   r   )r   step	wall_timer   s       r   rN   zScalarDatum.__init__      
#r   c                     | j                   S r:   r   rP   s    r   r   zScalarDatum.step      zzr   c                     | j                   S r:   r   rP   s    r   r   zScalarDatum.wall_time      r   c                     | j                   S r:   )r   rP   s    r   r   zScalarDatum.value      {{r   c                     t        |t              sy| j                  |j                  k7  ry| j                  |j                  k7  ry| j                  |j                  k7  ryyru   )rX   r   r   r   r   rY   s     r   r[   zScalarDatum.__eq__  sM    %-::$??e...;;%,,&r   c                 Z    t        | j                  | j                  | j                  f      S r:   )r]   r   r   r   rP   s    r   r^   zScalarDatum.__hash__  s     TZZ$++>??r   c                 ~    ddj                  d| j                  d| j                  d| j                  f      z  S )NzScalarDatum(%s)r`   step=
wall_time=zvalue=)ra   r   r   r   rP   s    r   rb   zScalarDatum.__repr__  =     499!ZZ)"&//3"kk+$
 
 	
r   N)r;   r<   r=   r>   rx   rN   rc   r   r   r   r[   r^   rb   r   r   r   r   r     s_     2I
      	@
r   r   c                   "    e Zd ZdZd Zd Zd Zy)TensorTimeSeriesa/  Metadata about a tensor time series for a particular run and tag.

    Attributes:
      max_step: The largest step value of any datum in this tensor time series; a
        nonnegative integer.
      max_wall_time: The largest wall time of any datum in this time series, as
        `float` seconds since epoch.
      plugin_content: A bytestring of arbitrary plugin-specific metadata for this
        time series, as provided to `tf.summary.write` in the
        `plugin_data.content` field of the `metadata` argument.
      description: An optional long-form Markdown description, as a `str` that is
        empty if no description was specified.
      display_name: An optional long-form Markdown description, as a `str` that is
        empty if no description was specified. Deprecated; may be removed soon.
    c                 *   t        |t              sy| j                  |j                  k7  ry| j                  |j                  k7  ry| j                  |j                  k7  ry| j
                  |j
                  k7  ry| j                  |j                  k7  ryyru   )rX   r   r   r   r   r   r   rY   s     r   r[   zTensorTimeSeries.__eq__  s    %!12>>U__,%"6"665#8#88 2 22!4!44r   c                     t        | j                  | j                  | j                  | j                  | j
                  f      S r:   )r]   r   r   r   r   r   rP   s    r   r^   zTensorTimeSeries.__hash__   s?    ##$$!!""
 	
r   c           	          ddj                  d| j                  d| j                  d| j                  d| j                  d| j
                  f      z  S )NzTensorTimeSeries(%s)r`   r   r   r   r   r   )ra   r   r   r   r   r   rP   s    r   rb   zTensorTimeSeries.__repr__  sY    %		!%1&*&9&9;'+';';=$($5$57%)%7%79)
 
 	
r   Nr   r   r   r   r   r     s     	
	
r   r   c                   Z    e Zd ZdZdZd Zed        Zed        Zed        Z	d Z
dZd	 Zy)
TensorDatuma  A single datum in a tensor time series for a run and tag.

    Attributes:
      step: The global step at which this datum occurred; an integer. This
        is a unique key among data of this time series.
      wall_time: The real-world time at which this datum occurred, as
        `float` seconds since epoch.
      numpy: The `numpy.ndarray` value with the tensor contents of this
        datum.
    r   r   _numpyc                 .    || _         || _        || _        y r:   r   )r   r   r   numpys       r   rN   zTensorDatum.__init__%  r   r   c                     | j                   S r:   r   rP   s    r   r   zTensorDatum.step*  r   r   c                     | j                   S r:   r   rP   s    r   r   zTensorDatum.wall_time.  r   r   c                     | j                   S r:   )r   rP   s    r   r   zTensorDatum.numpy2  r   r   c                     t        |t              sy| j                  |j                  k7  ry| j                  |j                  k7  ryt	        j
                  | j                  |j                        syyru   )rX   r   r   r   nparray_equalr   rY   s     r   r[   zTensorDatum.__eq__6  sS    %-::$??e...~~dkk5<<8r   Nc                 ~    ddj                  d| j                  d| j                  d| j                  f      z  S )NzTensorDatum(%s)r`   r   r   znumpy=)ra   r   r   r   rP   s    r   rb   zTensorDatum.__repr__D  r   r   )r;   r<   r=   r>   rx   rN   rc   r   r   r   r[   r^   rb   r   r   r   r   r     s`    	 2I
      	 H
r   r   c                   H     e Zd ZdZdZ fdZed        Zd Zd Z	d Z
 xZS )BlobSequenceTimeSeriesa  Metadata about a blob sequence time series for a particular run and tag.

    Attributes:
      max_step: The largest step value of any datum in this scalar time series; a
        nonnegative integer.
      max_wall_time: The largest wall time of any datum in this time series, as
        `float` seconds since epoch.
      max_length: The largest length (number of blobs) of any datum in
        this scalar time series, or `None` if this time series is empty.
      plugin_content: A bytestring of arbitrary plugin-specific metadata for this
        time series, as provided to `tf.summary.write` in the
        `plugin_data.content` field of the `metadata` argument.
      description: An optional long-form Markdown description, as a `str` that is
        empty if no description was specified.
      display_name: An optional long-form Markdown description, as a `str` that is
        empty if no description was specified. Deprecated; may be removed soon.
    _max_lengthc                <    t         |   |||||       || _        y )N)r   r   r   r   r   )superrN   r   )r   r   r   
max_lengthr   r   r   	__class__s          r   rN   zBlobSequenceTimeSeries.__init__c  s0     	')#% 	 	
 &r   c                     | j                   S r:   r   rP   s    r   r   z!BlobSequenceTimeSeries.max_lengthv  rs   r   c                 ^   t        |t              sy| j                  |j                  k7  ry| j                  |j                  k7  ry| j                  |j                  k7  ry| j
                  |j
                  k7  ry| j                  |j                  k7  ry| j                  |j                  k7  ryyru   )rX   r   r   r   r   r   r   r   rY   s     r   r[   zBlobSequenceTimeSeries.__eq__z  s    %!78>>U__,%"6"66u0005#8#88 2 22!4!44r   c                     t        | j                  | j                  | j                  | j                  | j
                  | j                  f      S r:   )r]   r   r   r   r   r   r   rP   s    r   r^   zBlobSequenceTimeSeries.__hash__  sH    ##  $$!!""	
 		
r   c           
          ddj                  d| j                  d| j                  d| j                  d| j                  d| j
                  d| j                  f      z  S )	NzBlobSequenceTimeSeries(%s)r`   r   r   zmax_length=r   r   r   )ra   r   r   r   r   r   r   rP   s    r   rb   zBlobSequenceTimeSeries.__repr__  se    +dii!%1&*&9&9;#'#3#35'+';';=$($5$57%)%7%79	/
 	
 		
r   )r;   r<   r=   r>   rx   rN   rc   r   r[   r^   rb   __classcell__)r   s   @r   r   r   N  s7    $ !I&&    "



r   r   c                   N    e Zd ZdZdZd
dZed        Zed        Zd Z	d Z
d	 Zy)BlobReferenceaA  A reference to a blob.

    Attributes:
      blob_key: A string containing a key uniquely identifying a blob, which
        may be dereferenced via `provider.read_blob(blob_key)`.

        These keys must be constructed such that they can be included directly in
        a URL, with no further encoding. Concretely, this means that they consist
        exclusively of "unreserved characters" per RFC 3986, namely
        [a-zA-Z0-9._~-]. These keys are case-sensitive; it may be wise for
        implementations to normalize case to reduce confusion. The empty string
        is not a valid key.

        Blob keys must not contain information that should be kept secret.
        Privacy-sensitive applications should use random keys (e.g. UUIDs), or
        encrypt keys containing secret fields.
      url: (optional) A string containing a URL from which the blob data may be
        fetched directly, bypassing the data provider. URLs may be a vector
        for data leaks (e.g. via browser history, web proxies, etc.), so these
        URLs should not expose secret information.
    )_url	_blob_keyNc                      || _         || _        y r:   )r	  r  )r   r,   urls      r   rN   zBlobReference.__init__  s    !	r   c                     | j                   S )a;  Provide a key uniquely identifying a blob.

        Callers should consider these keys to be opaque-- i.e., to have
        no intrinsic meaning. Some data providers may use random IDs;
        but others may encode information into the key, in which case
        callers must make no attempt to decode it.
        )r	  rP   s    r   r,   zBlobReference.blob_key  s     ~~r   c                     | j                   S )aB  Provide the direct-access URL for this blob, if available.

        Note that this method is *not* expected to construct a URL to
        the data-loading endpoint provided by TensorBoard. If this
        method returns None, then the caller should proceed to use
        `blob_key()` to build the URL, as needed.
        )r  rP   s    r   r  zBlobReference.url  s     yyr   c                     t        |t              sy| j                  |j                  k7  ry| j                  |j                  k7  ryyru   )rX   r  r	  r  rY   s     r   r[   zBlobReference.__eq__  s8    %/>>U__,99

"r   c                 D    t        | j                  | j                  f      S r:   )r]   r	  r  rP   s    r   r^   zBlobReference.__hash__  s    T^^TYY/00r   c                 b    ddj                  d| j                  d| j                  f      z  S )NzBlobReference(%s)r`   z	blob_key=zurl=)ra   r	  r  rP   s    r   rb   zBlobReference.__repr__  s0    "TYY"nn.DII0GH&
 
 	
r   r:   )r;   r<   r=   r>   rx   rN   rc   r,   r  r[   r^   rb   r   r   r   r  r    sJ    , &I    1
r   r  c                   \    e Zd ZdZdZd Zed        Zed        Zed        Z	d Z
d Zd	 Zy
)BlobSequenceDatuma  A single datum in a blob sequence time series for a run and tag.

    Attributes:
      step: The global step at which this datum occurred; an integer. This is a
        unique key among data of this time series.
      wall_time: The real-world time at which this datum occurred, as `float`
        seconds since epoch.
      values: A tuple of `BlobReference` objects, providing access to elements of
        this sequence.
    r   r   _valuesc                 .    || _         || _        || _        y r:   r  )r   r   r   valuess       r   rN   zBlobSequenceDatum.__init__  s    
#r   c                     | j                   S r:   r   rP   s    r   r   zBlobSequenceDatum.step  r   r   c                     | j                   S r:   r   rP   s    r   r   zBlobSequenceDatum.wall_time   r   r   c                     | j                   S r:   )r  rP   s    r   r  zBlobSequenceDatum.values  ro   r   c                     t        |t              sy| j                  |j                  k7  ry| j                  |j                  k7  ry| j                  |j                  k7  ryyru   )rX   r  r   r   r  rY   s     r   r[   zBlobSequenceDatum.__eq__  sN    %!23::$??e...<<5==(r   c                 Z    t        | j                  | j                  | j                  f      S r:   )r]   r   r   r  rP   s    r   r^   zBlobSequenceDatum.__hash__  s     TZZ$,,?@@r   c                 ~    ddj                  d| j                  d| j                  d| j                  f      z  S )NzBlobSequenceDatum(%s)r`   r   r   zvalues=)ra   r   r   r  rP   s    r   rb   zBlobSequenceDatum.__repr__  s=    &!ZZ)"&//3#||-*
 
 	
r   N)r;   r<   r=   r>   rx   rN   rc   r   r   r  r[   r^   rb   r   r   r   r  r    s_    	 3I
      	A
r   r  c                   D    e Zd ZdZddZd Zed        Zed        Zd Z	y)	RunTagFilterz"Filters data by run and tag names.Nc                 `    | j                  d|      | _        | j                  d|      | _        y)a  Construct a `RunTagFilter`.

        A time series passes this filter if both its run *and* its tag are
        included in the corresponding whitelists.

        Order and multiplicity are ignored; `runs` and `tags` are treated as
        sets.

        Args:
          runs: Collection of run names, as strings, or `None` to admit all
            runs.
          tags: Collection of tag names, as strings, or `None` to admit all
            tags.
        runstagsN)_parse_optional_string_set_runs_tags)r   r   r!  s      r   rN   zRunTagFilter.__init__#  s,     44VTB
44VTB
r   c                     |y t        |t              rt        |dt        |      d|      t	        |      }|D ].  }t        |t              rt        |dt        |      d|       |S )Nz0: expected `None` or collection of strings; got z: z=: expected `None` or collection of strings; got item of type )rX   r   	TypeErrortype	frozenset)r   namer   items       r   r"  z'RunTagFilter._parse_optional_string_set5  s}    =eS! ee-  %  	DdC(15tDz4I 	 r   c                     | j                   S r:   )r#  rP   s    r   r   zRunTagFilter.runsH  r   r   c                     | j                   S r:   )r$  rP   s    r   r!  zRunTagFilter.tagsL  r   r   c                 b    ddj                  d| j                  d| j                  f      z  S )NzRunTagFilter(%s)r`   zruns=ztags=)ra   r#  r$  rP   s    r   rb   zRunTagFilter.__repr__P  s3    !DII!ZZ)!ZZ)%
 
 	
r   )NN)
r;   r<   r=   r>   rN   r"  rc   r   r!  rb   r   r   r   r  r     s=    ,C$&    
r   r  )$r>   typingr   r   r   r   r?   dataclassesenumr   r   ABCMetar   r
   re   Enumrz   	dataclassr   r   r   r   r   r   r   r   r2   r   r   r   r   r   r   r  r  r  r   r   r   <module>r4     s   E 6 5 
   GS[[ GTF
 F
R3
 3
l
$tyy 
$ d#& & $&R d#0 0 $0, d#	 	 $	 d#"; "; $";Jtyy  d#  $6$))  d#0 0 $0 d#; ; $;7  7 t;
{ ;
|3
 3
l4
{ 4
n4
 4
nS
[ S
lB
 B
J4
 4
n6
 6
r   