aqdrop 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
aqdrop-0.0.1/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2026 National Energy Research Scientific Computing Center (NERSC)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
aqdrop-0.0.1/PKG-INFO ADDED
@@ -0,0 +1,23 @@
1
+ Metadata-Version: 2.4
2
+ Name: aqdrop
3
+ Version: 0.0.1
4
+ Summary: Thin client SDK for AQDROP API
5
+ Author-email: Evan Caplinger <ecaplinger@lbl.gov>, Jan Balewski <balewski@lbl.gov>
6
+ License-Expression: MIT
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Requires-Dist: httpx
13
+ Requires-Dist: tabulate
14
+ Requires-Dist: qiskit
15
+ Requires-Dist: qiskit-aer
16
+ Requires-Dist: qiskit-ibm-runtime
17
+ Requires-Dist: quantum-calibration
18
+ Requires-Dist: lbl-qubic
19
+ Dynamic: license-file
20
+
21
+ # AQDROP Client
22
+
23
+ This is a placeholder README. More detailed documentation will be added later.
aqdrop-0.0.1/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # AQDROP Client
2
+
3
+ This is a placeholder README. More detailed documentation will be added later.
@@ -0,0 +1,4 @@
1
+ from main import *
2
+
3
+ __author__ = "Evan Caplinger"
4
+ __version__ = "0.0.1"
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import httpx
5
+ import tabulate
6
+
7
+ from aqdrop import AQDrop
8
+ import creds
9
+
10
+
11
+ def add_args(parser: argparse.ArgumentParser):
12
+ parser.add_argument("--id")
13
+
14
+
15
+ def main(args):
16
+ try:
17
+ job_id = int(args.id)
18
+ except TypeError:
19
+ print("--id must be an integer.")
20
+ exit()
21
+
22
+ c = AQDrop(f"http://{creds.network}:8000")
23
+ c.login(creds.username, creds.password)
24
+
25
+ try:
26
+ job = c.cancel_job(job_id)
27
+ except httpx.HTTPStatusError as e:
28
+ print(f"Could not cancel job.")
29
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}.")
30
+ else:
31
+ print(tabulate.tabulate([job.values()], headers=job.keys()))
32
+
33
+
34
+ if __name__ == "__main__":
35
+ parser = argparse.ArgumentParser()
36
+ add_args(parser)
37
+ args = parser.parse_args()
38
+
39
+ main(args)
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import httpx
5
+ import tabulate
6
+
7
+ from aqdrop import AQDrop
8
+ import creds
9
+
10
+
11
+ def add_args(parser: argparse.ArgumentParser):
12
+ parser.add_argument("--id")
13
+
14
+
15
+ def main(args):
16
+ try:
17
+ job_id = int(args.id)
18
+ except TypeError:
19
+ print("--id must be an integer.")
20
+ exit()
21
+
22
+ c = AQDrop(f"http://{creds.network}:8000")
23
+ c.login(creds.username, creds.password)
24
+
25
+ try:
26
+ job = c.check_job(job_id)
27
+ except httpx.HTTPStatusError as e:
28
+ print(f"Could not check job.")
29
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}.")
30
+ else:
31
+ print(tabulate.tabulate([job.values()], headers=job.keys()))
32
+
33
+
34
+ if __name__ == "__main__":
35
+ parser = argparse.ArgumentParser()
36
+ add_args(parser)
37
+ args = parser.parse_args()
38
+
39
+ main(args)
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import httpx
5
+ import tabulate
6
+
7
+ from aqdrop import AQDrop, defs
8
+ import creds
9
+
10
+
11
+
12
+ def add_args(parser: argparse.ArgumentParser):
13
+ parser.add_argument("--id")
14
+ parser.add_argument("--status", default="success")
15
+ parser.add_argument("--output")
16
+
17
+
18
+ def main(args):
19
+
20
+ try:
21
+ job_id = int(args.id)
22
+ except TypeError:
23
+ print("--id must be an integer.")
24
+ exit()
25
+
26
+ c = AQDrop(creds.network)
27
+ c.login(creds.username, creds.password)
28
+ try:
29
+ job = c.dispatch_job(job_id, defs.JobStatus(args.status), {"message": args.output})
30
+ except httpx.HTTPStatusError as e:
31
+ print(f"Could not dispatch job.")
32
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}.")
33
+ else:
34
+ print(tabulate.tabulate([job.values()], headers=job.keys()))
35
+
36
+
37
+ if __name__ == "__main__":
38
+ parser = argparse.ArgumentParser()
39
+ add_args(parser)
40
+ args = parser.parse_args()
41
+
42
+ main(args)
@@ -0,0 +1,72 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import httpx
5
+ import tabulate
6
+
7
+ from aqdrop import AQDrop
8
+ import creds
9
+
10
+ def trim(s: str, w: int = 80):
11
+ r = ""
12
+ i = 0
13
+ for c in s:
14
+ if i > 0 and i % w == 0:
15
+ r += "\n"
16
+ r += c
17
+ i += 1
18
+ if c == "\n":
19
+ i = 0
20
+ return r
21
+
22
+
23
+
24
+ def add_args(parser: argparse.ArgumentParser):
25
+ parser.add_argument("--id")
26
+
27
+
28
+ def main(args):
29
+
30
+ try:
31
+ job_id = int(args.id)
32
+ except TypeError:
33
+ print("--id must be an integer.")
34
+ exit()
35
+
36
+ c = AQDrop(creds.network)
37
+ c.login(creds.username, creds.password)
38
+
39
+ try:
40
+ job = c.get_job(job_id)
41
+ except httpx.HTTPStatusError as e:
42
+ print(f"Could not get job.")
43
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}.")
44
+ else:
45
+ job_meta = {k: v for k, v in job.items() if not k in ("input", "output")}
46
+ job_in = job["input"]
47
+ job_out = job["output"]
48
+
49
+
50
+ print("\nJOB METADATA")
51
+ print(tabulate.tabulate([job_meta.values()], headers=job_meta.keys()))
52
+
53
+ if job_in is not None:
54
+ print("\nJOB INPUT")
55
+ print(tabulate.tabulate([[k, trim(str(v))] for k, v in job_in.items()], headers=["field", "value"]))
56
+
57
+ if job_out is not None:
58
+ for k, v in job_out.items():
59
+ if type(v) == dict:
60
+ job_out[k] = tabulate.tabulate([[kk, vv] for kk, vv in v.items()], tablefmt="plain")
61
+ print("\nJOB OUTPUT")
62
+ print(tabulate.tabulate([[k, trim(str(v))] for k, v in job_out.items()], headers=["field", "value"]))
63
+
64
+ print()
65
+
66
+
67
+ if __name__ == "__main__":
68
+ parser = argparse.ArgumentParser()
69
+ add_args(parser)
70
+ args = parser.parse_args()
71
+
72
+ main(args)
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import pprint
5
+ import tabulate
6
+
7
+ from aqdrop import AQDrop
8
+ import creds
9
+
10
+
11
+
12
+ def add_args(parser: argparse.ArgumentParser):
13
+ parser.add_argument("--queue")
14
+
15
+
16
+ def main(args):
17
+
18
+ c = AQDrop(creds.network)
19
+ c.login(creds.username, creds.password)
20
+ jobs = c.query_jobs(queue_name=args.queue)
21
+
22
+ print(f"Found {len(jobs)} jobs.")
23
+ if len(jobs) > 0:
24
+ print(tabulate.tabulate([j.values() for j in jobs], headers=jobs[0].keys()))
25
+
26
+
27
+ if __name__ == "__main__":
28
+ parser = argparse.ArgumentParser()
29
+ add_args(parser)
30
+ args = parser.parse_args()
31
+
32
+ main(args)
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import pprint
5
+ import tabulate
6
+ import httpx
7
+ import tempfile
8
+ import base64
9
+
10
+ from aqdrop import AQDrop, defs
11
+ import creds
12
+
13
+ from qiskit import QuantumCircuit, qpy
14
+ from qiskit_aer import AerSimulator
15
+ from qiskit_ibm_runtime.fake_provider import FakeFez
16
+
17
+
18
+ def add_args(parser: argparse.ArgumentParser):
19
+ parser.add_argument("--id")
20
+
21
+
22
+ def main(args):
23
+
24
+ try:
25
+ job_id = int(args.id)
26
+ except TypeError:
27
+ print("--id must be an integer.")
28
+ exit()
29
+
30
+ c = AQDrop(creds.network)
31
+ c.login(creds.username, creds.password)
32
+
33
+ try:
34
+ job = c.get_job(args.id)
35
+
36
+ status = defs.JobStatus.SUCCESS
37
+ output_dd = {}
38
+
39
+ with tempfile.NamedTemporaryFile(delete_on_close=False) as tf:
40
+ print(job["input"]["qpy"])
41
+ b = base64.b64decode(job["input"]["qpy"])
42
+ tf.write(b)
43
+ tf.close()
44
+ with open(tf.name, 'rb') as tfr:
45
+ qc = qpy.load(tfr)[0]
46
+
47
+ try:
48
+ nshots: int = int(job["input"]["shots"])
49
+ except ValueError:
50
+ status = defs.JobStatus.FAILED
51
+ output_dd["message"] = f"misformatted field 'shots'; must be int, got {job['input']['shots']}"
52
+ c.dispatch_job(job_id, status, output_dd)
53
+ exit()
54
+
55
+ if job["queue_name"] == "noisy":
56
+ sim = FakeFez()
57
+ else:
58
+ sim = AerSimulator()
59
+
60
+ qcr = sim.run(qc, shots=nshots).result()
61
+ output_dd["counts"] = qcr.get_counts()
62
+
63
+ c.dispatch_job(job_id, status, output_dd)
64
+ except httpx.HTTPStatusError as e:
65
+ print(f"Job submission failed.")
66
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}.")
67
+ else:
68
+ print(f"Job dispatch successful.") # TODO: print some info about job output
69
+
70
+
71
+ if __name__ == "__main__":
72
+ parser = argparse.ArgumentParser()
73
+ add_args(parser)
74
+ args = parser.parse_args()
75
+
76
+ main(args)
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import pprint
5
+ import tabulate
6
+ import httpx
7
+ import tempfile
8
+ import base64
9
+
10
+ from aqdrop import AQDrop, defs
11
+ import creds
12
+
13
+ from qiskit import QuantumCircuit, qpy
14
+ from qiskit_aer import AerSimulator
15
+ from qiskit_ibm_runtime.fake_provider import FakeFez
16
+
17
+
18
+ def add_args(parser: argparse.ArgumentParser):
19
+ parser.add_argument("--id")
20
+
21
+
22
+ def main(args):
23
+
24
+ try:
25
+ job_id = int(args.id)
26
+ except TypeError:
27
+ print("--id must be an integer.")
28
+ exit()
29
+
30
+ c = AQDrop(creds.network, operator=True)
31
+ c.login(creds.username, creds.password)
32
+
33
+ try:
34
+ c.run_job(args.id)
35
+ except httpx.HTTPStatusError as e:
36
+ print(f"Job submission failed.")
37
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}.")
38
+ else:
39
+ print(f"Job dispatch successful.") # TODO: print some info about job output
40
+
41
+
42
+ if __name__ == "__main__":
43
+ parser = argparse.ArgumentParser()
44
+ add_args(parser)
45
+ args = parser.parse_args()
46
+
47
+ main(args)
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import pprint
5
+ import tabulate
6
+ import httpx
7
+ import tempfile
8
+ import base64
9
+
10
+ from aqdrop import AQDrop
11
+ import creds
12
+
13
+ from qiskit import QuantumCircuit, qpy
14
+
15
+
16
+
17
+ def add_args(parser: argparse.ArgumentParser):
18
+ parser.add_argument("--queue", default="ideal")
19
+
20
+
21
+ def main(args):
22
+
23
+ c = AQDrop(creds.network)
24
+ c.login(creds.username, creds.password)
25
+
26
+ qc = QuantumCircuit(2, 2)
27
+ qc.h(0)
28
+ qc.cx(0,1)
29
+ qc.measure(0,0)
30
+ qc.measure(1,1)
31
+
32
+ with tempfile.NamedTemporaryFile(delete_on_close=False) as tf:
33
+ qpy.dump(qc, tf)
34
+ tf.close()
35
+ with open(tf.name, 'rb') as tfr:
36
+ b = base64.b64encode(tfr.read())
37
+
38
+ job_dd = {
39
+ 'qpy': b.decode(),
40
+ 'shots': 1024
41
+ }
42
+
43
+ try:
44
+ submitted = c.submit_job(args.queue, job_dd)
45
+ except httpx.HTTPStatusError as e:
46
+ print(f"Job submission failed.")
47
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}.")
48
+ else:
49
+ print(f"Job submission successful; assigned job ID {submitted['id']}.")
50
+
51
+
52
+ if __name__ == "__main__":
53
+ parser = argparse.ArgumentParser()
54
+ add_args(parser)
55
+ args = parser.parse_args()
56
+
57
+ main(args)
@@ -0,0 +1,36 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import pprint
5
+ import tabulate
6
+ import httpx
7
+
8
+ from aqdrop import AQDrop
9
+ import creds
10
+
11
+
12
+
13
+ def add_args(parser: argparse.ArgumentParser):
14
+ parser.add_argument("--queue")
15
+ parser.add_argument("--task")
16
+
17
+
18
+ def main(args):
19
+
20
+ c = AQDrop(f"http://{creds.network}:8000")
21
+ c.login(creds.username, creds.password)
22
+ try:
23
+ submitted = c.submit_job(args.queue, args.task)
24
+ except httpx.HTTPStatusError as e:
25
+ print(f"Job submission failed.")
26
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}.")
27
+ else:
28
+ print(f"Job submission successful; assigned job ID {submitted['id']}.")
29
+
30
+
31
+ if __name__ == "__main__":
32
+ parser = argparse.ArgumentParser()
33
+ add_args(parser)
34
+ args = parser.parse_args()
35
+
36
+ main(args)
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import pprint
5
+ import tabulate
6
+ import httpx
7
+ import tempfile
8
+ import base64
9
+
10
+ from aqdrop import AQDrop
11
+ import creds
12
+
13
+ from qiskit import QuantumCircuit, qpy
14
+
15
+
16
+
17
+ def add_args(parser: argparse.ArgumentParser):
18
+ parser.add_argument("--queue", default="ideal")
19
+ parser.add_argument("--bits", default="4")
20
+
21
+
22
+ def main(args):
23
+
24
+ try:
25
+ bits = int(args.bits)
26
+ except ValueError:
27
+ print("--bits must be an integer.")
28
+ exit()
29
+ if bits < 2:
30
+ print("--bits must be at least 2.")
31
+ exit()
32
+
33
+ c = AQDrop(creds.network)
34
+ c.login(creds.username, creds.password)
35
+
36
+ qc = QuantumCircuit(bits)
37
+ qc.h(0)
38
+ for i in range(bits - 1):
39
+ qc.cx(i, i+1)
40
+ qc.measure_all()
41
+
42
+ print(qc.draw())
43
+
44
+ with tempfile.NamedTemporaryFile(delete_on_close=False) as tf:
45
+ qpy.dump(qc, tf)
46
+ tf.close()
47
+ with open(tf.name, 'rb') as tfr:
48
+ b = base64.b64encode(tfr.read())
49
+
50
+ job_dd = {
51
+ 'qpy': b.decode(),
52
+ 'shots': 1024
53
+ }
54
+
55
+ try:
56
+ submitted = c.submit_job(args.queue, job_dd)
57
+ except httpx.HTTPStatusError as e:
58
+ print(f"Job submission failed.")
59
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}.")
60
+ else:
61
+ print(f"Job submission successful; assigned job ID {submitted['id']}.")
62
+
63
+
64
+ if __name__ == "__main__":
65
+ parser = argparse.ArgumentParser()
66
+ add_args(parser)
67
+ args = parser.parse_args()
68
+
69
+ main(args)
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import pprint
5
+ import httpx
6
+
7
+ from aqdrop import AQDrop
8
+ import creds
9
+
10
+
11
+ def add_args(parser):
12
+ parser.add_argument("--name")
13
+ parser.add_argument("--email", default=None)
14
+
15
+
16
+ def main(args):
17
+ parser.add_argument("--name")
18
+ parser.add_argument("--email", default=None)
19
+ args = parser.parse_args()
20
+
21
+ c = AQDrop(creds.network)
22
+
23
+ c.login(creds.username, creds.password)
24
+
25
+ try:
26
+ output = c.create_member(args.name, args.email)
27
+ except httpx.HTTPStatusError as e:
28
+ print(f"Could not create member.")
29
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}")
30
+ else:
31
+ # print out properly formatted .creds file to stdout so we can route it into a file
32
+ print("#!/usr/bin/bash")
33
+ print(f"export AQDROP_USERNAME={args.name}")
34
+ print(f"export AQDROP_PASSWORD={output['password']}")
35
+ print(f"export AQDROP_EMAIL={args.email}")
36
+ print(f"export AQDROP_HOST_NAME={creds.network}")
37
+
38
+
39
+ if __name__ == "__main__":
40
+ parser = argparse.ArgumentParser()
41
+ add_args(parser)
42
+ args = parser.parse_args()
43
+
44
+ main(args)
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env python3
2
+
3
+ import argparse
4
+ import httpx
5
+ import tabulate
6
+
7
+ from aqdrop import AQDrop
8
+ import creds
9
+
10
+
11
+ def add_args(parser: argparse.ArgumentParser):
12
+ parser.add_argument("--skip")
13
+ parser.add_argument("--limit")
14
+
15
+
16
+ def main(args):
17
+
18
+ try:
19
+ skip = int(args.skip)
20
+ except TypeError:
21
+ print("--skip must be an integer.")
22
+ exit()
23
+
24
+ try:
25
+ limit = int(args.limit)
26
+ except TypeError:
27
+ print("--limit must be an integer.")
28
+ exit()
29
+
30
+ c = AQDrop(f"http://{creds.network}:8000")
31
+ c.login(creds.username, creds.password)
32
+
33
+ try:
34
+ members = c.list_members(limit=limit, skip=skip)
35
+ except httpx.HTTPStatusError as e:
36
+ print(f"Could not list members.")
37
+ print(f"Error {e.response.status_code}: {e.response.json()['detail']}.")
38
+ else:
39
+ print(tabulate.tabulate([member.values() for member in members], headers=members[0].keys()))
40
+
41
+
42
+ if __name__ == "__main__":
43
+ parser = argparse.ArgumentParser()
44
+ add_args(parser)
45
+ args = parser.parse_args()
46
+
47
+ main(args)