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:
| Name | Type | Description | Default |
|---|---|---|---|
connector
|
APIConnector
|
The API connector to use. |
required |
org_id
|
UUID
|
The organization ID. |
required |
topic
|
str
|
The topic of the task. |
required |
task
|
str
|
The task to be executed. |
required |
job_id
|
UUID
|
The job ID. |
required |
result_type
|
type[T_Result]
|
The type to validate the result against. |
dict
|
preview
|
bool
|
Whether 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:
| Name | Type | Description | Default |
|---|---|---|---|
connector
|
APIConnector
|
The API connector to use. |
required |
url
|
str
|
The status URL of a submitted job. |
required |
result_type
|
type[T_Result]
|
The type to validate the result against. |
dict
|
preview
|
bool
|
Whether to use preview mode and include necessary header information. |
False
|
Returns:
| Type | Description |
|---|---|
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:
| Name | Type | Description | Default |
|---|---|---|---|
connector
|
APIConnector
|
The API connector to use. |
required |
topic
|
str
|
The topic of the task. |
required |
task
|
str
|
The task to be executed. |
required |
parameters
|
Mapping[str, Any]
|
The parameters for the task. |
required |
result_type
|
type[T_Result]
|
The type to validate the result against. |
dict
|
preview
|
bool
|
Whether to use preview mode and include necessary header information. |
False
|
Returns:
| Type | Description |
|---|---|
JobClient[T_Result]
|
The job that was created. |
Raises:
| Type | Description |
|---|---|
UnknownResponseError
|
If the Location header is missing or invalid. |
get_status
async
get_status() -> JobProgress
Get the status of the job.
Returns:
| Type | Description |
|---|---|
JobProgress
|
The job progress. |
get_results
async
get_results() -> T_Result
Get the results of the job.
Returns:
| Type | Description |
|---|---|
T_Result
|
The results. |
Raises:
| Type | Description |
|---|---|
UnknownResponseError
|
If the response or results fail validation. |
JobPendingError
|
If the job is still pending. |
JobError
|
If 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:
| Name | Type | Description | Default |
|---|---|---|---|
polling_interval_seconds
|
float
|
The interval in seconds between status checks. |
0.5
|
retry
|
Retry | None
|
A Retry object with a wait strategy. If None, a default Retry is created. |
None
|
fb
|
IFeedback
|
The feedback object to use. |
NoFeedback
|
Returns:
| Type | Description |
|---|---|
T_Result
|
The results. |
Raises:
| Type | Description |
|---|---|
UnknownResponseError
|
If the response or results fail validation. |
JobPendingError
|
If the job is still pending. |
JobError
|
If the job failed. |