API client

class qiskit_aqt_provider.api_client.portal_client.PortalClient[source]

Bases: object

Client for the AQT portal API.

__init__(*, token: str, user_agent_extra: str | None = None, timeout: float | None = 10.0) None[source]

Initialize a new client for the AQT remote computing portal API.

By default, the client connects to the portal at DEFAULT_PORTAL_URL. This can be overridden using the AQT_PORTAL_URL environment variable.

Parameters:
  • token – authentication token.

  • user_agent_extra – data appended to the default user-agent string.

  • timeout – HTTP timeout, in seconds.

workspaces() Workspaces[source]

List the workspaces visible to the used token.

Raises:
  • httpx.NetworkError – connection to the remote portal failed.

  • httpx.HTTPStatusError – something went wrong with the request to the remote portal.

qiskit_aqt_provider.api_client.portal_client.DEFAULT_PORTAL_URL: Final = URL('https://arnica.aqt.eu')

Default URL for the remote portal.

class qiskit_aqt_provider.api_client.models.Workspaces[source]

Bases: RootModel, Collection[Workspace]

List of available workspaces and devices.

Examples

Assume a Workspaces instance retrieved from the API with the following contents:

| Workspace ID | Resource ID | Resource Type |
|--------------+-------------+---------------|
| workspace0   | resource0   | device        |
| workspace1   | resource0   | device        |
| workspace1   | resource1   | simulator     |

Gather basic information:

>>> # workspaces = PortalClient(...).workspaces()
>>> len(workspaces)
2
>>> [ws.workspace_id for ws in workspaces]
['workspace0', 'workspace1']

Inclusion tests rely only on the identifier:

>>> Workspace(workspace_id="workspace0", resources=[]) in workspaces
True

The Workspaces.filter() method allows for complex filtering. For example by workspace identifier ending in 0:

>>> [ws.workspace_id for ws in workspaces.filter(workspace_pattern=re.compile(".+0$"))]
['workspace0']

or only the non-simulated devices:

>>> workspaces_devices = workspaces.filter(backend_type="device")
>>> [(ws.workspace_id, resource.resource_id)
...  for ws in workspaces_devices for resource in ws.resources]
[('workspace0', 'resource0'), ('workspace1', 'resource0')]
filter(*, workspace_pattern: str | Pattern[str] | None = None, name_pattern: str | Pattern[str] | None = None, backend_type: Literal['device', 'simulator', 'offline_simulator'] | None = None) Self[source]

Filtered copy of the list of available workspaces and devices.

Omitted criteria match any entry in the respective field.

Parameters:
  • workspace_pattern – pattern for the workspace ID to match

  • name_pattern – pattern for the resource ID to match

  • backend_type – backend type to select.

Returns:

Workspaces instance that only contains matching resources.

class qiskit_aqt_provider.api_client.models.Workspace[source]

Bases: BaseModel

Description of a workspace and the resources it contains.

This is the element type in the Workspaces container.

field resources: list[Resource] [Required]

Resources in the workspace.

field workspace_id: str [Required]

Workspace identifier.

class qiskit_aqt_provider.api_client.models.Resource[source]

Bases: BaseModel

Description of a resource.

This is the element type in Workspace.resources.

field resource_id: str [Required]

Resource identifier.

field resource_name: str [Required]

Resource name.

field resource_type: Literal['device', 'simulator', 'offline_simulator'] [Required]

Type of resource.

field workspace_id: str [Required]

Identifier of the workspace this resource belongs to.