provenaclient.utils.async_job_helpers

Created Date: Monday June 17th 2024 +1000 Author: Peter Baker —– Last Modified: Monday June 17th 2024 4:45:39 pm +1000 Modified By: Peter Baker —– Description: Set of helpers for running polling tasks against the job API until completion etc. —– HISTORY: Date By Comments ———- — ———————————————————

Attributes

JOB_FINISHED_STATES

Payload

PollCallbackData

PollCallbackResponse

PollCallbackFunction

Exceptions

PollTimeoutException

Raised when poll operation exceeds timeout

PollFunctionErrorException

Raised when poll operation callback errors

Functions

timestamp(→ int)

poll_callback(→ PollCallbackData)

The poll callback function which repeatedly polls given func according to spec

wait_for_in_progress(...)

Waits for the entry to be in in progress status

wait_for_entry_in_queue(...)

Waits for the entry to appear in the queue

wait_for_completion(...)

Waits for completion.

wait_for_full_lifecycle(...)

Waits for the entire lifecycle of a job, adhering to settings. Uses L2 client.

wait_for_full_successful_lifecycle(...)

Waits for the full lifecycle of an async job and asserts that it is successful at the end.

Module Contents

provenaclient.utils.async_job_helpers.JOB_FINISHED_STATES
provenaclient.utils.async_job_helpers.Payload
provenaclient.utils.async_job_helpers.timestamp() int[source]
provenaclient.utils.async_job_helpers.PollCallbackData
provenaclient.utils.async_job_helpers.PollCallbackResponse
provenaclient.utils.async_job_helpers.PollCallbackFunction
exception provenaclient.utils.async_job_helpers.PollTimeoutException[source]

Bases: Exception

Raised when poll operation exceeds timeout

exception provenaclient.utils.async_job_helpers.PollFunctionErrorException[source]

Bases: Exception

Raised when poll operation callback errors

async provenaclient.utils.async_job_helpers.poll_callback(poll_interval_seconds: int, timeout_seconds: int, callback: PollCallbackFunction) PollCallbackData[source]

The poll callback function which repeatedly polls given func according to spec

Parameters:
  • poll_interval_seconds (int) – The polling interval

  • timeout_seconds (int) – The timeout to adhere to

  • callback (PollCallbackFunction) – The call back function itself

Raises:
Returns:

The resulting data (job status table probably)

Return type:

PollCallbackData

async provenaclient.utils.async_job_helpers.wait_for_in_progress(session_id: str, client: provenaclient.clients.JobAPIClient, settings: provenaclient.models.AsyncAwaitSettings) ProvenaInterfaces.AsyncJobAPI.JobStatusTable[source]

Waits for the entry to be in in progress status

Parameters:
Returns:

The resulting entry

Return type:

JobStatusTable

async provenaclient.utils.async_job_helpers.wait_for_entry_in_queue(session_id: str, client: provenaclient.clients.JobAPIClient, settings: provenaclient.models.AsyncAwaitSettings) ProvenaInterfaces.AsyncJobAPI.JobStatusTable[source]

Waits for the entry to appear in the queue

Parameters:
Raises:

Exception – If non 400 error

Returns:

The resulting entry

Return type:

JobStatusTable

async provenaclient.utils.async_job_helpers.wait_for_completion(session_id: str, client: provenaclient.clients.JobAPIClient, settings: provenaclient.models.AsyncAwaitSettings) ProvenaInterfaces.AsyncJobAPI.JobStatusTable[source]

Waits for completion.

Parameters:
Returns:

The resulting entry

Return type:

JobStatusTable

async provenaclient.utils.async_job_helpers.wait_for_full_lifecycle(session_id: str, client: provenaclient.clients.JobAPIClient, settings: provenaclient.models.AsyncAwaitSettings) ProvenaInterfaces.AsyncJobAPI.JobStatusTable[source]

Waits for the entire lifecycle of a job, adhering to settings. Uses L2 client.

Parameters:
  • session_id (str) – The session ID to await

  • client (JobAPIClient) – The client to utilise

  • settings (AsyncAwaitSettings) – The settings including timeouts

Returns:

The resulting entry

Return type:

JobStatusTable

async provenaclient.utils.async_job_helpers.wait_for_full_successful_lifecycle(session_id: str, client: provenaclient.clients.JobAPIClient, settings: provenaclient.models.AsyncAwaitSettings) ProvenaInterfaces.AsyncJobAPI.JobStatusTable[source]

Waits for the full lifecycle of an async job and asserts that it is successful at the end.

Parameters:
Returns:

The resulting successful job

Return type:

JobStatusTable