numerous.sdk.connect.job_state module#

Contains the implementation of the JobState class, for managing job execution state.

class numerous.sdk.connect.job_state.JobState(spm_client, identity, execution_id)#

Bases: object

JobState enables jobs to store state remotely, and cache it locally. This is useful for keeping track of values across hibernations, or if an error has restarted the job.

commit()#

Commit the state to the server. This is useful for batching state updates.

Return type:

None

get(key, default=None)#

Get the state value keyed by key from the JobState.

Parameters:
  • key (str) – The key to look up in the state.

  • default (Optional[Any]) – A default value to return if the key does not exist.

Return type:

Any

Returns:

The state value at the key if it exists, otherwise the default, or None if no default is specified.

set(key, value, commit=True)#

Set the state value keyed by key to the value value in the JobState, and optionally commit the state to the server.

If commit is True the new state resulting from setting the value, will be comitted to the server.

Parameters:
  • key (str) – The key to set in the state.

  • value (Any) – The value to set.

  • commit (bool) – Whether or not to commit the resulting state to the server.

Return type:

None

unset(key, commit=True)#

Unset the state value keyed by key in the JobState, and optionally commit the state to the server.

If commit is True the new state resulting from unsetting the value, will be comitted to the server.

Parameters:
  • key (str) – The key to unset in the state.

  • commit (bool) – Whether or not to commit the resulting state to the server.

Return type:

None