def run_on_backend(backend, qobj, backend_options=None, noise_config=None, skip_qobj_validation=False): if skip_qobj_validation: job_id = str(uuid.uuid4()) if is_aer_provider(backend): from qiskit.providers.aer.aerjob import AerJob temp_backend_options = backend_options[ 'backend_options'] if backend_options != {} else None temp_noise_config = noise_config[ 'noise_model'] if noise_config != {} else None job = AerJob(backend, job_id, backend._run_job, qobj, temp_backend_options, temp_noise_config, False) job._future = job._executor.submit(job._fn, job._job_id, job._qobj, *job._args) elif is_basicaer_provider(backend): backend._set_options(qobj_config=qobj.config, **backend_options) job = BasicAerJob(backend, job_id, backend._run_job, qobj) job._future = job._executor.submit(job._fn, job._job_id, job._qobj) elif is_ibmq_provider(backend): # TODO: IBMQJob performs validation during the constructor. the following lines does not # skip validation but run as is. from qiskit.providers.ibmq.ibmqjob import IBMQJob job = IBMQJob(backend, None, backend._api, qobj=qobj) job._future = job._executor.submit(job._submit_callback) else: logger.info( "Can't skip qobj validation for the third-party provider.") job = backend.run(qobj, **backend_options, **noise_config) return job else: job = backend.run(qobj, **backend_options, **noise_config) return job
def run_on_backend(backend, qobj, backend_options=None, noise_config=None, skip_qobj_validation=False): """ run on backend """ if skip_qobj_validation: job_id = str(uuid.uuid4()) if is_aer_provider(backend): from qiskit.providers.aer.aerjob import AerJob temp_backend_options = \ backend_options['backend_options'] if backend_options != {} else None temp_noise_config = noise_config['noise_model'] if noise_config != {} else None job = AerJob(backend, job_id, backend._run_job, qobj, temp_backend_options, temp_noise_config, False) job._future = job._executor.submit(job._fn, job._job_id, job._qobj, *job._args) elif is_basicaer_provider(backend): backend._set_options(qobj_config=qobj.config, **backend_options) job = BasicAerJob(backend, job_id, backend._run_job, qobj) job._future = job._executor.submit(job._fn, job._job_id, job._qobj) else: logger.info( "Can't skip qobj validation for the %s provider.", backend.provider().__class__.__name__) job = backend.run(qobj, **backend_options, **noise_config) return job else: job = backend.run(qobj, **backend_options, **noise_config) return job
def run_on_backend(backend, qobj, backend_options=None, noise_config=None, skip_qobj_validation=False): if skip_qobj_validation: job_id = str(uuid.uuid4()) if backend.configuration().simulator: if type(backend.provider()).__name__ == 'AerProvider': from qiskit.providers.aer.aerjob import AerJob job = AerJob(backend, job_id, backend._run_job, qobj, backend_options, noise_config) job._future = job._executor.submit(job._fn, job._job_id, job._qobj, backend_options, noise_config) else: job = SimulatorsJob(backend, job_id, backend._run_job, qobj) job._future = job._executor.submit(job._fn, job._job_id, job._qobj) else: job = IBMQJob(backend, None, backend._api, not backend.configuration().simulator, qobj=qobj) job._future = job._executor.submit(job._fn, job._job_id, job._qobj) return job else: job = backend.run(qobj, **backend_options, **noise_config) return job
def run_on_backend(backend, qobj, backend_options=None, noise_config=None, skip_qobj_validation=False): """ run on backend """ if skip_qobj_validation: job_id = str(uuid.uuid4()) if is_aer_provider(backend): # pylint: disable=import-outside-toplevel try: from qiskit.providers.aer.aerjob import AerJob except ImportError as ex: raise MissingOptionalLibraryError( libname='qiskit-aer', name='run_on_backend', pip_install='pip install qiskit-aer') from ex temp_backend_options = \ backend_options['backend_options'] if backend_options != {} else None temp_noise_config = noise_config[ 'noise_model'] if noise_config != {} else None job = AerJob(backend, job_id, backend._run_job, qobj, temp_backend_options, temp_noise_config, False) job._future = job._executor.submit(job._fn, job._job_id, job._qobj, *job._args) elif is_basicaer_provider(backend): backend._set_options(qobj_config=qobj.config, **backend_options) job = BasicAerJob(backend, job_id, backend._run_job, qobj) job._future = job._executor.submit(job._fn, job._job_id, job._qobj) else: logger.info("Can't skip qobj validation for the %s provider.", backend.provider().__class__.__name__) job = backend.run(qobj, **backend_options, **noise_config) return job else: job = backend.run(qobj, **backend_options, **noise_config) return job