Skip to content

Commit a44e364

Browse files
committed
Merge branch 'main' into renovate/django-allauth-0.x
2 parents c6167a9 + 3f9f486 commit a44e364

File tree

10 files changed

+130
-30
lines changed

10 files changed

+130
-30
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: Update Component Versions
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
new_version:
7+
description: 'version to update to'
8+
required: true
9+
10+
jobs:
11+
update_component_versions:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
fetch-tags: true
18+
- name: Install helm
19+
shell: bash
20+
run: |
21+
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
22+
- name: Set variables
23+
shell: bash
24+
run: |
25+
NEWNUM=${{ github.event.inputs.new_version }}
26+
OLDTXT=$(git describe --tags $(git rev-list --tags --max-count=1))
27+
OLDNUM="${OLDTXT:1}"
28+
echo "NEWNUM=$NEWNUM" >> "$GITHUB_ENV"
29+
echo "OLDNUM=$OLDNUM" >> "$GITHUB_ENV"
30+
- name: Update observability chart
31+
shell: bash
32+
run: |
33+
sed -i "s/version: ${OLDNUM}/version: ${NEWNUM}/" charts/qs-observability/Chart.yaml
34+
sed -i "s/appVersion: \"${OLDNUM}\"/appVersion: \"${NEWNUM}\"/" charts/qs-observability/Chart.yaml
35+
- name: Update quantum-serverless chart
36+
shell: bash
37+
run: |
38+
sed -i "s/version: ${OLDNUM}/version: ${NEWNUM}/" charts/quantum-serverless/Chart.yaml
39+
sed -i "s/appVersion: \"${OLDNUM}\"/appVersion: \"${NEWNUM}\"/" charts/quantum-serverless/Chart.yaml
40+
sed -i "s/version: ${OLDNUM}/version: ${NEWNUM}/" charts/quantum-serverless/charts/gateway/Chart.yaml
41+
sed -i "s/appVersion: \"${OLDNUM}\"/appVersion: \"${NEWNUM}\"/" charts/quantum-serverless/charts/gateway/Chart.yaml
42+
sed -i "s/ray-node:${OLDNUM}/ray-node:${NEWNUM}/" charts/quantum-serverless/charts/gateway/values.yaml
43+
sed -i "s/version: ${OLDNUM}/version: ${NEWNUM}/" charts/quantum-serverless/charts/jupyter/Chart.yaml
44+
sed -i "s/appVersion: \"${OLDNUM}\"/appVersion: \"${NEWNUM}\"/" charts/quantum-serverless/charts/jupyter/Chart.yaml
45+
sed -i "s/version: ${OLDNUM}/version: ${NEWNUM}/" charts/quantum-serverless/charts/repository/Chart.yaml
46+
sed -i "s/appVersion: \"${OLDNUM}\"/appVersion: \"${NEWNUM}\"/" charts/quantum-serverless/charts/repository/Chart.yaml
47+
sed -i "s/tag: \"${OLDNUM}\"/tag: \"${NEWNUM}\"/" charts/quantum-serverless/values.yaml
48+
sed -i "s/tag: \"${OLDNUM}-py39\"/tag: \"${NEWNUM}-py39\"/" charts/quantum-serverless/values.yaml
49+
sed -i "s/ray-node:${OLDNUM}/ray-node:${NEWNUM}/" charts/quantum-serverless/values.yaml
50+
cd charts/quantum-serverless
51+
helm dependency update
52+
cd -
53+
- name: Update client version
54+
shell: bash
55+
run: |
56+
sed -i "s/${OLDNUM}/${NEWNUM}/" client/quantum_serverless/VERSION.txt
57+
- name: Update compose
58+
shell: bash
59+
run: |
60+
sed -i "s/VERSION:-${OLDNUM}/VERSION:-${NEWNUM}/g" docker-compose.yaml
61+
- name: Update docs
62+
shell: bash
63+
run: |
64+
sed -i "s/${OLDNUM}/${NEWNUM}/g" docs/deployment/cloud.rst
65+
- name: Create PR
66+
id: cpr
67+
uses: peter-evans/create-pull-request@v5
68+
with:
69+
branch: "update-version-${{ github.event.inputs.new_version }}"
70+
title: "update-version-${{ github.event.inputs.new_version }}"

README.md

+13-13
Original file line numberDiff line numberDiff line change
@@ -71,20 +71,18 @@ For user convenience, this section assumes that users will deploy the infrastruc
7171

7272
1. Access the JupyterLab environment
7373
Open `localhost:8888` in your web browser. The default token for the JupyterLab is `123`
74-
1. Write your first example program
75-
In the JupyterLab, create a new file, `program.py`, in the `work` directory.
76-
77-
Save [this example python code](https://qiskit-extensions.github.io/quantum-serverless/quickstart/index.html#id8).
74+
1. Write your first example Qiskit Pattern.
75+
In the JupyterLab, create a new file, `pattern.py`, in the `work` directory. You can include any arbitrary Python code in your program, or you can use the
76+
[example Python file in this tutorial](https://github.com/Qiskit-Extensions/quantum-serverless/blob/main/docs/getting_started/basic/01_running_program.ipynb).
7877

79-
Now, you are ready to run the first program.
8078
1. Run the program
81-
In the JupyterLab, create a new notebook in the same directory as your program, and execute [this python code](https://qiskit-extensions.github.io/quantum-serverless/quickstart/index.html#id9).
79+
In the JupyterLab, create a new notebook in the same directory as your program, and execute [the tutorial code](https://github.com/Qiskit-Extensions/quantum-serverless/blob/main/docs/getting_started/basic/01_running_program.ipynb).
8280

8381
You can check the job status and get the result.
8482

8583
```
8684
job.status()
87-
# <JobStatus.SUCCEEDED: 'SUCCEEDED'>
85+
# 'DONE'
8886

8987
job.logs()
9088
# 2023-09-21 03:48:40,286\tINFO worker.py:1329 -- Using address 172.18.0.4:6379 set in the environment variable RAY_ADDRESS\n2023-09-21 03:48:40,286\tINFO worker.py:1458 -- Connecting to existing Ray cluster at address: 172.18.0.4:6379...\n2023-09-21 03:48:40,295\tINFO worker.py:1633 -- Connected to Ray cluster. View the dashboard at \x1b[1m\x1b[32m172.18.0.4:8265 \x1b[39m\x1b[22m\n
@@ -97,16 +95,18 @@ For user convenience, this section assumes that users will deploy the infrastruc
9795
That's all!
9896
9997
For more detailed examples and explanations refer to the [Guide](https://qiskit-extensions.github.io/quantum-serverless/index.html):
100-
[Getting Started](https://qiskit-extensions.github.io/quantum-serverless/getting_started/index.html#),
101-
[Deployment](https://qiskit-extensions.github.io/quantum-serverless/deployment/index.html),
102-
[Development](https://qiskit-extensions.github.io/quantum-serverless/development/index.html).
98+
99+
1. [Getting Started](https://qiskit-extensions.github.io/quantum-serverless/getting_started/index.html#)
100+
1. [Example Qiskit Patterns](https://qiskit-extensions.github.io/quantum-serverless/examples/index.html)
101+
1. [Infrastructure](https://qiskit-extensions.github.io/quantum-serverless/deployment/index.html)
102+
1. [Migrating from Qiskit Runtime programs](https://qiskit-extensions.github.io/quantum-serverless/migration/index.html)
103103
104104
----------------------------------------------------------------------------------------------------
105105
106106
### How to Give Feedback
107107
108108
We encourage your feedback! You can share your thoughts with us by:
109-
- [Opening an issue](https://github.com/Qiskit-Extensions/quantum-serverless/issues) in the repository
109+
- Opening an [issue](https://github.com/Qiskit-Extensions/quantum-serverless/issues) in the repository
110110
111111
112112
----------------------------------------------------------------------------------------------------
@@ -125,8 +125,8 @@ This project is meant to evolve rapidly and, as such, do not follow [Qiskit's de
125125
----------------------------------------------------------------------------------------------------
126126
127127
## References and Acknowledgements
128-
[1] Qiskit Terra \
129-
https://github.com/Qiskit/qiskit-terra
128+
[1] Qiskit \
129+
https://github.com/Qiskit/qiskit
130130
131131
[2] Client for IBM Qiskit Runtime \
132132
https://github.com/Qiskit/qiskit-ibm-runtime

client/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ Full docs can be found at https://qiskit-extensions.github.io/quantum-serverless
106106

107107
```python
108108
job.status()
109-
# <JobStatus.SUCCEEDED: 'SUCCEEDED'>
109+
# 'DONE'
110110

111111
# or get logs
112112
job.logs()

client/quantum_serverless/core/job.py

+22-5
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def __init__(self, client: JobSubmissionClient):
132132
self._job_client = client
133133

134134
def status(self, job_id: str):
135-
return self._job_client.get_job_status(job_id)
135+
return self._job_client.get_job_status(job_id).value
136136

137137
def stop(self, job_id: str):
138138
return self._job_client.stop_job(job_id)
@@ -611,7 +611,7 @@ def __init__(
611611

612612
def status(self):
613613
"""Returns status of the job."""
614-
return self._job_client.status(self.job_id)
614+
return _map_status_to_serverless(self._job_client.status(self.job_id))
615615

616616
def stop(self):
617617
"""Stops the job from running."""
@@ -634,7 +634,7 @@ def result(self, wait=True, cadence=5, verbose=False):
634634
if wait:
635635
if verbose:
636636
logging.info("Waiting for job result.")
637-
while not self._in_terminal_state():
637+
while not self.in_terminal_state():
638638
time.sleep(cadence)
639639
if verbose:
640640
logging.info(".")
@@ -649,9 +649,9 @@ def result(self, wait=True, cadence=5, verbose=False):
649649

650650
return results
651651

652-
def _in_terminal_state(self) -> bool:
652+
def in_terminal_state(self) -> bool:
653653
"""Checks if job is in terminal state"""
654-
terminal_states = ["STOPPED", "SUCCEEDED", "FAILED"]
654+
terminal_states = ["CANCELED", "DONE", "ERROR"]
655655
return self.status() in terminal_states
656656

657657
def __repr__(self):
@@ -723,3 +723,20 @@ def save_result(result: Dict[str, Any]):
723723
logging.warning("Something went wrong: %s", response.text)
724724

725725
return response.ok
726+
727+
728+
def _map_status_to_serverless(status: str) -> str:
729+
"""Map a status string from job client to the Qiskit terminology."""
730+
status_map = {
731+
"PENDING": "INITIALIZING",
732+
"RUNNING": "RUNNING",
733+
"STOPPED": "CANCELED",
734+
"SUCCEEDED": "DONE",
735+
"FAILED": "ERROR",
736+
"QUEUED": "QUEUED",
737+
}
738+
739+
try:
740+
return status_map[status]
741+
except KeyError:
742+
return status

client/quantum_serverless/serializers/program_serializers.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
import json
3030
import os
3131
from typing import Any, Dict
32-
32+
from qiskit.primitives import SamplerResult, EstimatorResult
3333
from qiskit_ibm_runtime import QiskitRuntimeService
3434
from qiskit_ibm_runtime.utils.json import RuntimeDecoder, RuntimeEncoder
3535

@@ -45,6 +45,16 @@ def default(self, obj: Any) -> Any:
4545
"__type__": "QiskitRuntimeService",
4646
"__value__": obj.active_account(),
4747
}
48+
if isinstance(obj, SamplerResult):
49+
return {
50+
"__type__": "SamplerResult",
51+
"__value__": {"quasi_dists": obj.quasi_dists, "metadata": obj.metadata},
52+
}
53+
if isinstance(obj, EstimatorResult):
54+
return {
55+
"__type__": "EstimatorResult",
56+
"__value__": {"values": obj.values, "metadata": obj.metadata},
57+
}
4858
return super().default(obj)
4959

5060

@@ -57,6 +67,10 @@ def object_hook(self, obj: Any) -> Any:
5767

5868
if obj_type == "QiskitRuntimeService":
5969
return QiskitRuntimeService(**obj["__value__"])
70+
if obj_type == "SamplerResult":
71+
return SamplerResult(**obj["__value__"])
72+
if obj_type == "EstimatorResult":
73+
return EstimatorResult(**obj["__value__"])
6074
return super().object_hook(obj)
6175
return obj
6276

client/requirements-notebook.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ ipywidgets==8.1.1
55
circuit-knitting-toolbox==0.4.0
66
matplotlib==3.7.1
77
qiskit-ibmq-provider==0.20.2
8-
qiskit-aer==0.12.0
8+
qiskit-aer==0.13.0
99
certifi==2023.7.22
1010
ipython==8.13.0

client/requirements.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
ray[default,data]>=2.6.3, <3
22
requests>=2.31.0
33
importlib-metadata>=5.2.0
4-
qiskit>=0.44.1
5-
qiskit-ibm-runtime>=0.12.0
4+
qiskit>=0.44.3
5+
qiskit-ibm-runtime>=0.13.0
66
cloudpickle>=2.2.1
77
tqdm>=4.65.0
88
# opentelemetry

client/tests/core/test_pattern.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""Tests jobs."""
22
import os
33

4-
from ray.dashboard.modules.job.common import JobStatus
54
from testcontainers.compose import DockerCompose
65

76
from quantum_serverless import QuantumServerless, BaseProvider
@@ -49,12 +48,12 @@ def test_program():
4948
wait_for_job_completion(job)
5049

5150
assert "42" in job.logs()
52-
assert job.status().is_terminal()
53-
assert job.status() == JobStatus.SUCCEEDED
51+
assert job.in_terminal_state()
52+
assert job.status() == "DONE"
5453

5554
recovered_job = serverless.get_job_by_id(job.job_id)
5655
assert recovered_job.job_id == job.job_id
5756
assert "42" in recovered_job.logs()
58-
assert recovered_job.status().is_terminal()
59-
assert recovered_job.status() == JobStatus.SUCCEEDED
57+
assert recovered_job.in_terminal_state()
58+
assert recovered_job.status() == "DONE"
6059
assert isinstance(job.stop(), bool)

client/tests/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ def wait_for_job_completion(job: Job, timeout: int = 60):
1818
"""Utility function that waits for job completion."""
1919
must_finish = time.time() + timeout
2020
while time.time() < must_finish:
21-
if job.status().is_terminal():
21+
if job.in_terminal_state():
2222
break
2323
time.sleep(1)

docs/requirements-doc.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ reno>=3.5.0
1515
# the ~= specifier for it.
1616
black[jupyter]~=22.12
1717
sphinx-copybutton>=0.5.2
18-
qiskit-sphinx-theme~=1.15.2
18+
qiskit-sphinx-theme~=1.16.0
1919
tox>=4.0.0

0 commit comments

Comments
 (0)