Skip to content
Pasqal Documentation

Workload

Workload(**data)

Bases: BaseModel

Class for workload data.

ATTRIBUTE DESCRIPTION
id

Unique identifier for the workload.

TYPE: str

project_id

ID of the project which the users scheduling the workload belong to.

TYPE: str

status

Status of the workload. Possible values are: PENDING, RUNNING, DONE, CANCELED, TIMED_OUT, ERROR, PAUSED.

TYPE: str

_client

A Client instance to connect to PCS.

TYPE: Client

backend

The backend used for the workload.

TYPE: str

workload_type

The type of the workload.

TYPE: str

config

The config containing all the necessary information for the workload to run.

TYPE: Dict[str, Any]

created_at

Timestamp of the creation of the workload.

TYPE: str

updated_at

Timestamp of the last update of the workload.

TYPE: str

errors

Error messages that occurred while processing workload.

TYPE: Optional[List[str]]

start_timestamp

The timestamp of when the workload began processing.

TYPE: Optional[str]

end_timestamp

The timestamp of when the workload finished processing.

TYPE: Optional[str]

result

Result of the workload.

TYPE: Optional[Dict[str, Any]]

Source code in pasqal_cloud/workload.py
def __init__(self, **data: Any) -> None:
    # Workaround to make the private attribute '_client' working
    # like we need with Pydantic V2, more information on
    # https://docs.pydantic.dev/latest/concepts/models/#private-model-attributes
    super().__init__(**data)
    self._client = data["_client"]

cancel()

Cancel the current job on the PCS.

Source code in pasqal_cloud/workload.py
def cancel(self) -> Dict[str, Any]:
    """Cancel the current job on the PCS."""
    try:
        workload_rsp = self._client.cancel_workload(self.id)
    except HTTPError as e:
        raise WorkloadCancellingError(e) from e
    self.status = workload_rsp.get("status", "CANCELED")
    return workload_rsp