Skip to content

Commit

Permalink
Merge branch 'data-folder' into trace-decorator
Browse files Browse the repository at this point in the history
# Conflicts:
#	client/qiskit_serverless/core/files.py
  • Loading branch information
korgan00 committed Dec 20, 2024
2 parents dbc8129 + 97fe205 commit 11b41a3
Show file tree
Hide file tree
Showing 26 changed files with 564 additions and 243 deletions.
41 changes: 0 additions & 41 deletions .github/workflows/notebook-local-verify.yaml

This file was deleted.

6 changes: 3 additions & 3 deletions charts/qiskit-serverless/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dependencies:
- name: gateway
repository: ""
version: 0.18.0
version: 0.18.1
- name: nginx-ingress-controller
repository: https://charts.bitnami.com/bitnami
version: 9.11.0
Expand All @@ -11,5 +11,5 @@ dependencies:
- name: kuberay-operator
repository: https://ray-project.github.io/kuberay-helm
version: 1.1.1
digest: sha256:235cd506a12feb47413a0d091f440ae195d19aa7040a1cae1e4cb7e8e8e6144a
generated: "2024-11-04T13:26:38.419438091Z"
digest: sha256:d94ff7fe13a35912b401f0487f0b42715fc63defad450c6f882cdebc9f916155
generated: "2024-12-16T14:18:23.162250097Z"
6 changes: 3 additions & 3 deletions charts/qiskit-serverless/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ description: Qiskit-Serverless helm chart that contains different dependencies.

type: application

version: 0.18.0
appVersion: "0.18.0"
version: 0.18.1
appVersion: "0.18.1"

dependencies:
- name: gateway
condition: gatewayEnable
version: 0.18.0
version: 0.18.1
- name: nginx-ingress-controller
condition: nginxIngressControllerEnable
version: 9.11.0
Expand Down
4 changes: 2 additions & 2 deletions charts/qiskit-serverless/charts/gateway/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.18.0
version: 0.18.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "0.18.0"
appVersion: "0.18.1"
4 changes: 2 additions & 2 deletions charts/qiskit-serverless/charts/gateway/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ application:
superuser:
enable: true
ray:
nodeImage: "icr.io/quantum-public/qiskit-serverless/ray-node:0.18.0"
nodeImage: "icr.io/quantum-public/qiskit-serverless/ray-node:0.18.1"
cpu: 2
memory: 2
gpu: 1
Expand All @@ -27,7 +27,7 @@ application:
maxReplicas: 4
opensslImage: registry.access.redhat.com/ubi8/openssl:8.8-9
kubectlImage: alpine/k8s:1.29.2@sha256:a51aa37f0a34ff827c7f2f9cb7f6fbb8f0e290fa625341be14c2fcc4b1880f60
proxyImage: "icr.io/quantum-public/qiskit-serverless/proxy:0.18.0"
proxyImage: "icr.io/quantum-public/qiskit-serverless/proxy:0.18.1"
scrapeWithPrometheus: true
openTelemetry: false
openTelemetryCollector:
Expand Down
6 changes: 3 additions & 3 deletions charts/qiskit-serverless/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Qiskit Serverless Info
# ===================
global:
version: 0.18.0
version: 0.18.1

# ===================
# Qiskit Serverless configs
Expand Down Expand Up @@ -47,7 +47,7 @@ gateway:
image:
repository: "icr.io/quantum-public/qiskit-serverless/gateway"
pullPolicy: IfNotPresent
tag: "0.18.0"
tag: "0.18.1"
application:
siteHost: "http://gateway:8000"
rayHost: "http://kuberay-head-svc:8265"
Expand All @@ -59,7 +59,7 @@ gateway:
type: ClusterIP
port: 8000
ray:
nodeImage: "icr.io/quantum-public/qiskit-serverless/ray-node:0.18.0"
nodeImage: "icr.io/quantum-public/qiskit-serverless/ray-node:0.18.1"
opensslImage: registry.access.redhat.com/ubi8/openssl:8.8-9
kubectlImage: alpine/k8s:1.29.2@sha256:a51aa37f0a34ff827c7f2f9cb7f6fbb8f0e290fa625341be14c2fcc4b1880f60
gpuJobsConfig: "/tmp/gpujobs/gpu-jobs.json"
Expand Down
2 changes: 1 addition & 1 deletion client/qiskit_serverless/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.18.0
0.18.1
14 changes: 11 additions & 3 deletions client/qiskit_serverless/core/clients/local_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
from qiskit_ibm_runtime import QiskitRuntimeService

from qiskit_serverless.core.constants import (
JOB_ARGUMENTS_FILE,
OT_PROGRAM_NAME,
ENV_JOB_ARGUMENTS,
)
from qiskit_serverless.core.client import BaseClient
from qiskit_serverless.core.job import (
Expand Down Expand Up @@ -112,11 +112,16 @@ def run(
**(saved_program.env_vars or {}),
**{OT_PROGRAM_NAME: saved_program.title},
**{"PATH": os.environ["PATH"]},
**{ENV_JOB_ARGUMENTS: json.dumps(arguments, cls=QiskitObjectsEncoder)},
}

with open(JOB_ARGUMENTS_FILE, "w", encoding="utf-8") as f:
json.dump(arguments, f, cls=QiskitObjectsEncoder)

with Popen(
["python", saved_program.working_dir + saved_program.entrypoint],
[
"python",
os.path.join(saved_program.working_dir, saved_program.entrypoint),
],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
Expand All @@ -126,6 +131,9 @@ def run(
if pipe.wait():
status = "FAILED"
output, _ = pipe.communicate()

os.remove(JOB_ARGUMENTS_FILE)

results = re.search("\nSaved Result:(.+?):End Saved Result\n", output)
result = ""
if results:
Expand Down
10 changes: 8 additions & 2 deletions client/qiskit_serverless/core/clients/serverless_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,15 @@ def file_delete(self, file: str, provider: Optional[str] = None):
"""Deletes file uploaded or produced by the programs,"""
return self._files_client.delete(file, provider)

def file_upload(self, file: str, provider: Optional[str] = None):
def file_upload(
self, file: str, function: QiskitFunction, provider: Optional[str] = None
):
"""Upload file."""
return self._files_client.upload(file, function, provider)

def provider_file_upload(self, file: str, function: QiskitFunction, provider: str):
"""Upload file."""
return self._files_client.upload(file, provider)
return self._files_client.provider_upload(file, function, provider)


class IBMServerlessClient(ServerlessClient):
Expand Down
2 changes: 2 additions & 0 deletions client/qiskit_serverless/core/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
ENV_JOB_ID_GATEWAY = "ENV_JOB_ID_GATEWAY"
ENV_JOB_ARGUMENTS = "ENV_JOB_ARGUMENTS"

JOB_ARGUMENTS_FILE = "arguments.serverless"

# artifact
MAX_ARTIFACT_FILE_SIZE_MB = 50
MAX_ARTIFACT_FILE_SIZE_MB_OVERRIDE = "MAX_ARTIFACT_FILE_SIZE_MB_OVERRIDE"
Expand Down
25 changes: 23 additions & 2 deletions client/qiskit_serverless/core/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,34 @@ def provider_download(
)

@_trace
def upload(self, file: str, provider: Optional[str] = None) -> Optional[str]:
def upload(
self, file: str, function: QiskitFunction, provider: Optional[str] = None
) -> Optional[str]:
"""Uploads file."""
with open(file, "rb") as f:
with requests.post(
os.path.join(self._files_url, "upload"),
files={"file": f},
data={"provider": provider},
params={"provider": provider, "function": function.title},
stream=True,
headers={"Authorization": f"Bearer {self._token}"},
timeout=REQUESTS_STREAMING_TIMEOUT,
) as req:
if req.ok:
return req.text
return "Upload failed"
return "Can not open file"

@_trace
def provider_upload(
self, file: str, function: QiskitFunction, provider: str
) -> Optional[str]:
"""Uploads file to provider/function file storage."""
with open(file, "rb") as f:
with requests.post(
os.path.join(self._files_url, "upload"),
files={"file": f},
params={"provider": provider, "function": function.title},
stream=True,
headers={"Authorization": f"Bearer {self._token}"},
timeout=REQUESTS_STREAMING_TIMEOUT,
Expand Down
6 changes: 4 additions & 2 deletions client/qiskit_serverless/serializers/program_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit_ibm_runtime.utils.json import RuntimeDecoder, RuntimeEncoder

from qiskit_serverless.core.constants import JOB_ARGUMENTS_FILE


class QiskitObjectsEncoder(RuntimeEncoder):
"""Json encoder for Qiskit objects."""
Expand Down Expand Up @@ -80,7 +82,7 @@ def get_arguments() -> Dict[str, Any]:
Dictionary of arguments.
"""
arguments = "{}"
if os.path.isfile("arguments.serverless"):
with open("arguments.serverless", "r", encoding="utf-8") as f:
if os.path.isfile(JOB_ARGUMENTS_FILE):
with open(JOB_ARGUMENTS_FILE, "r", encoding="utf-8") as f:
arguments = f.read()
return json.loads(arguments, cls=QiskitObjectsDecoder)
3 changes: 2 additions & 1 deletion client/tests/serializers/test_program_serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from qiskit.circuit.random import random_circuit
from qiskit_ibm_runtime import QiskitRuntimeService

from qiskit_serverless.core.constants import JOB_ARGUMENTS_FILE
from qiskit_serverless.serializers.program_serializers import (
QiskitObjectsDecoder,
QiskitObjectsEncoder,
Expand Down Expand Up @@ -59,7 +60,7 @@ def test_argument_parsing(self):
circuit = random_circuit(4, 2)
array = np.array([[42.0], [0.0]])

with open("arguments.serverless", "w", encoding="utf-8") as f:
with open(JOB_ARGUMENTS_FILE, "w", encoding="utf-8") as f:
json.dump({"circuit": circuit, "array": array}, f, cls=QiskitObjectsEncoder)

parsed_arguments = get_arguments()
Expand Down
6 changes: 3 additions & 3 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
ray-head:
user: "0"
container_name: ray-head
image: icr.io/quantum-public/qiskit-serverless/ray-node:${VERSION:-0.18.0}
image: icr.io/quantum-public/qiskit-serverless/ray-node:${VERSION:-0.18.1}
entrypoint: [
"ray", "start", "--head", "--port=6379",
"--dashboard-host=0.0.0.0", "--block"
Expand All @@ -28,7 +28,7 @@ services:
always
gateway:
container_name: gateway
image: icr.io/quantum-public/qiskit-serverless/gateway:${VERSION:-0.18.0}
image: icr.io/quantum-public/qiskit-serverless/gateway:${VERSION:-0.18.1}
command: gunicorn main.wsgi:application --bind 0.0.0.0:8000 --workers=4
ports:
- 8000:8000
Expand All @@ -53,7 +53,7 @@ services:
- postgres
scheduler:
container_name: scheduler
image: icr.io/quantum-public/qiskit-serverless/gateway:${VERSION:-0.18.0}
image: icr.io/quantum-public/qiskit-serverless/gateway:${VERSION:-0.18.1}
entrypoint: "./scripts/scheduler.sh"
environment:
- DEBUG=0
Expand Down
4 changes: 2 additions & 2 deletions docs/deployment/cloud.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Once your cluster is ready, the installation is relatively straightforward with
and run the next commands:

.. code-block::
:caption: run this commands with the release version like 0.18.0 in x.y.z (2 places)
:caption: run this commands with the release version like 0.18.1 in x.y.z (2 places)
$ helm -n <INSERT_YOUR_NAMESPACE> install qiskit-serverless --create-namespace https://github.com/Qiskit/qiskit-serverless/releases/download/vx.y.z/qiskit-serverless-x.y.z.tgz
Expand Down Expand Up @@ -119,6 +119,6 @@ with the configuration of your domain and provider.
Optionally, you can install an observability package to handle logging and monitoring on your cluster by running the following command:

.. code-block::
:caption: run this commands with the release version like 0.18.0 in x.y.z (2 places) using the same namespace as in the previous helm command
:caption: run this commands with the release version like 0.18.1 in x.y.z (2 places) using the same namespace as in the previous helm command
$ helm -n <INSERT_YOUR_NAMESPACE> install qs-observability https://github.com/Qiskit/qiskit-serverless/releases/download/vx.y.z/qs-observability-x.y.z.tgz
2 changes: 1 addition & 1 deletion docs/deployment/custom_function/Sample-Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM icr.io/quantum-public/qiskit-serverless/ray-node:0.18.0
FROM icr.io/quantum-public/qiskit-serverless/ray-node:0.18.1

# install all necessary dependencies for your custom image

Expand Down
5 changes: 3 additions & 2 deletions docs/deployment/deploying_custom_image_function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ In our simple case it will look something like this:
.. code-block::
:caption: Dockerfile for custom image function.
FROM icr.io/quantum-public/qiskit-serverless/ray-node:0.18.0
FROM icr.io/quantum-public/qiskit-serverless/ray-node:0.18.1
# install all necessary dependencies for your custom image
Expand Down Expand Up @@ -92,7 +92,8 @@ Run it:
Or if you are using kubernetes you will need to create the cluster and load the image in Kind:

.. code-block::
:caption: Run docker compose
:caption: Run your local cluster
tox -e cluster-deploy
kind load docker-image test-local-provider-function:latest
Expand Down
5 changes: 3 additions & 2 deletions docs/deployment/example_custom_image_function.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Dockerfile
.. code-block::
:caption: Dockerfile
FROM icr.io/quantum-public/qiskit-serverless/ray-node:0.18.0
FROM icr.io/quantum-public/qiskit-serverless/ray-node:0.18.1
# install all necessary dependencies for your custom image
Expand Down Expand Up @@ -90,7 +90,8 @@ Run it
Or if you are using kubernetes you will need to create the cluster and load the image in Kind

.. code-block::
:caption: Run docker compose
:caption: Run your local cluster
tox -e cluster-deploy
kind load docker-image test-local-provider-function:latest
Expand Down
Loading

0 comments on commit 11b41a3

Please sign in to comment.