Session Class

Azure Quantum Job Session: a logical grouping of jobs.

Inheritance
azure.quantum.job.workspace_item.WorkspaceItem
Session

Constructor

Session(workspace: Workspace, details: SessionDetails | None = None, target: str | Target | None = None, provider_id: str | None = None, id: str | None = None, name: str | None = None, job_failure_policy: str | SessionJobFailurePolicy | None = None, **kwargs)

Parameters

Name Description
workspace
Required

Workspace instance to open the session on

details

Session details model, containing the session id, name, job_failure_policy, provider_id and target. Either this parameter should be passed containing all the session detail values, or the same values should be passed as individual parameters.

default value: None
target

The name of the target (or Target object) to open the session on.

default value: None
provider_id

The id of the provider to open the session on. If not passed, it will be extracted from the target name.

default value: None
id

The id of the session. If not passed, one random uuid will used.

default value: None
name

The name of the session. If not passed, the name will be session-{session-id}.

default value: None
job_failure_policy

The policy that determines when a session would fail, close and not accept further jobs.

default value: None

Methods

close

Closes a session, not allowing further jobs to be submitted under the session.

is_in_terminal_state

Returns True if the session is in one of the possible terminal states(Succeeded, Failed and Timed_Out).

list_jobs

Lists all jobs associated with this session.

open

Opens a session, effectively creating a new session in the Azure Quantum service, and allowing it to accept jobs under it.

refresh

Fetches the latest session details from the Azure Quantum service.

close

Closes a session, not allowing further jobs to be submitted under the session.

close() -> Session

Returns

Type Description

The session object with updated details after its closing.

is_in_terminal_state

Returns True if the session is in one of the possible terminal states(Succeeded, Failed and Timed_Out).

is_in_terminal_state() -> bool

Returns

Type Description

True if the session is in one of the terminal states.

list_jobs

Lists all jobs associated with this session.

list_jobs() -> List[Job]

Returns

Type Description

A list of all jobs associated with this session.

open

Opens a session, effectively creating a new session in the Azure Quantum service, and allowing it to accept jobs under it.

open() -> Session

Returns

Type Description

The session object with updated details after its opening.

refresh

Fetches the latest session details from the Azure Quantum service.

refresh() -> Session

Returns

Type Description

The session object with updated details.

Attributes

details

Get the session details.

Returns

Type Description

The details about the session.

target

Get the target associated with the session.

Returns

Type Description

The target associated with the session.