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

Operation

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() .

Synchronous mode:

Automatically waits for operation to resolve before returning the operation.

asynchronous mode:

Immediately return the 'PENDING' operation. It is up to the user to coordinate this operation with their code via wait() and/or poll() .

Parameters
  • asynchronous (bool) – Whether or not to run in asynchronous mode. Default: False.

  • **options – When running in synchronous mode, these options are passed to the underlying wait() call.

Returns

Operation with options applied.

Return type

Operation

property type
Type

str

property description
Type

str

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 new Operation.

Returns

Updated representation of this operation.

Return type

Operation

wait(poll_interval_seconds=3, timeout_seconds=None)[source]

Continuously polls for this operation’s server-side state.

Parameters
  • poll_interval_seconds (int) – Time interval (in seconds) between subsequent polls.

  • timeout_seconds (int) – Time (in seconds) to wait for operation to resolve.

Raises

TimeoutError – If operation takes longer than timeout_seconds to resolve.

Returns

Resolved operation.

Return type

Operation

succeeded()[source]

Convenience method for checking if operation was successful.

Returns

True if operation’s state is 'SUCCEEDED', False otherwise.

Return type

bool

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

requests.Response

property relative_id
Type

str

property resource_id
Type

str