
    1Vh;C                        d Z ddlZddlZddlmZ  G d de      Zej                  Zej                  Zej                  Z	ej                  Z
ej                  Zej                  Zej                  Zej                  Zej                  Zej                   Zej"                  Zej$                  Zej&                  Zej(                  Zej*                  Zej,                  Zej.                  Z G d de      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z  G d de      Z! G d de      Z" G d de      Z# G d d e      Z$ G d! d"e      Z% G d# d$e      Z& G d% d&e      Z'i eee	ee
eeeeeeeeeeeee ee!ee"ee#ee$ee%ee&ee'Z( e)d' e(jU                         D              Z+d( Z,d) Z-d* Z. G d+ d,      Z/y)-z&Exception types for TensorFlow errors.    N   )error_codesc                   h     e Zd ZdZ fdZed        Zed        Zed        Zed        Z	d Z
 xZS )OpErrorzA generic error that is raised when TensorFlow execution fails.

    Whenever possible, the session will raise a more specific subclass
    of `OpError` from the `tf.errors` module.
    c                 Z    t         |           || _        || _        || _        || _        y)a  Creates a new `OpError` indicating that a particular op failed.

        Args:
          node_def: The `node_def_pb2.NodeDef` proto representing the op that
            failed, if known; otherwise None.
          op: The `ops.Operation` that failed, if known; otherwise None.
          message: The message string describing the failure.
          error_code: The `error_codes.Code` describing the error.
        N)super__init___message	_node_def_op_error_codeselfnode_defopmessage
error_code	__class__s        Y/home/dcms/DCMS/lib/python3.12/site-packages/tensorboard/compat/tensorflow_stub/errors.pyr	   zOpError.__init__    s-     	!%    c                     | j                   S )z+The error message that describes the error.)r
   r   s    r   r   zOpError.message0   s     }}r   c                     | j                   S )a  The operation that failed, if known.

        *N.B.* If the failed op was synthesized at runtime, e.g. a `Send`
        or `Recv` op, there will be no corresponding
        @{tf.Operation}
        object.  In that case, this will return `None`, and you should
        instead use the @{tf.OpError.node_def} to
        discover information about the op.

        Returns:
          The `Operation` that failed, or None.
        )r   r   s    r   r   z
OpError.op5   s     xxr   c                     | j                   S )z0The integer error code that describes the error.)r   r   s    r   r   zOpError.error_codeE   s     r   c                     | j                   S )z4The `NodeDef` proto representing the op that failed.)r   r   s    r   r   zOpError.node_defJ   s     ~~r   c                 6   | j                   | j                  d| j                   j                  dg}t        j                  | j                   j                        }|j                  |       | j                   j                  }||j                  d|j                  d       |}t        j                  |j                        }d}d}d }t        ||      D ]^  \  }}	||	k(  r |r|dz  }|}|j                  |       d}d}+|r!|dkD  r|j                  d|dz
  fz  |g       d}|j                  |       ` |j                  }||j                  d	t        |       j                  d
| j                  d	       dj                  |      S | j                  S )Nz

Caused by op z, defined at:
z'
...which was originally created as op Fr   r   Tz4[elided %d identical lines from previous traceback]

z (see above for traceback):  )r   r   name	tracebackformat_listextend_original_opappendziptype__name__join)
r   outputcurr_traceback_listoriginal_opprev_traceback_list
is_elidingelide_countlast_elided_linelineline_in_prevs
             r   __str__zOpError.__str__O   s   88 <<0F #,"7"78J8J"KMM-.((//K)"''* ':#&/&;&;))'# #
#' *-')<+ ,&D, |+%'1,K/3,"MM$/)-J*+K%*Q &(_+6?*<)=(8%&!" */Jd+-,2 *66U )X MM:&&6 776?"<<r   )r'   
__module____qualname____doc__r	   propertyr   r   r   r   r2   __classcell__r   s   @r   r   r      sb    &           = r   r   c                   "     e Zd ZdZ fdZ xZS )CancelledErroraf  Raised when an operation or step is cancelled.

    For example, a long-running operation (e.g.
    @{tf.QueueBase.enqueue} may be
    cancelled by running another operation (e.g.
    @{tf.QueueBase.close},
    or by @{tf.Session.close}.
    A step that is running such a long-running operation will fail by raising
    `CancelledError`.

    @@__init__
    c                 2    t         |   |||t               y)zCreates a `CancelledError`.N)r   r	   	CANCELLEDr   r   r   r   r   s       r   r	   zCancelledError.__init__       2w	:r   r'   r3   r4   r5   r	   r7   r8   s   @r   r:   r:      s    ; ;r   r:   c                   &     e Zd ZdZef fd	Z xZS )UnknownErroraJ  Unknown error.

    An example of where this error may be returned is if a Status value
    received from another address space belongs to an error-space that
    is not known to this address space. Also errors raised by APIs that
    do not return enough error information may be converted to this
    error.

    @@__init__
    c                 *    t         |   ||||       y)zCreates an `UnknownError`.N)r   r	   r   s        r   r	   zUnknownError.__init__   s    2w
;r   )r'   r3   r4   r5   UNKNOWNr	   r7   r8   s   @r   rA   rA      s    	 :A < <r   rA   c                   "     e Zd ZdZ fdZ xZS )InvalidArgumentErrora  Raised when an operation receives an invalid argument.

    This may occur, for example, if an operation is receives an input
    tensor that has an invalid value or shape. For example, the
    @{tf.matmul} op will raise this
    error if it receives an input that is not a matrix, and the
    @{tf.reshape} op will raise
    this error if the new shape does not match the number of elements in the input
    tensor.

    @@__init__
    c                 2    t         |   |||t               y)z"Creates an `InvalidArgumentError`.N)r   r	   INVALID_ARGUMENTr=   s       r   r	   zInvalidArgumentError.__init__   s    2w0@Ar   r?   r8   s   @r   rE   rE      s    B Br   rE   c                   "     e Zd ZdZ fdZ xZS )DeadlineExceededErrorzRaised when a deadline expires before an operation could complete.

    This exception is not currently used.

    @@__init__
    c                 2    t         |   |||t               y)z"Creates a `DeadlineExceededError`.N)r   r	   DEADLINE_EXCEEDEDr=   s       r   r	   zDeadlineExceededError.__init__       2w0ABr   r?   r8   s   @r   rI   rI      s    C Cr   rI   c                   "     e Zd ZdZ fdZ xZS )NotFoundErrora  Raised when a requested entity (e.g., a file or directory) was not
    found.

    For example, running the
    @{tf.WholeFileReader.read}
    operation could raise `NotFoundError` if it receives the name of a file that
    does not exist.

    @@__init__
    c                 2    t         |   |||t               y)zCreates a `NotFoundError`.N)r   r	   	NOT_FOUNDr=   s       r   r	   zNotFoundError.__init__  r>   r   r?   r8   s   @r   rN   rN     s    	; ;r   rN   c                   "     e Zd ZdZ fdZ xZS )AlreadyExistsErrora  Raised when an entity that we attempted to create already exists.

    For example, running an operation that saves a file
    (e.g. @{tf.train.Saver.save})
    could potentially raise this exception if an explicit filename for an
    existing file was passed.

    @@__init__
    c                 2    t         |   |||t               y)z Creates an `AlreadyExistsError`.N)r   r	   ALREADY_EXISTSr=   s       r   r	   zAlreadyExistsError.__init__  s    2w?r   r?   r8   s   @r   rR   rR     s    @ @r   rR   c                   "     e Zd ZdZ fdZ xZS )PermissionDeniedErrora)  Raised when the caller does not have permission to run an operation.

    For example, running the
    @{tf.WholeFileReader.read}
    operation could raise `PermissionDeniedError` if it receives the name of a
    file for which the user does not have the read file permission.

    @@__init__
    c                 2    t         |   |||t               y)z"Creates a `PermissionDeniedError`.N)r   r	   PERMISSION_DENIEDr=   s       r   r	   zPermissionDeniedError.__init__/  rL   r   r?   r8   s   @r   rV   rV   $  s    C Cr   rV   c                   "     e Zd ZdZ fdZ xZS )UnauthenticatedErrorz{The request does not have valid authentication credentials.

    This exception is not currently used.

    @@__init__
    c                 2    t         |   |||t               y)z"Creates an `UnauthenticatedError`.N)r   r	   UNAUTHENTICATEDr=   s       r   r	   zUnauthenticatedError.__init__=  s    2w@r   r?   r8   s   @r   rZ   rZ   5  s    A Ar   rZ   c                   "     e Zd ZdZ fdZ xZS )ResourceExhaustedErrorzSome resource has been exhausted.

    For example, this error might be raised if a per-user quota is
    exhausted, or perhaps the entire file system is out of space.

    @@__init__
    c                 2    t         |   |||t               y)z#Creates a `ResourceExhaustedError`.N)r   r	   RESOURCE_EXHAUSTEDr=   s       r   r	   zResourceExhaustedError.__init__L  s    2w0BCr   r?   r8   s   @r   r^   r^   C  s    D Dr   r^   c                   "     e Zd ZdZ fdZ xZS )FailedPreconditionErrorzOperation was rejected because the system is not in a state to execute
    it.

    This exception is most commonly raised when running an operation
    that reads a @{tf.Variable}
    before it has been initialized.

    @@__init__
    c                 2    t         |   |||t               y)z$Creates a `FailedPreconditionError`.N)r   r	   FAILED_PRECONDITIONr=   s       r   r	   z FailedPreconditionError.__init__]  s    2w0CDr   r?   r8   s   @r   rb   rb   R  s    E Er   rb   c                   "     e Zd ZdZ fdZ xZS )AbortedErrorzThe operation was aborted, typically due to a concurrent action.

    For example, running a
    @{tf.QueueBase.enqueue}
    operation may raise `AbortedError` if a
    @{tf.QueueBase.close} operation
    previously ran.

    @@__init__
    c                 2    t         |   |||t               y)zCreates an `AbortedError`.N)r   r	   ABORTEDr=   s       r   r	   zAbortedError.__init__o  s    2w8r   r?   r8   s   @r   rf   rf   c  s    	9 9r   rf   c                   "     e Zd ZdZ fdZ xZS )OutOfRangeErrora  Raised when an operation iterates past the valid input range.

    This exception is raised in "end-of-file" conditions, such as when a
    @{tf.QueueBase.dequeue}
    operation is blocked on an empty queue, and a
    @{tf.QueueBase.close}
    operation executes.

    @@__init__
    c                 2    t         |   |||t               y)zCreates an `OutOfRangeError`.N)r   r	   OUT_OF_RANGEr=   s       r   r	   zOutOfRangeError.__init__  s    2w=r   r?   r8   s   @r   rj   rj   u  s    	> >r   rj   c                   "     e Zd ZdZ fdZ xZS )UnimplementedErrorak  Raised when an operation has not been implemented.

    Some operations may raise this error when passed otherwise-valid
    arguments that it does not currently support. For example, running
    the @{tf.nn.max_pool} operation
    would raise this error if pooling was requested on the batch dimension,
    because this is not yet supported.

    @@__init__
    c                 2    t         |   |||t               y)z Creates an `UnimplementedError`.N)r   r	   UNIMPLEMENTEDr=   s       r   r	   zUnimplementedError.__init__  s    2w>r   r?   r8   s   @r   rn   rn     s    	? ?r   rn   c                   "     e Zd ZdZ fdZ xZS )InternalErrorzRaised when the system experiences an internal error.

    This exception is raised when some invariant expected by the runtime
    has been broken. Catching this exception is not recommended.

    @@__init__
    c                 2    t         |   |||t               y)zCreates an `InternalError`.N)r   r	   INTERNALr=   s       r   r	   zInternalError.__init__  s    2w9r   r?   r8   s   @r   rr   rr     s    : :r   rr   c                   "     e Zd ZdZ fdZ xZS )UnavailableErrorzqRaised when the runtime is currently unavailable.

    This exception is not currently used.

    @@__init__
    c                 2    t         |   |||t               y)zCreates an `UnavailableError`.N)r   r	   UNAVAILABLEr=   s       r   r	   zUnavailableError.__init__  s    2w<r   r?   r8   s   @r   rv   rv     s    = =r   rv   c                   "     e Zd ZdZ fdZ xZS )DataLossErrorzRaised when unrecoverable data loss or corruption is encountered.

    For example, this may be raised by running a
    @{tf.WholeFileReader.read}
    operation, if the file is truncated while it is being read.

    @@__init__
    c                 2    t         |   |||t               y)zCreates a `DataLossError`.N)r   r	   	DATA_LOSSr=   s       r   r	   zDataLossError.__init__  r>   r   r?   r8   s   @r   rz   rz     s    ; ;r   rz   c              #   *   K   | ]  \  }}||f  y wN ).0codeclass_s      r   	<genexpr>r     s     Kvfd^Ks   c                     t         |    S r~   )_CODE_TO_EXCEPTION_CLASS)r   s    r   exception_type_from_error_coder     s    #J//r   c                     t         |    S r~   )_EXCEPTION_CLASS_TO_CODE)clss    r   error_code_from_exception_typer     s    #C((r   c                     	 t        |      } || ||      S # t        $ r) t        j                  d|z         t	        | |||      cY S w xY w)NzUnknown error code: %d)r   KeyErrorwarningswarnrA   )r   r   r   r   exc_types        r   _make_specific_exceptionr     sR    ?1*="g.. ?.;<Hb':>>?s    /A	A	c                       e Zd ZdZd Zd Zy) raise_exception_on_not_ok_statusz*Context manager to check for C API status.c                      y)NzStatus not OKr   r   s    r   	__enter__z*raise_exception_on_not_ok_status.__enter__  s    r   c                      y)NFr   )r   type_arg	value_argtraceback_args       r   __exit__z)raise_exception_on_not_ok_status.__exit__  s    r   N)r'   r3   r4   r5   r   r   r   r   r   r   r     s    4r   r   )0r5   r    r   r   r   	Exceptionr   OKr<   rC   rG   rK   rP   rT   rX   r\   r`   rd   rh   rl   rp   rt   rx   r|   r:   rA   rE   rI   rN   rR   rV   rZ   r^   rb   rf   rj   rn   rr   rv   rz   r   dictitemsr   r   r   r   r   r   r   r   <module>r      s   -   s i s l ^^!!	


//   11  !!	++11  -- 33  "55  

''))%%!!	
;W ;(<7 <$B7 B(
CG 
C;G ;$@ @"CG C"
A7 
ADW DEg E"97 9$>g >$? ?$:G :
=w 
=;G ;~\ * ,	
 } & , ) . 0 \ / % m !  }! &  K*B*H*H*JK 0
)? r   