diff --git a/app/__init__.py b/app/__init__.py
index 2c016a6..e14531d 100644
--- a/app/__init__.py
+++ b/app/__init__.py
@@ -16,6 +16,6 @@ def create_app(config_name="default"):
@app.route("/")
def heartbeat():
- return '
The Error-Mitigation Service is Running
View the API Docs here
'
+ return 'The Error-Mitigation Service is Running
View the API Docs here
'
return app
diff --git a/config.py b/config.py
index 6d8892d..8125742 100644
--- a/config.py
+++ b/config.py
@@ -14,8 +14,7 @@ class Config:
API_SPEC_OPTIONS = {
"info": {
- "description": "This is the API Specification of the Readout Error Mitigation Service("
- "https://readthedocs/readout-error-mitigation-service/TOBERELEASED).",
+ "description": "This is the API Specification of the Readout Error Mitigation Service",
},
"license": {"name": "Apache v2 License"},
}
diff --git a/requirements.txt b/requirements.txt
index 47426f5..55e74ce 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -7,8 +7,10 @@ marshmallow==3.13.0
minio==7.1.3
mthree==1.0.0
pyquil==3.0.1
-qiskit==0.37.1
+qiskit==0.44.1
qiskit_ionq==0.1.4
symengine==0.9
Werkzeug==2.0.1
-qiskit-ignis==0.6.0
\ No newline at end of file
+qiskit-ignis==0.6.0
+qiskit_aer==0.12.2
+qiskit_ibm_provider==0.7.1
\ No newline at end of file
diff --git a/tests/test_client.py b/tests/test_client.py
index 6d95903..6d89302 100644
--- a/tests/test_client.py
+++ b/tests/test_client.py
@@ -3,6 +3,9 @@
import json
import re
+from qiskit import IBMQ
+from tests.utils_test import get_available_qpu
+
parent_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
sys.path.append(parent_dir)
from app import create_app
@@ -23,18 +26,19 @@ def test_app_running(self):
self.assertEqual(response.status_code, 200)
def test_cm_noisy_simulator(self):
- token = os.environ["TOKEN"]
+ credentials = {"token": os.environ["TOKEN"]}
+ backend = get_available_qpu(credentials)
response = self.client.post(
"/cm/",
data=json.dumps(
{
"provider": "IBM",
"qpu": "aer_qasm_simulator",
- "credentials": {"token": token},
+ "credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"shots": 1000,
- "noise_model": "ibmq_lima",
+ "noise_model": backend,
"only_measurement_errors": False,
}
),
@@ -44,24 +48,29 @@ def test_cm_noisy_simulator(self):
self.assertTrue(".pkl" in response.json)
response_get = self.client.get(
- "/cm/?noise_model=ibmq_lima&cm_gen_method=standard&qpu=aer_qasm_simulator&qubits=0&qubits=1&qubits=2&qubits=3&qubits=4&max_age=360"
+ "/cm/?noise_model=" + backend +
+ "&cm_gen_method=" + "standard" +
+ "&qpu=aer_qasm_simulator" +
+ "&qubits=0&qubits=1&qubits=2&qubits=3&qubits=4"+
+ "&max_age=360"
)
self.assertEqual(response_get.status_code, 200)
self.assertEqual(len(response_get.json), 32)
def test_cm_tpnm_noisy_simulator(self):
- token = os.environ["TOKEN"]
+ credentials = {"token": os.environ["TOKEN"]}
+ backend = get_available_qpu(credentials)
response = self.client.post(
"/cm/",
data=json.dumps(
{
"provider": "IBM",
"qpu": "aer_qasm_simulator",
- "credentials": {"token": token},
+ "credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "tpnm",
"shots": 1000,
- "noise_model": "ibmq_lima",
+ "noise_model": backend,
"only_measurement_errors": False,
}
),
@@ -113,18 +122,19 @@ def test_gen_from_counts(self):
self.assertTrue(".pkl" in response.json)
def test_cm_noisy_simulator_only_measure(self):
- token = os.environ["TOKEN"]
+ credentials = {"token": os.environ["TOKEN"]}
+ backend = get_available_qpu(credentials)
response = self.client.post(
"/cm/",
data=json.dumps(
{
"provider": "IBM",
"qpu": "aer_qasm_simulator",
- "credentials": {"token": token},
+ "credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"shots": 1000,
- "noise_model": "ibmq_lima",
+ "noise_model": backend,
"only_measurement_errors": "True",
}
),
@@ -134,19 +144,20 @@ def test_cm_noisy_simulator_only_measure(self):
self.assertTrue(".pkl" in response.json)
def test_mm_noisy_simulator(self):
- token = os.environ["TOKEN"]
+ credentials = {"token": os.environ["TOKEN"]}
+ backend = get_available_qpu(credentials)
response = self.client.post(
"/mm/",
data=json.dumps(
{
"provider": "IBM",
"qpu": "aer_qasm_simulator",
- "credentials": {"token": token},
+ "credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "inversion",
"shots": 1000,
- "noise_model": "ibmq_lima",
+ "noise_model": backend,
"only_measurement_errors": False,
"max_age": 0,
}
@@ -157,19 +168,20 @@ def test_mm_noisy_simulator(self):
self.assertTrue(".pkl" in response.json)
def test_mm_noisy_simulator_only_measure(self):
- token = os.environ["TOKEN"]
+ credentials = {"token": os.environ["TOKEN"]}
+ backend = get_available_qpu(credentials)
response = self.client.post(
"/mm/",
data=json.dumps(
{
"provider": "IBM",
"qpu": "aer_qasm_simulator",
- "credentials": {"token": token},
+ "credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "inversion",
"shots": 1000,
- "noise_model": "ibmq_lima",
+ "noise_model": backend,
"only_measurement_errors": "True",
}
),
@@ -179,13 +191,19 @@ def test_mm_noisy_simulator_only_measure(self):
self.assertTrue(".pkl" in response.json)
response_get = self.client.get(
- "/mm/?noise_model=ibmq_lima&cm_gen_method=standard&mitigation_method=inversion&qpu=aer_qasm_simulator&qubits=0&qubits=1&qubits=2&qubits=3&qubits=4&max_age=360"
+ "/mm/?noise_model=" + backend +
+ "&cm_gen_method=standard" +
+ "&mitigation_method=inversion" +
+ "&qpu=aer_qasm_simulator" +
+ "&qubits=0&qubits=1&qubits=2&qubits=3&qubits=4"+
+ "&max_age=360"
)
self.assertEqual(response_get.status_code, 200)
self.assertEqual(len(response_get.json), 32)
def test_rem_noisy_simulator_only_measure_standard_inversion(self):
- token = os.environ["TOKEN"]
+ credentials = {"token": os.environ["TOKEN"]}
+ backend = get_available_qpu(credentials)
response = self.client.post(
"/rem/",
data=json.dumps(
@@ -225,12 +243,12 @@ def test_rem_noisy_simulator_only_measure_standard_inversion(self):
},
"provider": "IBM",
"qpu": "aer_qasm_simulator",
- "credentials": {"token": token},
+ "credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "inversion",
"shots": 1000,
- "noise_model": "ibmq_lima",
+ "noise_model": backend,
"only_measurement_errors": "True",
"max_age": 0,
}
@@ -241,7 +259,8 @@ def test_rem_noisy_simulator_only_measure_standard_inversion(self):
self.assertTrue("11110" in response.json.keys())
def test_rem_noisy_simulator_only_measure_standard_inversion_reuse_mitigator(self):
- token = os.environ["TOKEN"]
+ credentials = {"token": os.environ["TOKEN"]}
+ backend = get_available_qpu(credentials)
response = self.client.post(
"/rem/",
data=json.dumps(
@@ -281,12 +300,12 @@ def test_rem_noisy_simulator_only_measure_standard_inversion_reuse_mitigator(sel
},
"provider": "IBM",
"qpu": "aer_qasm_simulator",
- "credentials": {"token": token},
+ "credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "inversion",
"shots": 1000,
- "noise_model": "ibmq_lima",
+ "noise_model": backend,
"only_measurement_errors": "True",
"max_age": 300,
}
@@ -297,7 +316,8 @@ def test_rem_noisy_simulator_only_measure_standard_inversion_reuse_mitigator(sel
self.assertTrue("11110" in response.json.keys())
def test_rem_noisy_simulator_only_measure_ignis(self):
- token = os.environ["TOKEN"]
+ credentials = {"token": os.environ["TOKEN"]}
+ backend = get_available_qpu(credentials)
response = self.client.post(
"/rem/",
data=json.dumps(
@@ -337,12 +357,12 @@ def test_rem_noisy_simulator_only_measure_ignis(self):
},
"provider": "IBM",
"qpu": "aer_qasm_simulator",
- "credentials": {"token": token},
+ "credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "ignis",
"shots": 1000,
- "noise_model": "ibmq_lima",
+ "noise_model": backend,
"only_measurement_errors": "True",
"max_age": 0,
}
@@ -353,7 +373,8 @@ def test_rem_noisy_simulator_only_measure_ignis(self):
self.assertTrue("11110" in response.json.keys())
def test_rem_noisy_simulator_only_measure_bayes(self):
- token = os.environ["TOKEN"]
+ credentials = {"token": os.environ["TOKEN"]}
+ backend = get_available_qpu(credentials)
response = self.client.post(
"/rem/",
data=json.dumps(
@@ -393,12 +414,12 @@ def test_rem_noisy_simulator_only_measure_bayes(self):
},
"provider": "IBM",
"qpu": "aer_qasm_simulator",
- "credentials": {"token": token},
+ "credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"cm_gen_method": "standard",
"mitigation_method": "bayes",
"shots": 1000,
- "noise_model": "ibmq_lima",
+ "noise_model": backend,
"only_measurement_errors": "True",
"max_age": 0,
}
@@ -409,7 +430,8 @@ def test_rem_noisy_simulator_only_measure_bayes(self):
self.assertTrue("11110" in response.json.keys())
def test_rem_noisy_simulator_only_measure_tpnm(self):
- token = os.environ["TOKEN"]
+ credentials = {"token": os.environ["TOKEN"]}
+ backend = get_available_qpu(credentials)
response = self.client.post(
"/rem/",
data=json.dumps(
@@ -449,11 +471,11 @@ def test_rem_noisy_simulator_only_measure_tpnm(self):
},
"provider": "IBM",
"qpu": "aer_qasm_simulator",
- "credentials": {"token": token},
+ "credentials": credentials,
"qubits": [0, 1, 2, 3, 4],
"mitigation_method": "tpnm",
"shots": 1000,
- "noise_model": "ibmq_lima",
+ "noise_model": backend,
"only_measurement_errors": "True",
"max_age": 0,
}
diff --git a/tests/utils_test.py b/tests/utils_test.py
new file mode 100644
index 0000000..baad376
--- /dev/null
+++ b/tests/utils_test.py
@@ -0,0 +1,8 @@
+from qiskit_ibm_provider import IBMProvider
+
+def get_available_qpu(credentials):
+ provider = IBMProvider(**credentials)
+ backends = provider.backends()
+ for backend in backends:
+ if 'simulator' not in backend.name:
+ return backend.name
\ No newline at end of file