
    
                     R    S r SSKJr  SSKJr  SSKJr  SrSSSS	.r " S
 S\	5      r
g)z2Utilities for Edge ML API long-running operations.    )util)waiter)	resourcesi'	 z+Analyzing Edge machine learning model. [{}]z9Optimizing Edge machine learning model for Edge TPU. [{}]z,Converting SavedModel to TF Lite model. [{}])analyzecompileconvertc                   .    \ rS rSrSrSS jrS rS rSrg)	OperationsClient    zClient for the Edge ML operations API.

Attributes:
  client: Generated Edge ML API client.
  messages: Generated Edge ML API messages.
Nc                     U=(       d    [         R                  " 5       U l        U=(       d    [         R                  " U5      U l        U R                  R
                  U l        g )N)r   GetClientInstanceclientGetMessagesModulemessages
operations_service)selfr   r   s      /lib/googlecloudsdk/api_lib/edgeml/operations.py__init__OperationsClient.__init__(   s?    4D224DK> 6 6v >DMKK**DM    c                     U R                   R                  R                  U R                  R	                  UR                  5       S95      $ )zCalls get method for long-running operations.

Args:
  operation_ref: Ref to long-running operation.

Returns:
  edgeml.Operation message.
)name)r   projects_operationsGetr   EdgemlOperationsGetRequestRelativeName)r   operation_refs     r   r   OperationsClient.Get-   sD     ;;**..00++- 	1 	/0 0r   c                 B   [         R                  " U R                  5      n[        R                  R                  UR                  SS9nUR                  5       R                  S5      S   n[        R                  US5      n[         R                  " UUUS[        SSSSS	9	$ )
a*  Wait until the operation is complete or times out.

Args:
  operation: The operation resource to wait on.

Returns:
  The operation resource when it has completed.

Raises:
  OperationTimeoutError: When the operation polling times out.
  OperationError: When the operation completed with an error.
zedgeml.operations)
collection/r   zWaiting for operation [{}]i  Ni  )pre_start_sleep_msmax_wait_msexponential_sleep_multiplier	jitter_mswait_ceiling_mssleep_ms)r   CloudOperationPollerNoResourcesr   r   REGISTRYParser   Namesplit_WAITING_MESSAGEgetWaitFor_MAX_WAIT_TIME_MS)r   	operationpollerr   operation_typemessages         r   WaitForOperation!OperationsClient.WaitForOperation:   s     33DMMBF&&,,#6 - 8M"'')//4Q7N"">3OPG>>%%)	 	r   )r   r   r   )NN)	__name__
__module____qualname____firstlineno____doc__r   r   r6   __static_attributes__ r   r   r
   r
       s    +
0r   r
   N)r<   googlecloudsdk.api_lib.edgemlr   googlecloudsdk.api_lib.utilr   googlecloudsdk.corer   r1   r.   objectr
   r>   r   r   <module>rC      s<    9 / . ) #  =J= 5v 5r   