Job#

Client for managing asynchronous jobs and status tracking.

Job client for managing asynchronous jobs.

This module provides the JobClient for submitting, monitoring, and managing background jobs in the Ionworks platform.

class ionworks.job.JobCreationPayload(*, job_type, params, priority=5, callback_url=None)[source]#

Bases: BaseModel

Payload for creating a job.

Parameters:
job_type: str#
params: dict[str, Any]#
priority: int#
callback_url: str | None#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ionworks.job.JobResponse(*, job_id, status, job_type, params, priority, created_at, updated_at, metadata, error, result)[source]#

Bases: BaseModel

Response model for job details.

Parameters:
job_id: str#
status: str#
job_type: str#
params: dict[str, Any]#
priority: int#
created_at: str#
updated_at: str#
metadata: dict[str, Any] | None#
error: str | None#
result: dict[str, Any] | None#
model_config = {}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

class ionworks.job.JobClient(client)[source]#

Bases: object

Client for managing asynchronous jobs.

This class provides methods to create, retrieve, list, and cancel jobs in the Ionworks platform.

Parameters:

client (Any)

__init__(client)[source]#

Initialize the JobClient.

Parameters:

client (Any) – The HTTP client instance used for API requests.

Return type:

None

create(payload)[source]#

Submit a job using the provided payload.

Parameters:

payload (JobCreationPayload) – The configuration for the job to be created.

Returns:

Response containing the job_id and initial status.

Return type:

JobResponse

Raises:
  • requests.exceptions.RequestException – If the API request fails.

  • ValueError – If the response parsing fails.

get(job_id)[source]#

Get the status and details of a specific job.

Parameters:

job_id (str) – The ID of the job to retrieve.

Returns:

Job details and current status.

Return type:

JobResponse

Raises:

ValueError – If the response parsing fails.

list()[source]#

List all jobs.

Returns:

List of all jobs with their details.

Return type:

list[JobResponse]

Raises:

ValueError – If the response is not a list or job data format is invalid.

cancel(job_id)[source]#

Cancel a job.

Parameters:

job_id (str) – The ID of the job to cancel.

Returns:

Updated job details with canceled status.

Return type:

JobResponse

Raises:

ValueError – If the response parsing fails.