Skip to content

orca_sdk.job#

Status #

Bases: Enum

Status of a cloud job in the task queue

DISPATCHED class-attribute instance-attribute #

DISPATCHED = 'DISPATCHED'

The job has been queued and is waiting to be processed

PROCESSING class-attribute instance-attribute #

PROCESSING = 'PROCESSING'

The job is being processed

COMPLETED class-attribute instance-attribute #

COMPLETED = 'COMPLETED'

The job has been completed successfully

FAILED class-attribute instance-attribute #

FAILED = 'FAILED'

The job has failed

ABORTING class-attribute instance-attribute #

ABORTING = 'ABORTING'

The job is being aborted

ABORTED class-attribute instance-attribute #

ABORTED = 'ABORTED'

The job has been aborted

Job #

Bases: Generic[TResult]

Handle to a job that is run in the OrcaCloud

Attributes:

  • id (str) –

    Unique identifier for the job

  • type (str) –

    Type of the job

  • status (Status) –

    Current status of the job

  • steps_total (int | None) –

    Total number of steps in the job, present if the job started processing

  • steps_completed (int | None) –

    Number of steps completed in the job, present if the job started processing

  • completion (float) –

    Percentage of the job that has been completed, present if the job started processing

  • exception (str | None) –

    Exception that occurred during the job, present if the status is FAILED

  • value (TResult | None) –

    Value of the result of the job, present if the status is COMPLETED

  • created_at (datetime) –

    When the job was queued for processing

  • updated_at (datetime) –

    When the job was last updated

  • refreshed_at (datetime) –

    When the job status was last refreshed

Note

Accessing status and related attributes will refresh the job status in the background.

completion property #

completion

Percentage of the job that has been completed, present if the job started processing

set_config classmethod #

set_config(
    *,
    refresh_interval=None,
    show_progress=None,
    max_wait=None
)

Set global configuration for running jobs

Parameters:

  • refresh_interval (int | None, default: None ) –

    Time to wait between polling the job status in seconds, default is 3

  • show_progress (bool | None, default: None ) –

    Whether to show a progress bar when calling the wait method, default is True

  • max_wait (int | None, default: None ) –

    Maximum time to wait for the job to complete in seconds, default is 1 hour

query classmethod #

query(
    status=None,
    type=None,
    limit=None,
    offset=0,
    start=None,
    end=None,
)

Query the job queue for jobs matching the given filters

Parameters:

  • status (Status | list[Status] | None, default: None ) –

    Optional status or list of statuses to filter by

  • type (str | list[str] | None, default: None ) –

    Optional type or list of types to filter by

  • limit (int | None, default: None ) –

    Maximum number of jobs to return

  • offset (int, default: 0 ) –

    Offset into the list of jobs to return

  • start (datetime | None, default: None ) –

    Optional minimum creation time of the jobs to query for

  • end (datetime | None, default: None ) –

    Optional maximum creation time of the jobs to query for

Returns:

  • list[Job]

    List of jobs matching the given filters

__init__ #

__init__(id, get_value=None)

Create a handle to a job in the job queue

Parameters:

  • id (str) –

    Unique identifier for the job

  • get_value (Callable[[], TResult | None] | None, default: None ) –

    Optional function to customize how the value is resolved, if not provided the result will be a dict

refresh #

refresh(throttle=0)

Refresh the status and progress of the job

Parameters:

  • throttle (float, default: 0 ) –

    Minimum time in seconds between refreshes

wait #

wait(
    show_progress=None, refresh_interval=None, max_wait=None
)

Block until the job is complete

Parameters:

  • show_progress (bool | None, default: None ) –

    Show a progress bar while waiting for the job to complete

  • refresh_interval (int | None, default: None ) –

    Polling interval in seconds while waiting for the job to complete

  • max_wait (int | None, default: None ) –

    Maximum time to wait for the job to complete in seconds

Note

The defaults for the config parameters can be set globally using the set_config method.

This method will not return the result or raise an exception if the job fails. Call result instead if you want to get the result.

Raises:

result #

result(
    show_progress=None, refresh_interval=None, max_wait=None
)

Block until the job is complete and return the result value

Parameters:

  • show_progress (bool | None, default: None ) –

    Show a progress bar while waiting for the job to complete

  • refresh_interval (int | None, default: None ) –

    Polling interval in seconds while waiting for the job to complete

  • max_wait (int | None, default: None ) –

    Maximum time to wait for the job to complete in seconds

Note

The defaults for the config parameters can be set globally using the set_config method.

This method will raise an exception if the job fails. Use wait if you just want to wait for the job to complete without raising errors on failure.

Returns:

  • TResult

    The result value of the job

Raises:

abort #

abort(show_progress=False, refresh_interval=1, max_wait=20)

Abort the job

Parameters:

  • show_progress (bool, default: False ) –

    Optionally show a progress bar while waiting for the job to abort

  • refresh_interval (int, default: 1 ) –

    Polling interval in seconds while waiting for the job to abort

  • max_wait (int, default: 20 ) –

    Maximum time to wait for the job to abort in seconds