c12_callisto_clients.api package¶
Submodules¶
c12_callisto_clients.api.client module¶
- class c12_callisto_clients.api.client.Request(auth_token: str, verbose: bool = False)¶
Bases:
object
Facade for the API requests to the C12 simulator backend.
- property auth_token¶
Getter for the authentication token.
- Returns:
user authentication token
- do_request(url: str, method: str, params: dict | None = None, header: dict | None = None) object ¶
Generic function for performing the API request.
- Parameters:
url – string - the endpoint url of the API
method – http method (“get”, “put”, “post”, “patch”, “delete”)
params – query parameters of the request (dictionary)
header – additional header options
- Returns:
object (json)
- Raises:
ValueError – if some parameters are in the work fmt
HTTPError – if some Error occurred during the execution of the api request
PermissionError – if the user do not have enough permission for the execution of the API
- get_backends() list ¶
Call to the API to get all available backends.
- Returns:
list of available backends, empty if none available
- Raises:
ApiError – if unexpected API error happened
- get_job(job_uuid: str) dict ¶
Get a specific job with a given uuid.
- Parameters:
job_uuid – job_id
- Returns:
dict of job data
- get_job_result(job_uuid: str, output_data: str | None = None, timeout: float | None = None, wait: float = 5) object ¶
Wait for the job state is finished or an error during the job execution occurred.
- Parameters:
job_uuid – job id
output_data – string to override which results to get, values should be ‘counts, statevector,density_matrix,states’ If no value is specified the one from the DB will be used.
timeout – seconds to wait for a job (if None wait forever)
wait – seconds between queries
- Returns:
json with job information (dict)
- Raises:
ApiError – if error in API communication occurred
TimeoutError – if timeout is exceeded
- get_job_status(job_uuid: str) str ¶
Get the status of a running job.
- Parameters:
job_uuid – job uuid
- Returns:
status of a job
- get_maxjobs() int ¶
Call to the API to get the maximum number of jobs per user.
- Returns:
number of jobs (int)
- Raises:
ApiError – if unexpected API error happened
- get_params() dict ¶
Call to the API to get the physical parameters of the C12 system.
- Returns:
list of parameters
- Raises:
ApiError – if unexpected API error has happened
- get_user_jobs(limit: int, offset: int) list ¶
Get a list of a running job for a specific user, with a support for paging.
- Parameters:
limit – number of records
offset – offset
- Returns:
list of running jobs
- start_job(qasm_str: str, shots: int, result: str, backend_name: str, ini_noise: bool = False, ini: str | list[complexfloating] | None = None, physical_params: str | None = None) tuple ¶
Call the API to start the job.
- Parameters:
qasm_str – QASM string with transpiled quantum circuit
shots – Number of shots for the simulation
result – what is desired output (statevector, counts, density_matrix)
backend_name – the name of the backend to run on
ini_noise – specify if we want to apply a noise to the initialisation of the circuit
ini – initial state of the circuit as a string (label) or array of complex numbers
physical_params – stringify json with physical parameters
- Returns:
tuple str (job uuid) and transpiled qasm str
- Raises:
ApiError – if unexpected API error happened
c12_callisto_clients.api.configs module¶
Basic URLs to the C12 sim APIs.
c12_callisto_clients.api.exceptions module¶
- exception c12_callisto_clients.api.exceptions.ApiError¶
Bases:
Exception
Class that represent C12 simulator error with ID’s depending on the error.