QrSession module

class QrSession

A template class to run a sequence or a batch of jobs on the Quantum Rings backend.

QrSession.session_id

Returns the session ID.

Returns:

Returns the session ID

QrSession.service

Returns the service associated with this session.

Returns:

An object of the class QrRuntimeService

QrSession(backend: QrBackendV2, max_time: int | str | None = None, create_new: bool | None = True)

Session constructor.

Args:

backend: Instance of QrBackendV2 class.

max_time: Maximum allowed time for the session before it is closed. It can be specified

in seconds or as a string like “2h 30m 10s”.

create_new: If True, A new session is created

Raises:

Exception: If an input value is invalid.

backend() QrBackendV2

Return backend for this session.

Returns:

Backend for this session. None if unknown.

cancel() None

Cancels the associted session

close() None

Closes the current session. No new jobs will be accepted. However, existing jobs in the queue will be completed, if there is still time to complete them.

status() str

Returns the current session status.

Returns:

A string describing the current status of the session.

details() Dict[str, Any] | None

Return session details.

from_id(session_id: str, service: QrRuntimeService) QrSession

Construct a Session object with a given session_id

Args:

session_id: the id of the session to be created. T service: instance of the QrRuntimeService class.

Raises:

Exception, should an error occur

Returns:

A new Session with the given session_id

usage() float | None

Returns the time elapsed since the start of the session in seconds.