BaseJob Class
Base job class with methods to create a job from raw blob data, upload blob data and download results.
- Inheritance
-
azure.quantum.job.workspace_item.WorkspaceItemBaseJob
Constructor
BaseJob(workspace: Workspace, details: ItemDetails, **kwargs)
Parameters
Name | Description |
---|---|
workspace
Required
|
Workspace instance of the job |
details
Required
|
<xref:ItemDetails>
Item details model, contains item ID, name and other details |
Methods
create_job_id |
Create a unique id for a new job. |
download_attachment |
Downloads an attachment from job's container in Azure Storage. Attachments are blobs of data created as part of the Job's execution, or they can be created by uploading directly from Python using the upload_attachment method. |
download_blob_properties |
Download Blob properties |
download_data |
Download file from blob uri |
from_input_data |
Create a new Azure Quantum job based on a raw input_data payload. |
from_storage_uri |
Create new Job from URI if input data is already uploaded to blob storage |
upload_attachment |
Uploads an attachment to the job's container file. Attachment's are identified by name. Uploading to an existing attachment overrides its previous content. |
upload_input_data |
Upload input data file |
create_job_id
Create a unique id for a new job.
static create_job_id() -> str
download_attachment
Downloads an attachment from job's container in Azure Storage. Attachments are blobs of data created as part of the Job's execution, or they can be created by uploading directly from Python using the upload_attachment method.
download_attachment(name: str, container_uri: str = None)
Parameters
Name | Description |
---|---|
name
Required
|
Attachment name |
container_uri
|
Container URI, defaults to the job's linked container. Default value: None
|
Returns
Type | Description |
---|---|
Attachment data |
download_blob_properties
Download Blob properties
download_blob_properties(blob_uri: str)
Parameters
Name | Description |
---|---|
blob_uri
Required
|
Blob URI |
Returns
Type | Description |
---|---|
Blob properties |
download_data
Download file from blob uri
download_data(blob_uri: str) -> dict
Parameters
Name | Description |
---|---|
blob_uri
Required
|
Blob URI |
Returns
Type | Description |
---|---|
Payload from blob |
from_input_data
Create a new Azure Quantum job based on a raw input_data payload.
from_input_data(workspace: Workspace, name: str, target: str, input_data: bytes, content_type: ContentType = ContentType.json, blob_name: str = 'inputData', encoding: str = '', job_id: str = None, container_name: str = None, provider_id: str = None, input_data_format: str = None, output_data_format: str = None, input_params: Dict[str, Any] = None, session_id: str | None = None, **kwargs) -> BaseJob
Parameters
Name | Description |
---|---|
workspace
Required
|
Azure Quantum workspace to submit the input_data to |
name
Required
|
Name of the job |
target
Required
|
Azure Quantum target |
input_data
Required
|
Raw input data to submit |
blob_name
|
Input data blob name, defaults to "inputData" Default value: inputData
|
content_type
|
Content type, e.g. "application/json" Default value: ContentType.json
|
encoding
Required
|
input_data encoding, e.g. "gzip", defaults to empty string |
job_id
|
Job ID, defaults to None Default value: None
|
container_name
|
Container name, defaults to None Default value: None
|
provider_id
|
Provider ID, defaults to None Default value: None
|
input_data_format
|
Input data format, defaults to None Default value: None
|
output_data_format
|
Output data format, defaults to None Default value: None
|
input_params
|
Input parameters, defaults to None Default value: None
|
input_params
Required
|
Input params for job |
session_id
|
Default value: None
|
Returns
Type | Description |
---|---|
Azure Quantum Job |
from_storage_uri
Create new Job from URI if input data is already uploaded to blob storage
from_storage_uri(workspace: Workspace, name: str, target: str, input_data_uri: str, provider_id: str, input_data_format: str, output_data_format: str, container_uri: str = None, job_id: str = None, input_params: Dict[str, Any] = None, submit_job: bool = True, session_id: str | None = None, **kwargs) -> BaseJob
Parameters
Name | Description |
---|---|
workspace
Required
|
Azure Quantum workspace to submit the blob to |
name
Required
|
Job name |
target
Required
|
Azure Quantum target |
input_data_uri
Required
|
Input data URI |
provider_id
Required
|
Provider ID |
input_data_format
Required
|
Input data format |
output_data_format
Required
|
Output data format |
container_uri
|
Container URI, defaults to None Default value: None
|
job_id
|
Pre-generated job ID, defaults to None Default value: None
|
input_params
|
Input parameters, defaults to None Default value: None
|
submit_job
|
If job should be submitted to the service, defaults to True Default value: True
|
session_id
|
Default value: None
|
Returns
Type | Description |
---|---|
Job instance |
upload_attachment
Uploads an attachment to the job's container file. Attachment's are identified by name. Uploading to an existing attachment overrides its previous content.
upload_attachment(name: str, data: bytes, container_uri: str = None, **kwargs) -> str
Parameters
Name | Description |
---|---|
name
Required
|
Attachment name |
data
Required
|
Attachment data in binary format |
container_uri
|
Container URI, defaults to the job's linked container. Default value: None
|
Returns
Type | Description |
---|---|
Uploaded data URI |
upload_input_data
Upload input data file
static upload_input_data(container_uri: str, input_data: bytes, content_type: ContentType | None = ContentType.json, blob_name: str = 'inputData', encoding: str = '', return_sas_token: bool = False) -> str
Parameters
Name | Description |
---|---|
container_uri
Required
|
Container URI |
input_data
Required
|
Input data in binary format |
content_type
|
Content type, e.g. "application/json" Default value: ContentType.json
|
blob_name
|
Blob name, defaults to "inputData" Default value: inputData
|
encoding
Required
|
Encoding, e.g. "gzip", defaults to "" |
return_sas_token
|
Flag to return SAS token as part of URI, defaults to False Default value: False
|
Returns
Type | Description |
---|---|
Uploaded data URI |
Attributes
container_name
Job input/output data container name
details
Job details