Skip to content

Commit

Permalink
Run tweaks (#43)
Browse files Browse the repository at this point in the history
* qobj -> circuit in backend.run

* deprecate_args
  • Loading branch information
nonhermitian authored Nov 13, 2020
1 parent 1f084eb commit 175fe1a
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions qiskit_aqt_provider/aqt_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from qiskit.providers import Options
from qiskit.providers.models import BackendConfiguration
from qiskit.exceptions import QiskitError
from qiskit.util import deprecate_arguments

from . import aqt_job
from . import qobj_to_aqt
Expand Down Expand Up @@ -62,17 +63,18 @@ def __init__(self, provider):
def _default_options(cls):
return Options(shots=100)

def run(self, qobj, **kwargs):
if isinstance(qobj, qobj_mod.QasmQobj):
@deprecate_arguments({'qobj': 'circuit'})
def run(self, circuit, **kwargs):
if isinstance(circuit, qobj_mod.QasmQobj):
warnings.warn("Passing in a QASMQobj object to run() is "
"deprecated and will be removed in a future "
"release", DeprecationWarning)
if qobj.config.shots > self.configuration().max_shots:
if circuit.config.shots > self.configuration().max_shots:
raise ValueError('Number of shots is larger than maximum '
'number of shots')
aqt_json = qobj_to_aqt.qobj_to_aqt(
qobj, self._provider.access_token)[0]
elif isinstance(qobj, qobj_mod.PulseQobj):
circuit, self._provider.access_token)[0]
elif isinstance(circuit, qobj_mod.PulseQobj):
raise QiskitError("Pulse jobs are not accepted")
else:
for kwarg in kwargs:
Expand All @@ -85,7 +87,7 @@ def run(self, qobj, **kwargs):
raise ValueError('Number of shots is larger than maximum '
'number of shots')
aqt_json = circuit_to_aqt.circuit_to_aqt(
qobj, self._provider.access_token, shots=out_shots)[0]
circuit, self._provider.access_token, shots=out_shots)[0]
header = {
"Ocp-Apim-Subscription-Key": self._provider.access_token,
"SDK": "qiskit"
Expand All @@ -95,7 +97,7 @@ def run(self, qobj, **kwargs):
response = res.json()
if 'id' not in response:
raise Exception
job = aqt_job.AQTJob(self, response['id'], qobj=qobj)
job = aqt_job.AQTJob(self, response['id'], qobj=circuit)
return job


Expand Down Expand Up @@ -135,17 +137,18 @@ def __init__(self, provider):
def _default_options(cls):
return Options(shots=100)

def run(self, qobj, **kwargs):
if isinstance(qobj, qobj_mod.QasmQobj):
@deprecate_arguments({'qobj': 'circuit'})
def run(self, circuit, **kwargs):
if isinstance(circuit, qobj_mod.QasmQobj):
warnings.warn("Passing in a QASMQobj object to run() is "
"deprecated and will be removed in a future "
"release", DeprecationWarning)
if qobj.config.shots > self.configuration().max_shots:
if circuit.config.shots > self.configuration().max_shots:
raise ValueError('Number of shots is larger than maximum '
'number of shots')
aqt_json = qobj_to_aqt.qobj_to_aqt(
qobj, self._provider.access_token)[0]
elif isinstance(qobj, qobj_mod.PulseQobj):
circuit, self._provider.access_token)[0]
elif isinstance(circuit, qobj_mod.PulseQobj):
raise QiskitError("Pulse jobs are not accepted")
else:
for kwarg in kwargs:
Expand All @@ -158,7 +161,7 @@ def run(self, qobj, **kwargs):
raise ValueError('Number of shots is larger than maximum '
'number of shots')
aqt_json = circuit_to_aqt.circuit_to_aqt(
qobj, self._provider.access_token, shots=out_shots)[0]
circuit, self._provider.access_token, shots=out_shots)[0]
header = {
"Ocp-Apim-Subscription-Key": self._provider.access_token,
"SDK": "qiskit"
Expand All @@ -168,7 +171,7 @@ def run(self, qobj, **kwargs):
response = res.json()
if 'id' not in response:
raise Exception
job = aqt_job.AQTJob(self, response['id'], qobj=qobj)
job = aqt_job.AQTJob(self, response['id'], qobj=circuit)
return job


Expand Down Expand Up @@ -207,17 +210,18 @@ def __init__(self, provider):
def _default_options(cls):
return Options(shots=100)

def run(self, qobj, **kwargs):
if isinstance(qobj, qobj_mod.QasmQobj):
@deprecate_arguments({'qobj': 'circuit'})
def run(self, circuit, **kwargs):
if isinstance(circuit, qobj_mod.QasmQobj):
warnings.warn("Passing in a QASMQobj object to run() is "
"deprecated and will be removed in a future "
"release", DeprecationWarning)
if qobj.config.shots > self.configuration().max_shots:
if circuit.config.shots > self.configuration().max_shots:
raise ValueError('Number of shots is larger than maximum '
'number of shots')
aqt_json = qobj_to_aqt.qobj_to_aqt(
qobj, self._provider.access_token)[0]
elif isinstance(qobj, qobj_mod.PulseQobj):
circuit, self._provider.access_token)[0]
elif isinstance(circuit, qobj_mod.PulseQobj):
raise QiskitError("Pulse jobs are not accepted")
else:
for kwarg in kwargs:
Expand All @@ -230,7 +234,7 @@ def run(self, qobj, **kwargs):
raise ValueError('Number of shots is larger than maximum '
'number of shots')
aqt_json = circuit_to_aqt.circuit_to_aqt(
qobj, self._provider.access_token, shots=out_shots)[0]
circuit, self._provider.access_token, shots=out_shots)[0]
header = {
"Ocp-Apim-Subscription-Key": self._provider.access_token,
"SDK": "qiskit"
Expand All @@ -240,5 +244,5 @@ def run(self, qobj, **kwargs):
response = res.json()
if 'id' not in response:
raise Exception
job = aqt_job.AQTJob(self, response['id'], qobj=qobj)
job = aqt_job.AQTJob(self, response['id'], qobj=circuit)
return job

0 comments on commit 175fe1a

Please sign in to comment.