Operation¶
-
class
tamr_unify_client.operation.
Operation
(client, data, alias=None)[source]¶ A long-running operation performed by Tamr. Operations appear on the “Jobs” page of the Tamr UI.
By design, client-side operations represent server-side operations at a particular point in time (namely, when the operation was fetched from the server). In other words: Operations will not pick up on server-side changes automatically. To get an up-to-date representation, refetch the operation e.g.
op = op.poll()
.-
classmethod
from_response
(client, response)[source]¶ Handle idiosyncrasies in constructing Operations from Tamr responses. When a Tamr API call would start an operation, but all results that would be produced by that operation are already up-to-date, Tamr returns HTTP 204 No Content
To make it easy for client code to handle these API responses without checking the response code, this method will either construct an Operation, or a dummy NoOp operation representing the 204 Success response.
- Parameters
client (
Client
) – Delegate underlying API calls to this client.response (
requests.Response
) – HTTP Response from the request that started the operation.
- Returns
Operation
- Return type
-
apply_options
(asynchronous=False, **options)[source]¶ Applies operation options to this operation.
NOTE: This function should not be called directly. Rather, options should be passed in through a higher-level function e.g.
refresh()
.
-
property
state
¶ Server-side state of this operation.
Operation state can be unresolved (i.e.
state
is one of:'PENDING'
,'RUNNING'
), or resolved (i.e. state is one of:'CANCELED'
,'SUCCEEDED'
,'FAILED'
). Unless opting into asynchronous mode, all exposed operations should be resolved.Note: you only need to manually pick up server-side changes when opting into asynchronous mode when kicking off this operation.
- Usage:
>>> op.state # operation is currently 'PENDING' 'PENDING' >>> op.wait() # continually polls until operation resolves >>> op.state # incorrect usage; operation object state never changes. 'PENDING' >>> op = op.poll() # correct usage; use value returned by Operation.poll or Operation.wait >>> op.state 'SUCCEEDED'
-
poll
()[source]¶ Poll this operation for server-side updates.
Does not update the calling
Operation
object. Instead, returns a newOperation
.- Returns
Updated representation of this operation.
- Return type
-
wait
(poll_interval_seconds=3, timeout_seconds=None)[source]¶ Continuously polls for this operation’s server-side state.
- Parameters
- Raises
TimeoutError – If operation takes longer than timeout_seconds to resolve.
- Returns
Resolved operation.
- Return type
-
succeeded
()[source]¶ Convenience method for checking if operation was successful.
- Returns
True
if operation’s state is'SUCCEEDED'
,False
otherwise.- Return type
-
delete
()¶ Deletes this resource. Some resources do not support deletion, and will raise a 405 error if this is called.
- Returns
HTTP response from the server
- Return type
-
classmethod