IQMServerClient#
Module: iqm.iqm_server_client.iqm_server_client
- class iqm.iqm_server_client.iqm_server_client.IQMServerClient(iqm_server_url: str | None = None, *, quantum_computer: str | None = None, token: str | None = None, tokens_file: str | None = None, client_signature: str | None = None, enable_opentelemetry: bool = False, timeout: float = 120.0)#
Bases:
SerializableShared functionality for clients communicating with the same IQM server.
- Parameters:
iqm_server_url (str | None) – Remote IQM Server URL to connect to.
quantum_computer (str | None) – ID or alias of the quantum computer to connect to, if the IQM Server instance controls more than one.
token (str | None) – Long-lived IQM token in plain text format.
tokens_file (str | None) – Path to a tokens file used for authentication.
client_signature (str | None) – String that is added to the User-Agent header of requests sent to the server.
enable_opentelemetry (bool) – Iff True, enable Jaeger/OpenTelemetry tracing.
timeout (float) – Timeout for the request in seconds.
Attributes
API version of the IQM Server API this client is using.
Resolved URL path prefix for station-proxied requests to this quantum computer.
Human-readable alias of the quantum computer this client connects to.
Methods
Sanitize query parameters, defaulting 'invalid' to False if supported by the model.
Reconstruct an instance from a dictionary payload.
Parse HTTP response text directly into Pydantic models.
Get information about IQM Server.
Get the status of the IQM Server.
Return the keyword arguments for a
requestsHTTP method.Send an HTTP request.
Serialize the object instance into a dictionary payload.
Serialize a Pydantic model into a JSON string.
Serialize query parameters, skipping None values and empty dictionaries.
- classmethod deserialize(data: dict[str, Any]) IQMServerClient#
Reconstruct an instance from a dictionary payload.
- Parameters:
- Return type:
- property quantum_computer: str#
Human-readable alias of the quantum computer this client connects to.
- property proxy_path: str#
Resolved URL path prefix for station-proxied requests to this quantum computer.
- Raises:
ClientConfigurationError – Station-proxied requests are not available for this quantum computer, e.g. due to missing permissions, or the station proxy feature not being enabled on the server.
- static serialize_model(model: BaseModel) str#
Serialize a Pydantic model into a JSON string.
All Pydantic models should be serialized using this method, to keep the client behavior uniform.
- Parameters:
model (BaseModel) – Pydantic model to JSON-serialize.
- Returns:
Corresponding JSON string, may contain arbitrary Unicode characters.
- Return type:
- send_request(http_method: Callable[[...], Response], url_path: str, *, headers: dict[str, str] | None = None, params: dict[str, Any] | None = None, json_data: str | None = None, protobuf_data: bytes | None = None) Response#
Send an HTTP request.
Parameters
json_strandoctetsare mutually exclusive. The first non-None argument (in this order) will be used to construct the body of the request.- Parameters:
http_method (Callable[[...], Response]) – HTTP method to use for the request, any of requests.[post|get|put|head|delete|patch|options].
url_path (str) – URL for the request.
headers (dict[str, str] | None) – Additional HTTP headers for the request. Some may be overridden.
params (dict[str, Any] | None) – HTTP query parameters to store in the query string of the request URL.
json_data (str | None) – JSON string to store in the body, may contain arbitrary Unicode characters.
protobuf_data (bytes | None) – Pre-serialized protobuf binary data to store in the body.
- Returns:
Response to the request.
- Raises:
IQMError – Request was not successful.
- Return type:
Response
- static clean_query_parameters(model: Any, **kwargs) dict[str, Any]#
Sanitize query parameters, defaulting ‘invalid’ to False if supported by the model.
- prepare_request_kwargs(*, is_mutating: bool, headers: dict[str, str], params: dict[str, Any], json_data: str | None = None, protobuf_data: bytes | None = None, timeout: float) dict[str, Any]#
Return the keyword arguments for a
requestsHTTP method.
Inheritance
