
    BVh$
                     L    d Z ddlZddlZddlmZ ddlmZ d Z G d de	      Z
y)zkTF2 parameter server training utilities.

Parameter server training in TF2 is currently under development.
    N)
tf_logging)
server_libc                    | j                   dk(  s3| j                   dk(  s$t        dj                  | j                               t        j                  | j                         j                         | j                   | j                  |      }t        j                  d| j                   | j                         |j                          y)z2Start a server and block the process from exiting.workerpsz*Unexpected task_type to start a server: {})job_name
task_indexprotocolz.TensorFlow server started for job %s, task %d.N)	task_type
ValueErrorformatr   Servercluster_specas_cluster_deftask_idlogginginfojoin)cluster_resolverr
   servers      ^/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/distribute/coordinator/utils.pystart_serverr      s     
$
$
0

$
$
,
AHH""$ % % ##%446))!))	& 
,,?))+;+C+CE 	++-    c                   .    e Zd ZdZd Zd Zd Zd Zd Zy)RepeatedTimerz7Threaded Repeated Timer from http://shortn/_3hMZTFr1Iv.c                     d | _         || _        || _        || _        t	        j                         | _        d| _        | j                          y NF)_timerintervalfunctionargstime
start_time
is_runningstart)selfr   r    r!   s       r   __init__zRepeatedTimer.__init__3   s;    DKDMDMDIiikDODOJJLr   c                 V    t        t        j                         | j                  z
        S )N)intr"   r#   r&   s    r   _get_duration_seczRepeatedTimer._get_duration_sec<   s    tyy{T__,--r   c                 d    d| _         | j                           | j                  | j                    y r   )r$   r%   r    r!   r*   s    r   _runzRepeatedTimer._run?   s$    DOJJLDMM499r   c                     | j                   sQt        j                  | j                  | j                        | _        | j
                  j                          d| _         y y )NT)r$   	threadingTimerr   r-   r   r%   r*   s    r   r%   zRepeatedTimer.startD   s?    ??OODMM499=dk
kkdo r   c                 h    | j                         }| j                  j                          d| _        |S r   )r+   r   cancelr$   )r&   durations     r   stopzRepeatedTimer.stopJ   s,    %%'HKKDOOr   N)	__name__
__module____qualname____doc__r'   r+   r-   r%   r4    r   r   r   r   0   s    ?.
r   r   )r8   r/   r"   tensorflow.python.platformr   r   tensorflow.python.trainingr   r   objectr   r9   r   r   <module>r=      s)      < 1,F r   