Skip to main content

evo-compute

GitHub source

JobClient

evo.compute.client.JobClient

Client for managing a submitted compute task (a job).

id property

id: UUID

The job id.

topic property

topic: str

The topic of the task.

task property

task: str

The task.

url property

url: str

The status URL of the job.

__init__

__init__(
connector: APIConnector,
org_id: UUID,
topic: str,
task: str,
job_id: UUID,
result_type: type[T_Result] = dict,
preview: bool = False,
) -> None

Parameters:

NameTypeDescriptionDefault
connectorAPIConnectorThe API connector to use.required
org_idUUIDThe organization ID.required
topicstrThe topic of the task.required
taskstrThe task to be executed.required
job_idUUIDThe job ID.required
result_typetype[T_Result]The type to validate the result against.dict
previewboolWhether to use preview mode and include necessary header information.False

from_url staticmethod

from_url(
connector: APIConnector, url: str, result_type: type[T_Result] = dict, preview: bool = False
) -> JobClient[T_Result]

Create a job client from a status URL.

The URL hostname must match the connector base URL.

Parameters:

NameTypeDescriptionDefault
connectorAPIConnectorThe API connector to use.required
urlstrThe status URL of a submitted job.required
result_typetype[T_Result]The type to validate the result against.dict
previewboolWhether to use preview mode and include necessary header information.False

Returns:

TypeDescription
JobClient[T_Result]A client for managing the referenced job.

submit async staticmethod

submit(
connector: APIConnector,
org_id: UUID,
topic: str,
task: str,
parameters: Mapping[str, Any],
result_type: type[T_Result] = dict,
preview: bool = False,
) -> JobClient[T_Result]

Trigger an asynchronous task within a specific topic with the given parameters.

Parameters:

NameTypeDescriptionDefault
connectorAPIConnectorThe API connector to use.required
topicstrThe topic of the task.required
taskstrThe task to be executed.required
parametersMapping[str, Any]The parameters for the task.required
result_typetype[T_Result]The type to validate the result against.dict
previewboolWhether to use preview mode and include necessary header information.False

Returns:

TypeDescription
JobClient[T_Result]The job that was created.

Raises:

TypeDescription
UnknownResponseErrorIf the Location header is missing or invalid.

get_status async

get_status() -> JobProgress

Get the status of the job.

Returns:

TypeDescription
JobProgressThe job progress.

get_results async

get_results() -> T_Result

Get the results of the job.

Returns:

TypeDescription
T_ResultThe results.

Raises:

TypeDescription
UnknownResponseErrorIf the response or results fail validation.
JobPendingErrorIf the job is still pending.
JobErrorIf the job failed.

cancel async

cancel() -> None

Cancel the job.

wait_for_results async

wait_for_results(
polling_interval_seconds: float = 0.5, retry: Retry | None = None, fb: IFeedback = NoFeedback
) -> T_Result

Wait for the job to complete and return the results.

Parameters:

NameTypeDescriptionDefault
polling_interval_secondsfloatThe interval in seconds between status checks.0.5
retryRetry | NoneA Retry object with a wait strategy. If None, a default Retry is created.None
fbIFeedbackThe feedback object to use.NoFeedback

Returns:

TypeDescription
T_ResultThe results.

Raises:

TypeDescription
UnknownResponseErrorIf the response or results fail validation.
JobPendingErrorIf the job is still pending.
JobErrorIf the job failed.

What is the reason for your feedback?