Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
""" Retrieve a specified job by its job_id.
Args:
job_id: The job id.
Returns:
The job that has been retrieved.
Raises:
QisKitBackendError: If job not found or error occurs during retrieval of the job.
"""
try:
self.__api.get_project(int(job_id))
except (ErrorMessage, ValueError):
raise QisKitBackendError("Could not retrieve job with job_id '{}' ".format(job_id))
return QIJob(self, job_id, self.__api)
""" Submits a quantum job to the Quantum Inspire platform.
Args:
qobj: The quantum job with the Qiskit algorithm and quantum inspire backend.
Returns:
A job that has been submitted.
"""
self.__validate_number_of_shots(qobj)
number_of_shots = qobj.config.shots
identifier = uuid.uuid1()
project_name = 'qi-sdk-project-{}'.format(identifier)
project = self.__api.create_project(project_name, number_of_shots, self.__backend)
experiments = qobj.experiments
job = QIJob(self, str(project['id']), self.__api)
for experiment in experiments:
self.__validate_number_of_clbits(experiment)
full_state_projection = self.__validate_full_state_projection(experiment)
if not full_state_projection:
QuantumInspireBackend.__validate_unsupported_measurements(experiment)
self._submit_experiment(experiment, number_of_shots, project=project,
full_state_projection=full_state_projection)
job.experiments = experiments
return job