
    1Vh)              
          d Z ddlZddlZddlZddlZddlmZ ddlmZ ddlmZ ddl	m
Z
 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 ej4                  d
iZej8                  dej8                  d
ej8                  d
ej8                  dej8                  diZ ej<                         Z G d dej@                        Z!d Z"d Z#d Z$d Z%y)z?Provides data ingestion logic backed by local event processing.    N)data_provider)plugin_event_multiplexer)	tag_types)tf)ingester)metadata)
tb_logging
   i  i  d   c                   <    e Zd ZdZd Zed        Zed        Zd Zy)LocalDataIngesterz:Data ingestion implementation to use when running locally.c           	         t        t              }|j                  |j                         t	        j
                  t        ||j                  |j                  t        |      |j                        | _        t        j                  | j                  |j                  xs |j                        | _        |j"                  | _        |j&                  | _        |j                  r1t*        j,                  j/                  |j                        di| _        nt3        |j                        | _        t5        t6        dd      dk7  r$t9        | j0                  j;                                yy)zInitializes a `LocalDataIngester` from `flags`.

        Args:
          flags: An argparse.Namespace containing TensorBoard CLI flags.

        Returns:
          The new `LocalDataIngester`.
        )size_guidancetensor_size_guidancepurge_orphaned_datamax_reload_threadsevent_file_active_filterdetect_file_replacementN__version__stub)dictDEFAULT_TENSOR_SIZE_GUIDANCEupdatesamples_per_pluginr   EventMultiplexerDEFAULT_SIZE_GUIDANCEr   r   _get_event_file_active_filterr   _multiplexerr   MultiplexerDataProviderlogdirlogdir_spec_data_providerreload_interval_reload_intervalreload_task_reload_taskospath
expanduser_path_to_run_parse_event_files_specgetattrr   _check_filesystem_supportkeys)selfflagsr   s      b/home/dcms/DCMS/lib/python3.12/site-packages/tensorboard/backend/event_processing/data_ingester.py__init__zLocalDataIngester.__init__7   s     $$@A##E$<$<=4EE/!5 % 9 9$77%B5%I$)$A$A
 ,CCu||@u/@/@
 !& 5 5!--<<!#!3!3ELL!A4 HD 78I8I JD 2}f-7%d&7&7&<&<&>? 8    c                     | j                   S N)r"   r/   s    r1   r   zLocalDataIngester.data_providerX   s    """r3   c                     | j                   S r5   )r   r6   s    r1   deprecated_multiplexerz(LocalDataIngester.deprecated_multiplexer\   s       r3   c                      fd} j                   dk(  rDt        j                  d       ddl}|j	                  |d      }d|_        |j                          y j                   d	v rDt        j                  d
       t        j                  |d      }d|_        |j                          y j                   dk(  r" j                  dk7  rt        d       |        yt        d j                   z        )z?Starts ingesting data based on the ingester flag configuration.c                     	 t        j                          } t        j                  d       j                  j	                         D ]!  \  }}j
                  j                  ||       # t        j                  d       j
                  j                          t        j                          | z
  }t        j                  d|       j                  dk(  ry t        j                  j                         )Nz$TensorBoard reload process beginningz8TensorBoard reload process: Reload the whole Multiplexerz0TensorBoard done reloading. Load took %0.3f secsr   )
timeloggerinfor*   itemsr   AddRunsFromDirectoryReloadr$   sleep)startr(   namedurationr/   s       r1   _reloadz(LocalDataIngester.start.<locals>._reloadc   s    		BC"&"3"3"9"9"; GJD$%%::4FGN !!((*99;.F ((A-

4001! r3   processz#Launching reload in a child processr   NReloader)targetrC   T)threadautoz#Launching reload in a daemon threadblockingz1blocking reload only allowed with load_interval=0zunrecognized reload_task: %s)r&   r<   r=   multiprocessingProcessdaemonrB   	threadingThreadr$   
ValueError)r/   rE   rL   rF   rI   s   `    r1   rB   zLocalDataIngester.start`   s    	2& 	)KK=>"%--W:-NG "GNMMO"44KK=>%%W:FF FMLLN*,$$) G  I;d>O>OOPPr3   N)	__name__
__module____qualname____doc__r2   propertyr   r8   rB    r3   r1   r   r   4   s:    D@B # # ! !,Qr3   r   c                 \    | j                   sy| j                  dk(  rydk  rd S fdS )zReturns a predicate for whether an event file load timestamp is active.

    Returns:
      A predicate function accepting a single UNIX timestamp float argument, or
      None if multi-file loading is not enabled.
    Nr   c                      y)NTrW   )	timestamps    r1   <lambda>z/_get_event_file_active_filter.<locals>.<lambda>   s    r3   c                 8    | z   t        j                          k\  S r5   )r;   )rZ   inactive_secss    r1   r[   z/_get_event_file_active_filter.<locals>.<lambda>   s    Y6$))+E r3   )reload_multifilereload_multifile_inactive_secs)r0   r]   s    @r1   r   r      s;     !!88Mq%%EEr3   c                    i }| |S t        j                  d      }| j                  d      D ]  }|j                  |      Dd|v r@|d   dk7  r8t        j
                  j                  |      d   s|j                  d      \  }}}nd}|}|j                  |      <t        j
                  j                  t        j
                  j                  |            }|||<    |S )a(  Parses `logdir_spec` into a map from paths to run group names.

    The `--logdir_spec` flag format is a comma-separated list of path
    specifications. A path spec looks like 'group_name:/path/to/directory' or
    '/path/to/directory'; in the latter case, the group is unnamed. Group names
    cannot start with a forward slash: /foo:bar/baz will be interpreted as a spec
    with no name and path '/foo:bar/baz'.

    Globs are not supported.

    Args:
      logdir: A comma-separated list of run specifications.
    Returns:
      A dict mapping directory paths to names like {'/path/to/directory': 'name'}.
      Groups without an explicit name are named after their path. If logdir is
      None, returns an empty dict, which is helpful for testing things that don't
      require any valid runs.
    Nz[a-zA-Z][0-9a-zA-Z.]*://.*,:r   /)
recompilesplitmatchr'   r(   
splitdrive	partitionrealpathr)   )r!   filesuri_patternspecificationrun_name_r(   s          r1   r+   r+      s    & E**9:K$**3/  m,4}$a C'GG&&}5a8 !. 7 7 <HaH DT"*77##BGG$6$6t$<=Dd'( Lr3   c                 4    d| vry| j                  d      d   S )ad  Extracts filesystem scheme from a given path.

    The filesystem scheme is usually separated by `://` from the local filesystem
    path if given. For example, the scheme of `file://tmp/tf` is `file`.

    Args:
        path: A strings representing an input log directory.
    Returns:
        Filesystem scheme, None if the path doesn't contain one.
    z://Nr   )rf   )r(   s    r1   _get_filesystem_schemerq      s#     D::eQr3   c           	         t        t        j                  j                  dd      }|dn |       }| D ci c]  }t	        |      | }}d}|j                         D ]=  \  }}|	|	||vs|} n,	 t        j                  j                  j                  |       ? |r	 ddl
}yyc c}w # t        j                  j                  $ r |}Y  0t        j                  j                  $ r Y w xY w# t        $ rL}|rdj                  |      nd}	t        j                  j                  dddj                  ||	            |d}~ww xY w)zExamines the list of filesystems user requested.

    If TF I/O schemes are requested, try to import tensorflow_io module.

    Args:
        paths: A list of strings representing input log directories.
    get_registered_schemesNr   z (supported schemes: {}) zError: Unsupported filename scheme '{}'{}. For additional filesystem support, consider installing TensorFlow I/O (https://www.tensorflow.org/io) via `pip install tensorflow-io`.)r,   r   iogfilerq   r>   existserrorsUnimplementedErrorOpErrortensorflow_ioImportErrorformat)
pathsrs   registered_schemesr(   scheme_to_pathmissing_schemeschemer{   esupported_schemes_msgs
             r1   r-   r-      si    %
-t '.4J4L 
 FKKT,T2D8KNKN&,,. >)//!'""4(& 	  + L 99// !'99$$   	 & +112DE "
 ))..Z &)>? 	s6   B%1)B*C. *C+C+*C+.	E7AD>>E)&rU   r'   rd   rO   r;   $tensorboard.backend.event_processingr   r   r   tensorboard.compatr   tensorboard.datar   tensorboard.plugins.audior   audio_metadatatensorboard.plugins.histogramhistogram_metadatatensorboard.plugins.imageimage_metadatatensorboard.plugins.pr_curvepr_curve_metadatatensorboard.plugins.scalarscalar_metadatatensorboard.utilr	   TENSORSr   PLUGIN_NAMEr   
get_loggerr<   DataIngesterr   r   r+   rq   r-   rW   r3   r1   <module>r      s    F 	 	   ? I : ! % @ H @ F B ' r  ""C!!3   
			 XQ-- XQvF",^  6r3   