diff --git a/client/quantum_serverless/core/decorators.py b/client/quantum_serverless/core/decorators.py index dd5ffb5b8..d328397e5 100644 --- a/client/quantum_serverless/core/decorators.py +++ b/client/quantum_serverless/core/decorators.py @@ -50,9 +50,51 @@ from quantum_serverless.utils import JsonSerializable remote = ray.remote -get = ray.get -put = ray.put -get_refs_by_status = ray.wait + + +def put(value: Any, **kwargs): + """Puts object into shared distributed storage + + Args: + value: object to put to object store + **kwargs: other arguments + + Returns: + + """ + return ray.put(value=value, **kwargs) + + +def get_refs_by_status(object_refs: List["ray.ObjectRef"], **kwargs): + """Get references by status. + + Args: + object_refs: object references + **kwargs: other arguments + + Returns: + A list of refs that are ready and a list of the remaining references. + """ + return ray.wait(object_refs=object_refs, **kwargs) + + +def get( + object_refs: Union[ray.ObjectRef, Sequence[ray.ObjectRef]], + *, + timeout: Optional[float] = None, +) -> Any: + """Get results from distributed tasks. + + Args: + object_refs: Object ref of the object to get or a list of object refs + to get. + timeout (Optional[float]): The maximum amount of time in seconds to + wait before returning. + + Returns: + A object or a list of objects. + """ + return ray.get(object_refs=object_refs, timeout=timeout) @dataclass @@ -60,7 +102,7 @@ class Target(JsonSerializable): """Quantum serverless target. Example: - >>> @run_qiskit_remote(target=Target(cpu=1)) + >>> @distribute_task(target=Target(cpu=1)) >>> def awesome_function(): >>> return 42 """ diff --git a/client/requirements.txt b/client/requirements.txt index ce4790097..19ffd1f37 100644 --- a/client/requirements.txt +++ b/client/requirements.txt @@ -1,4 +1,4 @@ -ray[default,data]>=2.4.0, <3 +ray[default,data]>=2.5.1, <3 requests>=2.31.0 importlib-metadata>=5.2.0 qiskit-terra>=0.24.1 diff --git a/docs/requirements-doc.txt b/docs/requirements-doc.txt index 1ab9f910a..d7c20bea6 100644 --- a/docs/requirements-doc.txt +++ b/docs/requirements-doc.txt @@ -13,7 +13,7 @@ reno>=3.5.0 # Black's formatting rules can change between major versions, so we use # the ~= specifier for it. black[jupyter]~=22.1 -ray==2.1.0 +ray==2.5.1 qiskit-terra==0.21.1 qiskit-ibm-runtime==0.7.0rc2 sphinx-copybutton>=0.5.0 diff --git a/gateway/requirements.txt b/gateway/requirements.txt index 23aadde06..6c46bb709 100644 --- a/gateway/requirements.txt +++ b/gateway/requirements.txt @@ -6,7 +6,7 @@ django-allow-cidr>=0.6 dj-rest-auth>=3.0.0 djangorestframework-simplejwt>=5.2.2 django_prometheus>=2.3.1 -ray[default]>=2.4.0 +ray[default]>=2.5.1 Django>=4.2.2 gunicorn>=20.1.0 requests>=2.31.0 diff --git a/infrastructure/docker/Dockerfile-ray-qiskit b/infrastructure/docker/Dockerfile-ray-qiskit index 315cbf626..525d4e1e2 100644 --- a/infrastructure/docker/Dockerfile-ray-qiskit +++ b/infrastructure/docker/Dockerfile-ray-qiskit @@ -1,6 +1,6 @@ ARG IMAGE_PY_VERSION=py39 -FROM rayproject/ray:2.4.0-$IMAGE_PY_VERSION AS ray-node-amd64 +FROM rayproject/ray:2.5.1-$IMAGE_PY_VERSION AS ray-node-amd64 WORKDIR / USER 0 @@ -14,7 +14,7 @@ RUN pip install . --no-cache-dir WORKDIR / RUN rm -r ./qs -FROM rayproject/ray:2.4.0-$IMAGE_PY_VERSION-aarch64 AS ray-node-arm64 +FROM rayproject/ray:2.5.1-$IMAGE_PY_VERSION-aarch64 AS ray-node-arm64 WORKDIR / USER 0