SDK
SDK(username=None, password=None, token_provider=None, endpoints=None, auth0=None, webhook=None, project_id=None)
This class provides helper methods to call the Pasqal Cloud endpoints.
To authenticate to Pasqal Cloud, you have to provide either an email/password combination or a TokenProvider instance. You may omit the password, you will then be prompted to enter one.
PARAMETER | DESCRIPTION |
---|---|
username
|
Email of the user to login as.
TYPE:
|
password
|
Password of the user to login as.
TYPE:
|
token_provider
|
The token provider is an alternative log-in method not for human users.
TYPE:
|
webhook
|
Webhook where the job results are automatically sent to.
TYPE:
|
endpoints
|
Endpoints targeted of the public apis.
TYPE:
|
auth0
|
Auth0Config object to define the auth0 tenant to target.
TYPE:
|
project_id
|
ID of the owner project of the batch.
TYPE:
|
Source code in pasqal_cloud/__init__.py
add_jobs(batch_id, jobs)
Add jobs to an already existing batch.
PARAMETER | DESCRIPTION |
---|---|
batch_id
|
A unique identifier for the batch data.
TYPE:
|
jobs
|
a collection of CreateJob payloads
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Batch
|
An instance of a Batch model from the PCS database |
RAISES | DESCRIPTION |
---|---|
JobCreationError
|
spawns from a HTTPError. |
Source code in pasqal_cloud/__init__.py
cancel_batch(id)
Cancel the given batch on the PCS
PARAMETER | DESCRIPTION |
---|---|
id
|
ID of the batch.
TYPE:
|
Source code in pasqal_cloud/__init__.py
cancel_batches(batch_ids)
Cancel a group of batches by their ids.
PARAMETER | DESCRIPTION |
---|---|
batch_ids
|
batch ids to cancel.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
BatchCancellationResponse
|
TYPE:
|
BatchCancellationResponse
|
a class containing the batches that have been cancelled and the id of |
BatchCancellationResponse
|
the batches that could not be cancelled with the reason explained |
RAISES | DESCRIPTION |
---|---|
BatchCancellingError
|
spawns from a HTTPError |
Source code in pasqal_cloud/__init__.py
cancel_job(id)
Cancel the given job on the PCS
PARAMETER | DESCRIPTION |
---|---|
id
|
ID of the job.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Job
|
The job stored in the PCS database.
TYPE:
|
Source code in pasqal_cloud/__init__.py
cancel_jobs(batch_id, filters=None)
Cancel a group of jobs matching the filters in a selected batch.
PARAMETER | DESCRIPTION |
---|---|
batch_id
|
id of the batch
TYPE:
|
filters
|
filters to be applied to find the jobs that will be cancelled
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
JobCancellationResponse
|
TYPE:
|
JobCancellationResponse
|
a class containing the jobs that have been cancelled and the id of the jobs |
JobCancellationResponse
|
that could not be cancelled with the reason explained |
RAISES | DESCRIPTION |
---|---|
JobCancellingError
|
spawns from a HTTPError |
Source code in pasqal_cloud/__init__.py
cancel_workload(id)
Cancel the given workload on the PCS.
PARAMETER | DESCRIPTION |
---|---|
id
|
Workload id.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
workload
|
The canceled workload.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
WorkloadCancelingError
|
If cancelation failed. |
Source code in pasqal_cloud/__init__.py
close_batch(batch_id)
Set a batch 'open' field as False, indicating no more Jobs can be submitted.
PARAMETER | DESCRIPTION |
---|---|
batch_id
|
A unique identifier for the batch data.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Batch
|
An instance of a Batch model from the PCS database |
RAISES | DESCRIPTION |
---|---|
BatchClosingError
|
spawns from a HTTPError |
Source code in pasqal_cloud/__init__.py
complete_batch(batch_id)
Deprecated, use close_batch instead.
Source code in pasqal_cloud/__init__.py
create_batch(serialized_sequence, jobs, complete=None, open=None, emulator=None, configuration=None, wait=False, fetch_results=False)
Create a new batch and send it to the API.
PARAMETER | DESCRIPTION |
---|---|
serialized_sequence
|
Serialized pulser sequence.
TYPE:
|
complete
|
Opposite of open, deprecated.
TYPE:
|
jobs
|
List of jobs to be added to the batch at creation.
TYPE:
|
open
|
If all jobs are sent at creation.
If set to True, jobs can be added using the
TYPE:
|
emulator
|
The type of emulator to use, If set to None, the device_type will be set to the one stored in the serialized sequence
TYPE:
|
configuration
|
A dictionary with extra configuration for the emulators that accept it.
TYPE:
|
wait
|
Whether to block on this statement until all the submitted jobs are terminated
TYPE:
|
fetch_results
|
Whether to wait for the batch to be done and fetch results
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Batch
|
The new batch that has been created in the database.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
BatchCreationError
|
If batch creation failed |
BatchFetchingError
|
If batch fetching failed |
Source code in pasqal_cloud/__init__.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
create_workload(workload_type, backend, config, wait=False)
Create a workload to be scheduled for execution.
PARAMETER | DESCRIPTION |
---|---|
workload_type
|
The type of workload to create.
TYPE:
|
backend
|
The backend to run the workload on.
TYPE:
|
config
|
The config that defines the workload.
TYPE:
|
wait
|
Whether to wait for completion to fetch results.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
workload
|
The created workload instance.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
WorkloadCreationError
|
If creation failed. |
Source code in pasqal_cloud/__init__.py
get_batch(id, fetch_results=False)
Retrieve a batch's data and all its jobs.
PARAMETER | DESCRIPTION |
---|---|
fetch_results
|
Whether to wait for the batch to be done and fetch results
TYPE:
|
id
|
ID of the batch.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Batch
|
the batch stored in the PCS database.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
BatchFetchingError
|
in case fetching failed |
Source code in pasqal_cloud/__init__.py
get_batches(filters=None, pagination_params=None)
Retrieve a list of batches matching filters using a pagination system.
Batches are sorted by their creation date in descending order.
If no 'pagination_params' are provided, the first 100 batches matching the query will be returned by default.
PARAMETER | DESCRIPTION |
---|---|
filters
|
Filters to be applied to the batches.
TYPE:
|
pagination_params
|
Pagination to be applied to the query.
TYPE:
|
Examples:
get_batches(filters=BatchFilters(status=BatchStatus.ERROR)) Returns the first 100 batches with an ERROR status.
Get_batches(filters=BatchFilters(status=BatchStatus.ERROR), pagination_params=PaginationParams(offset=100)) Returns batches 101-200 with an ERROR status.
Get_batches(filters=BatchFilters(status=BatchStatus.ERROR), pagination_params=PaginationParams(offset=200)) Returns batches 201-300 with an ERROR status.
RETURNS | DESCRIPTION |
---|---|
PaginatedResponse
|
Includes the results of the API and some pagination information.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
BatchFetchingError
|
If fetching batches call failed. |
TypeError
|
If |
Source code in pasqal_cloud/__init__.py
get_device_specs_dict()
Retrieve the list of available device specifications.
RETURNS | DESCRIPTION |
---|---|
DeviceSpecs
|
The list of available device specifications.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
DeviceSpecsFetchingError
|
If fetching of specs failed. |
Source code in pasqal_cloud/__init__.py
get_job(id, wait=False)
Retrieve a job's data.
PARAMETER | DESCRIPTION |
---|---|
id
|
ID of the job.
TYPE:
|
wait
|
Whether to wait for the job to be done
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Job
|
The job stored in the PCS database.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
JobFetchingError
|
If fetching failed. |
Source code in pasqal_cloud/__init__.py
get_jobs(filters=None, pagination_params=None)
Retrieve a list of jobs matching filters using a pagination system.
Jobs are sorted by their creation date in descending order.
If no 'pagination_params' are provided, the first 100 jobs matching the query will be returned by default.
PARAMETER | DESCRIPTION |
---|---|
filters
|
Filters to be applied to the jobs.
TYPE:
|
pagination_params
|
Pagination to be applied to the query.
TYPE:
|
Examples:
get_jobs(filters=JobFilters(status=JobStatus.ERROR)) Returns the first 100 jobs with an ERROR status.
get_jobs(filters=JobFilters(status=JobStatus.ERROR), pagination_params=PaginationParams(offset=100)) Returns jobs 101-200 with an ERROR status.
get_jobs(filters=JobFilters(status=JobStatus.ERROR), pagination_params=PaginationParams(offset=200)) Returns jobs 201-300 with an ERROR status.
RETURNS | DESCRIPTION |
---|---|
PaginatedResponse
|
Includes the results of the API and some pagination information.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
JobFetchingError
|
If fetching jobs call failed. |
TypeError
|
If |
Source code in pasqal_cloud/__init__.py
get_workload(id, wait=False)
Retrieve a workload's data.
PARAMETER | DESCRIPTION |
---|---|
id
|
ID of the workload.
TYPE:
|
wait
|
Whether to wait for the workload to be done.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
workload
|
The workload stored in the PCS database.
TYPE:
|
RAISES | DESCRIPTION |
---|---|
WorkloadFetchingError
|
If fetching failed. |
Source code in pasqal_cloud/__init__.py
rebatch(id, filters=None)
Retry a group of jobs matching filters in a new batch.
PARAMETER | DESCRIPTION |
---|---|
id
|
id of the batch to re-create
TYPE:
|
filters
|
filters to be applied to find the jobs that will be retried
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Batch
|
An instance of a rescheduled Batch model. The fields |
Batch
|
can differ from the original batch as the record |
Batch
|
is recreated as to prevent modifying the original batch. |
RAISES | DESCRIPTION |
---|---|
RebatchError
|
if rebatch call failed. |