backend
¶
Classes:
-
OqtopusConfig–A configuration information class for using OQTOPUS backend.
-
OqtopusDevice–A device embedded in the oqtopus framework.
-
OqtopusDeviceBackend–A class representing a device backend for Oqtopus.
-
OqtopusEstimationBackend–A OQTOPUS backend for a estimation.
-
OqtopusEstimationJob–A job for a estimation.
-
OqtopusEstimationResult–A result of a estimation job.
-
OqtopusSamplingBackend–A OQTOPUS backend for a sampling measurement.
-
OqtopusSamplingJob–A job for a sampling measurement.
-
OqtopusSamplingResult–A result of a sampling job.
-
OqtopusSseBackend–A job for a SSE.
OqtopusConfig
¶
A configuration information class for using OQTOPUS backend.
Parameters:
Raises:
-
ValueError–If
urlorapi_tokenis None.
Methods:
-
from_file–Read configuration information from a file.
Attributes:
-
api_token(str) –Return the API token.
-
proxy(str | None) –Return the proxy.
-
url(str) –Return the url.
api_token
property
¶
api_token: str
Return the API token.
Returns:
-
str(str) –the API token to access OCTOPUS Cloud.
proxy
property
¶
proxy: str | None
Return the proxy.
Returns:
-
str | None–str | None: the proxy to access OCTOPUS Cloud.
from_file
staticmethod
¶
from_file(
section: str | None = "default",
path: str | None = "~/.oqtopus",
) -> OqtopusConfig
Read configuration information from a file.
Parameters:
-
(section¶str | None, default:'default') –A :class:
OqtopusConfigfor circuit execution. -
(path¶str | None, default:'~/.oqtopus') –A path for config file.
Returns:
-
OqtopusConfig–Configuration information :class:
OqtopusConfig.
Raises:
ValueError: If path is None.
Examples:
The OQTOPUS configuration file describes configuration information for each
section. A section has a header in the form [section].
The default file path is ~/.oqtopus and the default section name is
default. Each section describes a setting in the format key=value.
An example of a configuration file description is as below:
.. code-block::
[default]
url=<base URL>
api_token=<API token>
[sectionA]
url=<base URL>
api_token=<API token>
[sectioB]
url=<base URL>
api_token=<API token>
proxy=http://<proxy>:<port>
If sectionA settings are to be used, initialize
OqtopusSamplingBackend as follows
.. code-block::
backend = OqtopusSamplingBackend(OqtopusConfig.from_file("sectionA"))
OqtopusDevice
¶
OqtopusDevice(
device: DevicesDeviceInfo, device_api: DeviceApi
)
A device embedded in the oqtopus framework.
Parameters:
-
(device¶DevicesDeviceInfo) –The device information.
-
(device_api¶DeviceApi) –The device API for communication with the backend.
Raises:
-
ValueError–If the device or device_api is None.
Methods:
-
refresh–Retrieve the device information from OQTOPUS Cloud.
-
to_json–Return a json string representation of the OqtopusDevice.
Attributes:
-
available_at(datetime) –The
available_atof this DevicesDeviceInfo. -
basis_gates(list[str]) –The basis gates of the device.
-
calibrated_at(datetime) –The
calibrated_atof this DevicesDeviceInfo. -
description(str) –The description of the device.
-
device_id(str) –The device id of the device.
-
device_info(dict) –The device information of the device.
-
device_type(str) –The device type of the device.
-
n_pending_jobs(int) –The number of pending jobs in the device.
-
n_qubits(int) –The number of qubits in the device.
-
status(str) –The status of the device.
-
supported_instructions(list[str]) –The supported instructions of the device.
available_at
property
¶
available_at: datetime
The available_at of this DevicesDeviceInfo.
Returns:
-
datetime(datetime) –The
available_atof this DevicesDeviceInfo.
basis_gates
property
¶
basis_gates: list[str]
The basis gates of the device.
Returns:
-
list[str]–list[str]: The basis gates of the device.
calibrated_at
property
¶
calibrated_at: datetime
The calibrated_at of this DevicesDeviceInfo.
Returns:
-
datetime(datetime) –The
calibrated_atof this DevicesDeviceInfo.
description
property
¶
description: str
The description of the device.
Returns:
-
str(str) –The description of the device.
device_id
property
¶
device_id: str
The device id of the device.
Returns:
-
str(str) –The device id of the device.
device_info
property
¶
device_info: dict
The device information of the device.
Returns:
-
dict(dict) –The device information of the device.
device_type
property
¶
device_type: str
The device type of the device.
Returns:
-
str(str) –The device type of the device.
n_pending_jobs
property
¶
n_pending_jobs: int
The number of pending jobs in the device.
Returns:
-
int(int) –The number of pending jobs in the device.
n_qubits
property
¶
n_qubits: int
The number of qubits in the device.
Returns:
-
int(int) –The number of qubits in the device.
status
property
¶
status: str
The status of the device.
Returns:
-
str(str) –The status of the device.
supported_instructions
property
¶
supported_instructions: list[str]
The supported instructions of the device.
Returns:
-
list[str]–list[str]: The supported instructions of the device.
refresh
¶
refresh() -> None
Retrieve the device information from OQTOPUS Cloud.
Raises:
-
BackendError–If device cannot be found or if an authentication error occurred or timeout occurs, etc.
to_json
¶
to_json() -> str
Return a json string representation of the OqtopusDevice.
Returns:
-
str(str) –A json string representation of the OqtopusDevice.
OqtopusDeviceBackend
¶
OqtopusDeviceBackend(config: OqtopusConfig | None = None)
A class representing a device backend for Oqtopus.
This class is a placeholder and does not implement any functionality. It serves as a base for creating specific device backends in the future.
Methods:
-
get_device–Get a device by its ID.
-
get_devices–Get all devices registered in Oqtopus Cloud.
get_device
¶
get_device(device_id: str) -> OqtopusDevice
Get a device by its ID.
Parameters:
-
(device_id¶str) –The ID of the device.
Returns:
-
OqtopusDevice(OqtopusDevice) –An OqtopusDevice object.
get_devices
¶
get_devices() -> list[OqtopusDevice]
Get all devices registered in Oqtopus Cloud.
Returns:
-
list[OqtopusDevice]–list[OqtopusDevice]: A list of OqtopusDevice objects.
OqtopusEstimationBackend
¶
OqtopusEstimationBackend(
config: OqtopusConfig | None = None,
)
A OQTOPUS backend for a estimation.
Parameters:
-
(config¶OqtopusConfig | None, default:None) –A :class:
OqtopusConfigfor circuit execution. If this parameter isNoneand both environment variablesOQTOPUS_URLandOQTOPUS_API_TOKENexist, create a :class:OqtopusConfigusing the values of theOQTOPUS_URL,OQTOPUS_API_TOKEN, andOQTOPUS_PROXYenvironment variables.If this parameter is
Noneand the environment variables do not exist, thedefaultsection in the~/.oqtopusfile is read.
Methods:
-
estimate–Execute a estimation of a circuit.
-
estimate_qasm–Execute estimation of the program.
-
retrieve_job–Retrieve the job with the given id from OQTOPUS Cloud.
estimate
¶
estimate(
program: NonParametricQuantumCircuit,
operator: Operator,
device_id: str,
shots: int,
name: str | None = None,
description: str | None = None,
transpiler_info: dict | None = None,
simulator_info: dict | None = None,
mitigation_info: dict | None = None,
) -> OqtopusEstimationJob
Execute a estimation of a circuit.
The circuit is transpiled on OQTOPUS Cloud. The QURI Parts transpiling feature is not supported. The circuit is converted to OpenQASM 3.0 format and sent to OQTOPUS Cloud.
Parameters:
-
(program¶NonParametricQuantumCircuit) –The circuit to be estimated.
-
(operator¶Operator) –The observable operator applied to the circuit.
-
(device_id¶str) –The device id to be executed.
-
(shots¶int) –Number of repetitions of each circuit, for estimation.
-
(name¶str | None, default:None) –The name to be assigned to the job. Defaults to None.
-
(description¶str | None, default:None) –The description to be assigned to the job. Defaults to None.
-
(transpiler_info¶dict | None, default:None) –The transpiler information. Defaults to None.
-
(simulator_info¶dict | None, default:None) –The simulator information. Defaults to None.
-
(mitigation_info¶dict | None, default:None) –The mitigation information. Defaults to None.
Returns:
-
OqtopusEstimationJob–The job to be executed.
estimate_qasm
¶
estimate_qasm(
program: str,
operator: Operator,
device_id: str,
shots: int,
name: str | None = None,
description: str | None = None,
transpiler_info: dict | None = None,
simulator_info: dict | None = None,
mitigation_info: dict | None = None,
) -> OqtopusEstimationJob
Execute estimation of the program.
The program is transpiled on OQTOPUS Cloud. QURI Parts OQTOPUS does not support QURI Parts transpiling feature.
Parameters:
-
(program¶str) –The program to be estimated.
-
(operator¶Operator) –The observable operator applied to the circuit.
-
(device_id¶str) –The device id to be executed.
-
(shots¶int) –Number of repetitions of each circuit, for estimation.
-
(name¶str | None, default:None) –The name to be assigned to the job. Defaults to None.
-
(description¶str | None, default:None) –The description to be assigned to the job. Defaults to None.
-
(transpiler_info¶dict | None, default:None) –The transpiler information. Defaults to None.
-
(simulator_info¶dict | None, default:None) –The simulator information. Defaults to None.
-
(mitigation_info¶dict | None, default:None) –The mitigation information. Defaults to None.
Returns:
-
OqtopusEstimationJob(OqtopusEstimationJob) –The job to be executed.
Raises:
-
ValueError–If
shotsis not a positive integer. -
ValueError–Imaginary part of coefficient is not supported.
-
BackendError–If job is wrong or if an authentication error occurred, etc.
retrieve_job
¶
retrieve_job(job_id: str) -> OqtopusEstimationJob
Retrieve the job with the given id from OQTOPUS Cloud.
Parameters:
-
(job_id¶str) –The id of the job to retrieve.
Returns:
-
OqtopusEstimationJob–The job with the given
job_id.
Raises:
-
BackendError–If job cannot be found or if an authentication error occurred, etc.
OqtopusEstimationJob
¶
OqtopusEstimationJob(job: JobsJobDef, job_api: JobApi)
A job for a estimation.
Parameters:
-
(job¶JobsJobDef) –A result of dict type.
-
(job_api¶JobApi) –A result of dict type.
Raises:
-
ValueError–If
joborjob_apiis None.
Methods:
-
cancel–Cancel the job.
-
refresh–Retrieve the latest job information from OQTOPUS Cloud.
-
result–Wait until the job progress to the end and returns the result of the job.
-
to_json–Return a json string representation of the OqtopusEstimationJob.
-
wait_for_completion–Wait until the job progress to the end.
Attributes:
-
description(str) –The description of the job.
-
device_id(str) –The device id of the job.
-
ended_at(datetime) –The
ended_atof the job. -
execution_time(float) –The execution time of the job.
-
job_id(str) –The id of the job.
-
job_info(dict) –The detail information of the job.
-
job_type(str) –The job type of the job.
-
mitigation_info(dict) –The mitigation info of the job.
-
name(str) –The name of the job.
-
ready_at(datetime) –The
ready_atof the job. -
running_at(datetime) –The
running_atof the job. -
shots(int) –The shots of the job.
-
simulator_info(dict) –The simulator info of the job.
-
status(str) –The status of the job.
-
submitted_at(datetime) –The
submitted_atof the job. -
transpiler_info(dict) –The transpiler info of the job.
description
property
¶
description: str
The description of the job.
Returns:
-
str(str) –The description of the job.
device_id
property
¶
device_id: str
The device id of the job.
Returns:
-
str(str) –The device id of the job.
ended_at
property
¶
ended_at: datetime
The ended_at of the job.
Returns:
-
datetime(datetime) –The
ended_atof the job.
execution_time
property
¶
execution_time: float
The execution time of the job.
Returns:
-
float(float) –The execution time of the job.
job_info
property
¶
job_info: dict
The detail information of the job.
Returns:
-
dict(dict) –The detail information of the job.
job_type
property
¶
job_type: str
The job type of the job.
Returns:
-
str(str) –The job type of the job.
mitigation_info
property
¶
mitigation_info: dict
The mitigation info of the job.
Returns:
-
dict(dict) –The mitigation info of the job.
ready_at
property
¶
ready_at: datetime
The ready_at of the job.
Returns:
-
datetime(datetime) –The
ready_atof the job.
running_at
property
¶
running_at: datetime
The running_at of the job.
Returns:
-
datetime(datetime) –The
running_atof the job.
simulator_info
property
¶
simulator_info: dict
The simulator info of the job.
Returns:
-
dict(dict) –The simulator info of the job.
submitted_at
property
¶
submitted_at: datetime
The submitted_at of the job.
Returns:
-
datetime(datetime) –The
submitted_atof the job.
transpiler_info
property
¶
transpiler_info: dict
The transpiler info of the job.
Returns:
-
dict(dict) –The transpiler info of the job.
cancel
¶
cancel() -> None
Cancel the job.
If the job statuses are success, failure, or cancelled, then cannot be cancelled and an error occurs.
Raises:
-
BackendError–If job cannot be found or if an authentication error occurred or if job cannot be cancelled, etc.
refresh
¶
refresh() -> None
Retrieve the latest job information from OQTOPUS Cloud.
Raises:
-
BackendError–If job cannot be found or if an authentication error occurred or timeout occurs, etc.
result
¶
result(
timeout: float | None = None, wait: float = 10.0
) -> OqtopusEstimationResult
Wait until the job progress to the end and returns the result of the job.
If the status of job is not succeeded or failed, or cancelled,
the job is retrieved from OQTOPUS Cloud at intervals of wait seconds.
If the job does not progress to the end after timeout seconds,
raise :class:BackendError.
Parameters:
-
(timeout¶float | None, default:None) –The number of seconds to wait for job.
-
(wait¶float, default:10.0) –Time in seconds between queries.
Returns:
-
OqtopusEstimationResult(OqtopusEstimationResult) –the result of the estimation job.
Raises:
-
BackendError–If job cannot be found or if an authentication error occurred or timeout occurs, etc.
to_json
¶
to_json() -> str
Return a json string representation of the OqtopusEstimationJob.
Returns:
-
str(str) –A json string representation of the OqtopusEstimationJob.
wait_for_completion
¶
wait_for_completion(
timeout: float | None = None, wait: float = 10.0
) -> JobsJobDef | None
Wait until the job progress to the end.
Calling this function waits until the job progress to the end such as
succeeded or failed, cancelled.
Parameters:
-
(timeout¶float | None, default:None) –The number of seconds to wait for job.
-
(wait¶float, default:10.0) –Time in seconds between queries.
Returns:
-
JobsJobDef | None–JobsJobDef | None: If a timeout occurs, it returns None. Otherwise, it returns the Job.
OqtopusEstimationResult
¶
OqtopusEstimationResult(result: dict[str, Any])
A result of a estimation job.
Parameters:
-
(result¶dict[str, Any]) –A result of dict type.
Raises:
-
ValueError–If
estimationdoes not exist in result.
Examples:
An example of a dict of result is as below:
.. code-block::
{
"estimation": {
"exp_value": 2.0,
"stds": 1.1
}
}
exp_value represents the expectation value.
In the above case, exp_value is defined as a real number 2.0.
stds represents the standard deviation value.
Attributes:
OqtopusSamplingBackend
¶
OqtopusSamplingBackend(config: OqtopusConfig | None = None)
A OQTOPUS backend for a sampling measurement.
Parameters:
-
(config¶OqtopusConfig | None, default:None) –A :class:
OqtopusConfigfor circuit execution. If this parameter isNoneand both environment variablesOQTOPUS_URLandOQTOPUS_API_TOKENexist, create a :class:OqtopusConfigusing the values of theOQTOPUS_URL,OQTOPUS_API_TOKEN, andOQTOPUS_PROXYenvironment variables.If this parameter is
Noneand the environment variables do not exist, thedefaultsection in the~/.oqtopusfile is read.
Methods:
-
retrieve_job–Retrieve the job with the given id from OQTOPUS Cloud.
-
sample–Execute a sampling measurement of a circuit.
-
sample_qasm–Execute sampling measurement of the program.
retrieve_job
¶
retrieve_job(job_id: str) -> OqtopusSamplingJob
Retrieve the job with the given id from OQTOPUS Cloud.
Parameters:
-
(job_id¶str) –The id of the job to retrieve.
Returns:
-
OqtopusSamplingJob–The job with the given
job_id.
Raises:
-
BackendError–If job cannot be found or if an authentication error occurred, etc.
sample
¶
sample(
program: NonParametricQuantumCircuit
| list[NonParametricQuantumCircuit],
device_id: str,
shots: int,
name: str | None = None,
description: str | None = None,
transpiler_info: dict | None = None,
simulator_info: dict | None = None,
mitigation_info: dict | None = None,
) -> OqtopusSamplingJob
Execute a sampling measurement of a circuit.
The circuit is transpiled on OQTOPUS Cloud. The QURI Parts transpiling feature is not supported. The circuit is converted to OpenQASM 3.0 format and sent to OQTOPUS Cloud.
Parameters:
-
(program¶NonParametricQuantumCircuit | list[NonParametricQuantumCircuit]) –The circuit to be sampled.
-
(device_id¶str) –The device id to be executed.
-
(shots¶int) –Number of repetitions of each circuit, for sampling.
-
(name¶str | None, default:None) –The name to be assigned to the job. Defaults to None.
-
(description¶str | None, default:None) –The description to be assigned to the job. Defaults to None.
-
(transpiler_info¶dict | None, default:None) –The transpiler information. Defaults to None.
-
(simulator_info¶dict | None, default:None) –The simulator information. Defaults to None.
-
(mitigation_info¶dict | None, default:None) –The mitigation information. Defaults to None.
Returns:
-
OqtopusSamplingJob–The job to be executed.
sample_qasm
¶
sample_qasm(
program: str | list[str],
device_id: str,
shots: int,
name: str | None = None,
description: str | None = None,
transpiler_info: dict | None = None,
simulator_info: dict | None = None,
mitigation_info: dict | None = None,
job_type: str | None = None,
) -> OqtopusSamplingJob
Execute sampling measurement of the program.
The program is transpiled on OQTOPUS Cloud. QURI Parts OQTOPUS does not support QURI Parts transpiling feature.
Parameters:
-
(program¶str | list[str]) –The program to be sampled.
-
(device_id¶str) –The device id to be executed.
-
(shots¶int) –Number of repetitions of each circuit, for sampling.
-
(name¶str | None, default:None) –The name to be assigned to the job. Defaults to None.
-
(description¶str | None, default:None) –The description to be assigned to the job. Defaults to None.
-
(transpiler_info¶dict | None, default:None) –The transpiler information. Defaults to None.
-
(simulator_info¶dict | None, default:None) –The simulator information. Defaults to None.
-
(mitigation_info¶dict | None, default:None) –The mitigation information. Defaults to None.
-
(job_type¶str | None, default:None) –The job type. Defaults to None.
Returns:
-
OqtopusSamplingJob(OqtopusSamplingJob) –The job to be executed.
Raises:
-
ValueError–If
shotsis not a positive integer. -
BackendError–If job is wrong or if an authentication error occurred, etc.
OqtopusSamplingJob
¶
OqtopusSamplingJob(job: JobsJobDef, job_api: JobApi)
A job for a sampling measurement.
Parameters:
-
(job¶JobsJobDef) –A result of dict type.
-
(job_api¶JobApi) –A result of dict type.
Raises:
-
ValueError–If
joborjob_apiis None.
Methods:
-
cancel–Cancel the job.
-
refresh–Retrieve the latest job information from OQTOPUS Cloud.
-
result–Wait until the job progress to the end and returns the result of the job.
-
to_json–Return a json string representation of the OqtopusSamplingJob.
-
wait_for_completion–Wait until the job progress to the end.
Attributes:
-
description(str) –The description of the job.
-
device_id(str) –The device id of the job.
-
ended_at(datetime) –The
ended_atof the job. -
execution_time(float) –The execution time of the job.
-
job_id(str) –The id of the job.
-
job_info(dict) –The detail information of the job.
-
job_type(str) –The job type of the job.
-
mitigation_info(dict) –The mitigation info of the job.
-
name(str) –The name of the job.
-
ready_at(datetime) –The
ready_atof the job. -
running_at(datetime) –The
running_atof the job. -
shots(int) –The shots of the job.
-
simulator_info(dict) –The simulator info of the job.
-
status(str) –The status of the job.
-
submitted_at(datetime) –The
submitted_atof the job. -
transpiler_info(dict) –The transpiler info of the job.
description
property
¶
description: str
The description of the job.
Returns:
-
str(str) –The description of the job.
device_id
property
¶
device_id: str
The device id of the job.
Returns:
-
str(str) –The device id of the job.
ended_at
property
¶
ended_at: datetime
The ended_at of the job.
Returns:
-
datetime(datetime) –The
ended_atof the job.
execution_time
property
¶
execution_time: float
The execution time of the job.
Returns:
-
float(float) –The execution time of the job.
job_info
property
¶
job_info: dict
The detail information of the job.
Returns:
-
dict(dict) –The detail information of the job.
job_type
property
¶
job_type: str
The job type of the job.
Returns:
-
str(str) –The job type of the job.
mitigation_info
property
¶
mitigation_info: dict
The mitigation info of the job.
Returns:
-
dict(dict) –The mitigation info of the job.
ready_at
property
¶
ready_at: datetime
The ready_at of the job.
Returns:
-
datetime(datetime) –The
ready_atof the job.
running_at
property
¶
running_at: datetime
The running_at of the job.
Returns:
-
datetime(datetime) –The
running_atof the job.
simulator_info
property
¶
simulator_info: dict
The simulator info of the job.
Returns:
-
dict(dict) –The simulator info of the job.
submitted_at
property
¶
submitted_at: datetime
The submitted_at of the job.
Returns:
-
datetime(datetime) –The
submitted_atof the job.
transpiler_info
property
¶
transpiler_info: dict
The transpiler info of the job.
Returns:
-
dict(dict) –The transpiler info of the job.
cancel
¶
cancel() -> None
Cancel the job.
If the job statuses are success, failure, or cancelled, then cannot be cancelled and an error occurs.
Raises:
-
BackendError–If job cannot be found or if an authentication error occurred or if job cannot be cancelled, etc.
refresh
¶
refresh() -> None
Retrieve the latest job information from OQTOPUS Cloud.
Raises:
-
BackendError–If job cannot be found or if an authentication error occurred or timeout occurs, etc.
result
¶
result(
timeout: float | None = None, wait: float = 10.0
) -> OqtopusSamplingResult
Wait until the job progress to the end and returns the result of the job.
If the status of job is not succeeded or failed, or cancelled,
the job is retrieved from OQTOPUS Cloud at intervals of wait seconds.
If the job does not progress to the end after timeout seconds,
raise :class:BackendError.
Parameters:
-
(timeout¶float | None, default:None) –The number of seconds to wait for job.
-
(wait¶float, default:10.0) –Time in seconds between queries.
Returns:
-
OqtopusSamplingResult(OqtopusSamplingResult) –the result of the sampling job.
Raises:
-
BackendError–If job cannot be found or if an authentication error occurred or timeout occurs, etc.
to_json
¶
to_json() -> str
Return a json string representation of the OqtopusSamplingJob.
Returns:
-
str(str) –A json string representation of the OqtopusSamplingJob.
wait_for_completion
¶
wait_for_completion(
timeout: float | None = None, wait: float = 10.0
) -> JobsJobDef | None
Wait until the job progress to the end.
Calling this function waits until the job progress to the end such as
succeeded or failed, cancelled.
Parameters:
-
(timeout¶float | None, default:None) –The number of seconds to wait for job.
-
(wait¶float, default:10.0) –Time in seconds between queries.
Returns:
-
JobsJobDef | None–JobsJobDef | None: If a timeout occurs, it returns None. Otherwise, it returns the Job.
OqtopusSamplingResult
¶
OqtopusSamplingResult(result: dict[str, Any])
A result of a sampling job.
Parameters:
-
(result¶dict[str, Any]) –A result of dict type. This dict should have the key
counts. The value ofcountsis the dict input for the counts. Where the keys represent a measured classical value and the value is an integer the number of shots with that result.If the keys of
countsis expressed as a bit string, thenpropertiesis a mapping from the index of bit string to the index of the quantum circuit.
Raises:
-
ValueError–If
countsdoes not exist in result.
Examples:
An example of a dict of result is as below:
.. code-block::
{
"counts": {
"0": 600,
"1": 300,
"3": 100,
}
}
In the above case, the bit string representation of 0, 1, and 3
in the keys of counts is "00", "01", and "11" respectively.
The LSB (Least Significant Bit) of the bit string representation is
classical index=0.
Attributes:
-
counts(SamplingCounts) –Returns the dict input for the counts.
-
divided_counts(dict | None) –Returns divided_counts.
OqtopusSseBackend
¶
OqtopusSseBackend(config: OqtopusConfig | None = None)
A job for a SSE.
Parameters:
-
(config¶OqtopusConfig | None, default:None) –A :class:
OqtopusConfigfor job execution.
Methods:
-
download_log–Download logs generated by an SSE job on a OQTOPUS Cloud.
-
run_sse–Perform a SSE job.
download_log
¶
Download logs generated by an SSE job on a OQTOPUS Cloud.
Parameters:
-
(job_id¶str | None, default:None) –job id. Defaults to None.
-
(save_dir¶str | None, default:None) –Local directory path for downloads. Defaults to None.
Raises:
-
BackendError–If an error is returned from OQTOPUS Cloud.
-
ValueError–If
save_dirdoes not exist. -
ValueError–If
save_diris not a directory. -
ValueError–If the file already exists.
Returns:
-
str(str) –The file path of the saved SSE log.
run_sse
¶
run_sse(
file_path: str,
device_id: str,
name: str,
description: str | None = None,
) -> OqtopusSamplingJob
Perform a SSE job.
Parameters:
-
(file_path¶str) –The path to program file to upload.
-
(device_id¶str) –The identifier of the device where the job is executed.
-
(name¶str) –The name of the job.
-
(description¶str | None, default:None) –The description of the job. Defaults to None.
Raises:
-
ValueError–If
file_pathis not set. -
ValueError–If
file_pathdoes not exist. -
ValueError–If
file_pathis not a python file. -
ValueError–If file size is larger than max file size
-
BackendError–If an error is returned from OQTOPUS Cloud.
Returns:
-
OqtopusSamplingJob(OqtopusSamplingJob) –The job to be executed.