xoscar 0.7.15__cp39-cp39-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl

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.

Potentially problematic release.


This version of xoscar might be problematic. Click here for more details.

Files changed (88) hide show
  1. xoscar/__init__.py +61 -0
  2. xoscar/_utils.cpython-39-aarch64-linux-gnu.so +0 -0
  3. xoscar/_utils.pxd +36 -0
  4. xoscar/_utils.pyx +246 -0
  5. xoscar/_version.py +693 -0
  6. xoscar/aio/__init__.py +16 -0
  7. xoscar/aio/base.py +86 -0
  8. xoscar/aio/file.py +59 -0
  9. xoscar/aio/lru.py +228 -0
  10. xoscar/aio/parallelism.py +39 -0
  11. xoscar/api.py +527 -0
  12. xoscar/backend.py +67 -0
  13. xoscar/backends/__init__.py +14 -0
  14. xoscar/backends/allocate_strategy.py +160 -0
  15. xoscar/backends/communication/__init__.py +30 -0
  16. xoscar/backends/communication/base.py +315 -0
  17. xoscar/backends/communication/core.py +69 -0
  18. xoscar/backends/communication/dummy.py +253 -0
  19. xoscar/backends/communication/errors.py +20 -0
  20. xoscar/backends/communication/socket.py +444 -0
  21. xoscar/backends/communication/ucx.py +538 -0
  22. xoscar/backends/communication/utils.py +97 -0
  23. xoscar/backends/config.py +157 -0
  24. xoscar/backends/context.py +437 -0
  25. xoscar/backends/core.py +304 -0
  26. xoscar/backends/indigen/__init__.py +16 -0
  27. xoscar/backends/indigen/__main__.py +19 -0
  28. xoscar/backends/indigen/backend.py +51 -0
  29. xoscar/backends/indigen/driver.py +26 -0
  30. xoscar/backends/indigen/fate_sharing.py +221 -0
  31. xoscar/backends/indigen/pool.py +465 -0
  32. xoscar/backends/indigen/shared_memory.py +548 -0
  33. xoscar/backends/message.cpython-39-aarch64-linux-gnu.so +0 -0
  34. xoscar/backends/message.pyx +646 -0
  35. xoscar/backends/pool.py +1625 -0
  36. xoscar/backends/router.py +285 -0
  37. xoscar/backends/test/__init__.py +16 -0
  38. xoscar/backends/test/backend.py +38 -0
  39. xoscar/backends/test/pool.py +197 -0
  40. xoscar/batch.py +256 -0
  41. xoscar/collective/__init__.py +27 -0
  42. xoscar/collective/common.py +102 -0
  43. xoscar/collective/core.py +737 -0
  44. xoscar/collective/process_group.py +687 -0
  45. xoscar/collective/utils.py +41 -0
  46. xoscar/collective/xoscar_pygloo.cpython-39-aarch64-linux-gnu.so +0 -0
  47. xoscar/constants.py +23 -0
  48. xoscar/context.cpython-39-aarch64-linux-gnu.so +0 -0
  49. xoscar/context.pxd +21 -0
  50. xoscar/context.pyx +368 -0
  51. xoscar/core.cpython-39-aarch64-linux-gnu.so +0 -0
  52. xoscar/core.pxd +51 -0
  53. xoscar/core.pyx +664 -0
  54. xoscar/debug.py +188 -0
  55. xoscar/driver.py +42 -0
  56. xoscar/errors.py +63 -0
  57. xoscar/libcpp.pxd +31 -0
  58. xoscar/metrics/__init__.py +21 -0
  59. xoscar/metrics/api.py +288 -0
  60. xoscar/metrics/backends/__init__.py +13 -0
  61. xoscar/metrics/backends/console/__init__.py +13 -0
  62. xoscar/metrics/backends/console/console_metric.py +82 -0
  63. xoscar/metrics/backends/metric.py +149 -0
  64. xoscar/metrics/backends/prometheus/__init__.py +13 -0
  65. xoscar/metrics/backends/prometheus/prometheus_metric.py +70 -0
  66. xoscar/nvutils.py +717 -0
  67. xoscar/profiling.py +260 -0
  68. xoscar/serialization/__init__.py +20 -0
  69. xoscar/serialization/aio.py +142 -0
  70. xoscar/serialization/core.cpython-39-aarch64-linux-gnu.so +0 -0
  71. xoscar/serialization/core.pxd +28 -0
  72. xoscar/serialization/core.pyx +944 -0
  73. xoscar/serialization/cuda.py +111 -0
  74. xoscar/serialization/exception.py +48 -0
  75. xoscar/serialization/mlx.py +67 -0
  76. xoscar/serialization/numpy.py +82 -0
  77. xoscar/serialization/pyfury.py +37 -0
  78. xoscar/serialization/scipy.py +72 -0
  79. xoscar/utils.py +517 -0
  80. xoscar/virtualenv/__init__.py +34 -0
  81. xoscar/virtualenv/core.py +268 -0
  82. xoscar/virtualenv/platform.py +53 -0
  83. xoscar/virtualenv/utils.py +100 -0
  84. xoscar/virtualenv/uv.py +318 -0
  85. xoscar-0.7.15.dist-info/METADATA +226 -0
  86. xoscar-0.7.15.dist-info/RECORD +88 -0
  87. xoscar-0.7.15.dist-info/WHEEL +6 -0
  88. xoscar-0.7.15.dist-info/top_level.txt +2 -0
@@ -0,0 +1,318 @@
1
+ # Copyright 2022-2025 XProbe Inc.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ from __future__ import annotations
16
+
17
+ import logging
18
+ import os
19
+ import re
20
+ import shutil
21
+ import subprocess
22
+ import sys
23
+ import sysconfig
24
+ import tempfile
25
+ from importlib.metadata import distributions
26
+ from pathlib import Path
27
+ from typing import Optional
28
+
29
+ from packaging.requirements import Requirement
30
+ from packaging.version import Version
31
+
32
+ from .core import VirtualEnvManager
33
+ from .utils import is_vcs_url, run_subprocess_with_logger
34
+
35
+ UV_PATH = os.getenv("XOSCAR_UV_PATH")
36
+ SKIP_INSTALLED = bool(int(os.getenv("XOSCAR_VIRTUAL_ENV_SKIP_INSTALLED", "0")))
37
+ logger = logging.getLogger(__name__)
38
+
39
+
40
+ def _is_in_pyinstaller():
41
+ return hasattr(sys, "_MEIPASS")
42
+
43
+
44
+ class UVVirtualEnvManager(VirtualEnvManager):
45
+ def __init__(self, env_path: Path):
46
+ super().__init__(env_path)
47
+ self._install_process: Optional[subprocess.Popen] = None
48
+
49
+ @classmethod
50
+ def is_available(cls):
51
+ if UV_PATH is not None:
52
+ # user specified uv, just treat it as existed
53
+ return True
54
+ return shutil.which("uv") is not None
55
+
56
+ @staticmethod
57
+ def _get_uv_path() -> str:
58
+ if (uv_path := UV_PATH) is None:
59
+ try:
60
+ from uv import find_uv_bin
61
+
62
+ uv_path = find_uv_bin()
63
+ except (ImportError, FileNotFoundError):
64
+ logger.warning("Fail to find uv bin, use system one")
65
+ uv_path = "uv"
66
+ return uv_path
67
+
68
+ def exists_env(self) -> bool:
69
+ """Check if virtual environment already exists."""
70
+ return self.env_path.exists() and (self.env_path / "pyvenv.cfg").exists()
71
+
72
+ def create_env(
73
+ self, python_path: Path | None = None, exists: str = "ignore"
74
+ ) -> None:
75
+ """
76
+ Create virtual environment.
77
+
78
+ Args:
79
+ python_path: Path to Python interpreter to use
80
+ exists: How to handle existing environment:
81
+ - "ignore": Skip creation if environment already exists (default)
82
+ - "error": Raise error if environment exists
83
+ - "clear": Remove existing environment and create new one
84
+ """
85
+ if self.exists_env():
86
+ if exists == "error":
87
+ raise FileExistsError(
88
+ f"Virtual environment already exists at {self.env_path}"
89
+ )
90
+ elif exists == "ignore":
91
+ logger.info(
92
+ f"Virtual environment already exists at {self.env_path}, skipping creation"
93
+ )
94
+ return
95
+ elif exists == "clear":
96
+ logger.info(f"Removing existing virtual environment at {self.env_path}")
97
+ self.remove_env()
98
+ else:
99
+ raise ValueError(
100
+ f"Invalid exists option: {exists}. Must be one of: error, clear, ignore"
101
+ )
102
+
103
+ uv_path = self._get_uv_path()
104
+ cmd = [uv_path, "venv", str(self.env_path), "--system-site-packages"]
105
+
106
+ if python_path:
107
+ cmd += ["--python", str(python_path)]
108
+ elif _is_in_pyinstaller():
109
+ # in pyinstaller, uv would find the system python
110
+ # in this case we'd better specify the same python version
111
+ python_version = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
112
+ cmd += ["--python", python_version]
113
+
114
+ logger.info("Creating virtualenv via command: %s", cmd)
115
+ subprocess.run(cmd, check=True)
116
+
117
+ def _resolve_install_plan(
118
+ self, specs: list[str], pinned: dict[str, str]
119
+ ) -> list[str]:
120
+ """
121
+ Run uv --dry-run with pinned constraints and return
122
+ a list like ['package==version', ...].
123
+ """
124
+ with tempfile.NamedTemporaryFile("w+", delete=True) as f:
125
+ for name, ver in pinned.items():
126
+ f.write(f"{name}=={ver}\n")
127
+ f.flush() # make sure content is on disk
128
+
129
+ cmd = [
130
+ self._get_uv_path(),
131
+ "pip",
132
+ "install",
133
+ "-p",
134
+ str(self.env_path),
135
+ "--dry-run",
136
+ "--constraint",
137
+ f.name,
138
+ *specs,
139
+ ]
140
+ result = subprocess.run(cmd, check=True, text=True, capture_output=True)
141
+
142
+ # the temp file is automatically deleted here
143
+ deps = [
144
+ f"{m.group(1)}=={m.group(2)}"
145
+ for line in result.stderr.splitlines()
146
+ if (m := re.match(r"^\+ (\S+)==(\S+)$", line.strip()))
147
+ ]
148
+ return deps
149
+
150
+ @staticmethod
151
+ def _split_specs(
152
+ specs: list[str], installed: dict[str, str]
153
+ ) -> tuple[list[str], list[str], dict[str, str]]:
154
+ """
155
+ Split the given requirement specs into:
156
+ - keep: specs that need to be kept, e.g. git+github://xxx
157
+ - to_resolve: specs that need to be passed to the resolver (unsatisfied ones)
158
+ - pinned: already satisfied specs, used for constraint to lock their versions
159
+ """
160
+ keep: list[str] = []
161
+ to_resolve: list[str] = []
162
+ pinned: dict[str, str] = {}
163
+
164
+ for spec_str in specs:
165
+ # skip git+xxx
166
+ if is_vcs_url(spec_str):
167
+ keep.append(spec_str)
168
+ continue
169
+
170
+ req = Requirement(spec_str)
171
+ name = req.name.lower()
172
+ cur_ver = installed.get(name)
173
+
174
+ if cur_ver is None:
175
+ # Package not installed, needs resolution
176
+ to_resolve.append(spec_str)
177
+ continue
178
+
179
+ if not req.specifier:
180
+ # No version constraint, already satisfied
181
+ pinned[name] = cur_ver
182
+ continue
183
+
184
+ try:
185
+ if Version(cur_ver) in req.specifier:
186
+ # Version satisfies the specifier, pin it
187
+ pinned[name] = cur_ver
188
+ else:
189
+ # Version does not satisfy, needs resolution
190
+ to_resolve.append(spec_str)
191
+ except Exception:
192
+ # Parsing error, be conservative and resolve it
193
+ to_resolve.append(spec_str)
194
+
195
+ return keep, to_resolve, pinned
196
+
197
+ def _filter_packages_not_installed(self, packages: list[str]) -> list[str]:
198
+ """
199
+ Filter out packages that are already installed with the same version.
200
+ """
201
+
202
+ # all the installed packages in system site packages
203
+ installed = {
204
+ dist.metadata["Name"].lower(): dist.version
205
+ for dist in distributions()
206
+ if dist.metadata and "Name" in dist.metadata
207
+ }
208
+
209
+ # exclude those packages that satisfied in system site packages
210
+ keep, to_resolve, pinned = self._split_specs(packages, installed)
211
+ if not keep and not to_resolve:
212
+ logger.debug("All requirement specifiers satisfied by system packages.")
213
+ return []
214
+
215
+ if to_resolve:
216
+ resolved = self._resolve_install_plan(to_resolve, pinned)
217
+ logger.debug(f"Resolved install list: {resolved}")
218
+ if not keep and not resolved:
219
+ # no packages to install
220
+ return []
221
+ else:
222
+ resolved = []
223
+
224
+ final = keep.copy()
225
+ for item in resolved:
226
+ name, version = item.split("==")
227
+ key = name.lower()
228
+ if key not in installed or installed[key] != version:
229
+ final.append(item)
230
+ logger.debug(f"Filtered install list: {final}")
231
+ return final
232
+
233
+ def install_packages(self, packages: list[str], **kwargs):
234
+ """
235
+ Install packages into the virtual environment using uv.
236
+ Supports pip-compatible kwargs: index_url, extra_index_url, find_links.
237
+ """
238
+ if not packages:
239
+ return
240
+
241
+ packages = self.process_packages(packages)
242
+ log = kwargs.pop("log", False)
243
+ skip_installed = kwargs.pop("skip_installed", SKIP_INSTALLED)
244
+ uv_path = self._get_uv_path()
245
+
246
+ if skip_installed:
247
+ packages = self._filter_packages_not_installed(packages)
248
+ if not packages:
249
+ logger.info("All required packages are already installed.")
250
+ return
251
+
252
+ cmd = [
253
+ uv_path,
254
+ "pip",
255
+ "install",
256
+ "-p",
257
+ str(self.env_path),
258
+ "--color=always",
259
+ "--no-deps",
260
+ ] + packages
261
+ else:
262
+ cmd = [
263
+ uv_path,
264
+ "pip",
265
+ "install",
266
+ "-p",
267
+ str(self.env_path),
268
+ "--color=always",
269
+ ] + packages
270
+
271
+ if "index_url" in kwargs and kwargs["index_url"]:
272
+ cmd += ["-i", kwargs["index_url"]]
273
+ param_and_option = [
274
+ ("extra_index_url", "--extra-index-url"),
275
+ ("find_links", "-f"),
276
+ ("trusted_host", "--trusted-host"),
277
+ ]
278
+ for param, option in param_and_option:
279
+ if param in kwargs and kwargs[param]:
280
+ val = kwargs[param]
281
+ cmd += (
282
+ [option, val]
283
+ if isinstance(val, str)
284
+ else [opt for v in val for opt in (option, v)]
285
+ )
286
+
287
+ if kwargs.get("no_build_isolation", False):
288
+ cmd += ["--no-build-isolation"]
289
+
290
+ logger.info("Installing packages via command: %s", cmd)
291
+ if not log:
292
+ self._install_process = process = subprocess.Popen(cmd)
293
+ returncode = process.wait()
294
+ else:
295
+ with run_subprocess_with_logger(cmd) as process:
296
+ self._install_process = process
297
+ returncode = process.returncode
298
+
299
+ self._install_process = None
300
+ if returncode != 0:
301
+ raise subprocess.CalledProcessError(returncode, cmd)
302
+
303
+ def cancel_install(self):
304
+ if self._install_process and self._install_process.poll() is None:
305
+ self._install_process.terminate()
306
+ self._install_process.wait()
307
+
308
+ def get_python_path(self) -> str | None:
309
+ if self.env_path.exists():
310
+ return str(self.env_path.joinpath("bin/python"))
311
+ return None
312
+
313
+ def get_lib_path(self) -> str:
314
+ return sysconfig.get_path("purelib", vars={"base": str(self.env_path)})
315
+
316
+ def remove_env(self):
317
+ if self.env_path.exists():
318
+ shutil.rmtree(self.env_path, ignore_errors=True)
@@ -0,0 +1,226 @@
1
+ Metadata-Version: 2.1
2
+ Name: xoscar
3
+ Version: 0.7.15
4
+ Summary: Python actor framework for heterogeneous computing.
5
+ Home-page: http://github.com/xorbitsai/xoscar
6
+ Author: Qin Xuye
7
+ Author-email: qinxuye@xprobe.io
8
+ Maintainer: Qin Xuye
9
+ Maintainer-email: qinxuye@xprobe.io
10
+ License: Apache License 2.0
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: Implementation :: CPython
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Description-Content-Type: text/markdown
21
+ Requires-Dist: numpy>=1.14.0
22
+ Requires-Dist: pandas>=1.0.0
23
+ Requires-Dist: cloudpickle>=1.5.0
24
+ Requires-Dist: psutil>=5.9.0
25
+ Requires-Dist: tblib>=1.7.0
26
+ Requires-Dist: packaging
27
+ Requires-Dist: click
28
+ Requires-Dist: uvloop>=0.14.0; sys_platform != "win32"
29
+ Requires-Dist: scipy>=1.0.0; sys_platform != "win32" or python_version >= "3.10"
30
+ Requires-Dist: scipy<=1.9.1,>=1.0.0; sys_platform == "win32" and python_version < "3.10"
31
+ Provides-Extra: dev
32
+ Requires-Dist: cython>=0.29; extra == "dev"
33
+ Requires-Dist: pytest>=3.5.0; extra == "dev"
34
+ Requires-Dist: pytest-cov>=2.5.0; extra == "dev"
35
+ Requires-Dist: pytest-timeout>=1.2.0; extra == "dev"
36
+ Requires-Dist: pytest-forked>=1.0; extra == "dev"
37
+ Requires-Dist: pytest-asyncio>=0.14.0; extra == "dev"
38
+ Requires-Dist: ipython>=6.5.0; extra == "dev"
39
+ Requires-Dist: sphinx; extra == "dev"
40
+ Requires-Dist: pydata-sphinx-theme>=0.3.0; extra == "dev"
41
+ Requires-Dist: sphinx-intl>=0.9.9; extra == "dev"
42
+ Requires-Dist: flake8>=3.8.0; extra == "dev"
43
+ Requires-Dist: black; extra == "dev"
44
+ Requires-Dist: uv; extra == "dev"
45
+ Requires-Dist: click; extra == "dev"
46
+ Provides-Extra: doc
47
+ Requires-Dist: ipython>=6.5.0; extra == "doc"
48
+ Requires-Dist: sphinx; extra == "doc"
49
+ Requires-Dist: pydata-sphinx-theme>=0.3.0; extra == "doc"
50
+ Requires-Dist: sphinx-intl>=0.9.9; extra == "doc"
51
+ Provides-Extra: extra
52
+ Requires-Dist: pyarrow>=5.0.0; extra == "extra"
53
+ Provides-Extra: kubernetes
54
+ Requires-Dist: kubernetes>=10.0.0; extra == "kubernetes"
55
+ Provides-Extra: ray
56
+ Requires-Dist: xoscar-ray>=0.0.1; extra == "ray"
57
+
58
+ <div align="center">
59
+ <img width="77%" alt="" src="https://raw.githubusercontent.com/xprobe-inc/xoscar/main/doc/source/_static/Xoscar.svg"><br>
60
+ </div>
61
+
62
+ # Python actor framework for heterogeneous computing.
63
+ [![PyPI Latest Release](https://img.shields.io/pypi/v/xoscar.svg?style=for-the-badge)](https://pypi.org/project/xoscar/)
64
+ [![Coverage](https://img.shields.io/codecov/c/github/xorbitsai/xoscar?style=for-the-badge)](https://codecov.io/gh/xorbitsai/xoscar)
65
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/xorbitsai/xoscar/python.yaml?branch=main&style=for-the-badge&label=GITHUB%20ACTIONS&logo=github)](https://actions-badge.atrox.dev/xorbitsai/xoscar/goto?ref=main)
66
+ [![License](https://img.shields.io/pypi/l/xoscar.svg?style=for-the-badge)](https://github.com/xorbitsai/xoscar/blob/main/LICENSE)
67
+
68
+ ## What is actor
69
+ Writing parallel and distributed programs is often challenging and requires a lot of time to deal with concurrency
70
+ issues. Actor model provides a high-level, scalable and robust abstraction for building distributed applications.
71
+ It provides several benefits:
72
+ - Scalability: Actors easily scale across nodes. The asynchronous, non-blocking nature of actors allows them to handle huge volumes of concurrent tasks efficiently.
73
+ - Concurrency: The actor model abstracts over concurrency, allowing developers to avoid raw threads and locks.
74
+ - Modularity: An actor system decomposes naturally into a collection of actors that can be understood independently. Actor logic is encapsulated within the actor itself.
75
+
76
+ ## Why Xoscar
77
+ Xoscar implements the actor model in Python and provides user-friendly APIs that offer significant benefits for building
78
+ applications on heterogeneous hardware:
79
+ - **Abstraction over low-level communication details**: Xoscar handles all communication between actors transparently,
80
+ whether on CPUs, GPUs, or across nodes. Developers focus on application logic rather than managing hardware resources
81
+ and optimizing data transfer.
82
+ - **Flexible actor models**: Xoscar supports both stateful and stateless actors. Stateful actors ensure thread safety for
83
+ concurrent systems while stateless actors can handle massive volumes of concurrent messages. Developers choose the
84
+ appropriate actor model for their needs.
85
+ - **Batch method**: Xoscar provides a batch interface to significantly improve call efficiency when an actor interface is
86
+ invoked a large number of times.
87
+ - **Advanced debugging support**: Xoscar can detect potential issues like deadlocks, long-running calls, and performance
88
+ bottlenecks that would otherwise be nearly impossible to troubleshoot in a heterogeneous environment.
89
+ - **Automated recovery**: If an actor fails for any reason, Xoscar will automatically restart it if you want. It can monitor
90
+ actors and restart them upon failure, enabling fault-tolerant systems.
91
+
92
+ ## Overview
93
+ ![architecture.png](doc/source/_static/architecture.png)
94
+ Xoscar allows you to create multiple actor pools on each worker node, typically binding an actor pool to a CPU core or
95
+ a GPU card. Xoscar provides allocation policies so that whenever an actor is created, it will be instantiated in the
96
+ appropriate pool based on the specified policy.
97
+
98
+ When actors communicate, Xoscar will choose the optimal communication mechanism based on which pools the actors
99
+ belong to. This allows Xoscar to optimize communication in heterogeneous environments with multiple processing
100
+ units and accelerators.
101
+
102
+ ## Where to get it
103
+
104
+ ### PyPI
105
+ Binary installers for the latest released version are available at the [Python
106
+ Package Index (PyPI)](https://pypi.org/project/xoscar).
107
+
108
+ ```shell
109
+ # PyPI
110
+ pip install xoscar
111
+ ```
112
+
113
+ ### Build from source
114
+ The source code is currently hosted on GitHub at: https://github.com/xorbitsai/xoscar .
115
+
116
+ Building from source requires that you have cmake and gcc installed on your system.
117
+
118
+ - cmake >= 3.11
119
+ - gcc >= 8
120
+
121
+ ```shell
122
+ # If you have never cloned xoscar before
123
+ git clone --recursive https://github.com/xorbitsai/xoscar.git
124
+ cd xoscar/python
125
+ pip install -e .
126
+
127
+ # If you have already cloned xoscar before
128
+ cd xoscar
129
+ git submodule init
130
+ git submodule update
131
+ cd python && pip install -e .
132
+ ```
133
+
134
+ ## APIs
135
+ Here are basic APIs for Xoscar.
136
+ #### Define an actor
137
+ ```python
138
+ import xoscar as xo
139
+
140
+ # stateful actor, for stateless actor, inherit from xo.StatelessActor
141
+ class MyActor(xo.Actor):
142
+ def __init__(self, *args, **kwargs):
143
+ pass
144
+
145
+ async def __post_create__(self):
146
+ # called after created
147
+ pass
148
+
149
+ async def __pre_destroy__(self):
150
+ # called before destroy
151
+ pass
152
+
153
+ def method_a(self, arg_1, arg_2, **kw_1): # user-defined function
154
+ pass
155
+
156
+ async def method_b(self, arg_1, arg_2, **kw_1): # user-defined async function
157
+ pass
158
+ ```
159
+
160
+ #### Create an actor
161
+ ```python
162
+ import xoscar as xo
163
+
164
+ actor_ref = await xo.create_actor(
165
+ MyActor, 1, 2, a=1, b=2,
166
+ address='<ip>:<port>', uid='UniqueActorName')
167
+ ```
168
+
169
+ #### Get an actor reference
170
+ ```python
171
+ import xoscar as xo
172
+
173
+ actor_ref = await xo.actor_ref(address, actor_id)
174
+ ```
175
+
176
+ #### Invoke a method
177
+ ```python
178
+ # send
179
+ await actor_ref.method_a.send(1, 2, a=1, b=2)
180
+ # equivalent to actor_ref.method_a.send
181
+ await actor_ref.method_a(1, 2, a=1, b=2)
182
+ # tell, it sends a message asynchronously and does not wait for a response.
183
+ await actor_ref.method_a.tell(1, 2, a=1, b=2)
184
+ ```
185
+ ### Batch method
186
+ Xoscar provides a set of APIs to write batch methods. You can simply add a `@extensible` decorator to your actor method
187
+ and create a batch version. All calls wrapped in a batch will be sent together, reducing possible RPC cost.
188
+ #### Define a batch method
189
+ ```python
190
+ import xoscar as xo
191
+
192
+ class ExampleActor(xo.Actor):
193
+ @xo.extensible
194
+ async def batch_method(self, a, b=None):
195
+ pass
196
+ ```
197
+ Xoscar also supports creating a batch version of the method:
198
+ ```python
199
+ class ExampleActor(xo.Actor):
200
+ @xo.extensible
201
+ async def batch_method(self, a, b=None):
202
+ raise NotImplementedError # this will redirect all requests to the batch version
203
+
204
+ @batch_method.batch
205
+ async def batch_method(self, args_list, kwargs_list):
206
+ results = []
207
+ for args, kwargs in zip(args_list, kwargs_list):
208
+ a, b = self.batch_method.bind(*args, **kwargs)
209
+ # process the request
210
+ results.append(result)
211
+ return results # return a list of results
212
+ ```
213
+ In a batch method, users can define how to more efficiently process a batch of requests.
214
+
215
+ #### Invoke a batch method
216
+ Calling batch methods is easy. You can use `<method_name>.delay` to make a batched call and use `<method_name>.batch` to send them:
217
+ ```python
218
+ ref = await xo.actor_ref(uid='ExampleActor', address='127.0.0.1:13425')
219
+ results = await ref.batch_method.batch(
220
+ ref.batch_method.delay(10, b=20),
221
+ ref.batch_method.delay(20),
222
+ )
223
+ ```
224
+
225
+ ## License
226
+ [Apache 2](LICENSE)
@@ -0,0 +1,88 @@
1
+ xoscar/__init__.py,sha256=sy7Wtn2EuQZI0I4Az_MfsBVZm4G0DRj46qRyExgmnJk,1622
2
+ xoscar/_utils.cpython-39-aarch64-linux-gnu.so,sha256=TiY-9PTAv8cssinr2DDw5elvTSsl6dyjLnuwFDLsRP0,1318280
3
+ xoscar/_utils.pxd,sha256=5KYAL3jfPdejsHnrGGT2s--ZUX5SXznQWpHVSno429k,1157
4
+ xoscar/_utils.pyx,sha256=frgVQ5xGp92jBKc4PsPmjOlVsXlKeHWtTOAMfHmBaII,7380
5
+ xoscar/_version.py,sha256=ClSPrUjgGRGHIkVMQV9XQnkQ-n0akJMnq_rh819nqFE,23719
6
+ xoscar/api.py,sha256=zxNqOjGiTIKuAip9WJ0LOoM7yevD6P5rb-sLynpZ2Zo,14648
7
+ xoscar/backend.py,sha256=is436OPkZfSpQXaoqTRVta5eoye_pp45RFgCstAk2hU,1850
8
+ xoscar/batch.py,sha256=DpArS0L3WYJ_HVPG-6hSYEwoAFY1mY2-mlC4Jp5M_Dw,7872
9
+ xoscar/constants.py,sha256=QHHSREw6uWBBjQDCFqlNfTvBZgniJPGy42KSIsR8Fqw,787
10
+ xoscar/context.cpython-39-aarch64-linux-gnu.so,sha256=eiz08FnbEaEDOIynTTtjxM_R8WzPh685Aqso1LA5-K0,1684008
11
+ xoscar/context.pxd,sha256=qKa0OyDPZtVymftSh447m-RzFZgmz8rGqQBa7qlauvc,725
12
+ xoscar/context.pyx,sha256=8CdgPnWcE9eOp3N600WgDQ03MCi8P73eUOGcfV7Zksg,10942
13
+ xoscar/core.cpython-39-aarch64-linux-gnu.so,sha256=NnC2_mGE7NzRwPn4bF2wfLx9DewSEooxg2lp5AuDDUc,3670880
14
+ xoscar/core.pxd,sha256=I_C2ka7XryyGnnAVXUVm8xfS1gtIrCs6X-9rswgOcUU,1317
15
+ xoscar/core.pyx,sha256=phN-yYV0A0QI8WFi2jCu0nc4CnShTepfDi0V7ZrLYPY,22092
16
+ xoscar/debug.py,sha256=9Z8SgE2WaKYQcyDo-5-DxEJQ533v7kWjrvCd28pSx3E,5069
17
+ xoscar/driver.py,sha256=498fowtJr6b3FE8FIOA_Tc1Vwx88nfZw7p0FxrML0h4,1372
18
+ xoscar/errors.py,sha256=wBlQOKsXf0Fc4skN39tDie0YZT-VIAuLNRgoDl2pZcA,1241
19
+ xoscar/libcpp.pxd,sha256=DJqBxLFOKL4iRr9Kale5UH3rbvPRD1x5bTSOPHFpz9I,1147
20
+ xoscar/nvutils.py,sha256=qmW4mKLU0WB2yCs198ccQOgLL02zB7Fsa-AotO3NOmg,20412
21
+ xoscar/profiling.py,sha256=BC5OF0HzSaXv8V7w-y-B8r5gV5DgxHFoTEIF6jCMioQ,8015
22
+ xoscar/utils.py,sha256=MaKiW4Vphwhh8c0yoqN8G8hbJr1zXgpf49EdvmGc1ZU,16500
23
+ xoscar/aio/__init__.py,sha256=kViDKR_kJe59VQViHITKEfBcIgN4ZJblUyd8zl0E3ZI,675
24
+ xoscar/aio/base.py,sha256=9j0f1piwfE5R5GIvV212vSD03ixdaeSzSSsO2kxJZVE,2249
25
+ xoscar/aio/file.py,sha256=PBtkLp-Q7XtYl-zk00s18TtgIrkNr60J3Itf66ctO1o,1486
26
+ xoscar/aio/lru.py,sha256=rpXCqSLtPV5xnWtd6uDwQQFGgIPEgvmWEQDkPNUx9cM,6311
27
+ xoscar/aio/parallelism.py,sha256=VSsjk8wP-Bw7tLeUsTyLVNgp91thjxEfE3pCrw_vF5Q,1293
28
+ xoscar/backends/__init__.py,sha256=VHEBQcUWM5bj027W8EUf9PiJUAP7JoMrRw3Tsvy5ySw,643
29
+ xoscar/backends/allocate_strategy.py,sha256=tC1Nbq2tJohahUwd-zoRYHEDX65wyuX8tmeY45uWj_w,4845
30
+ xoscar/backends/config.py,sha256=4tZMiXAMMS8qQ4SX_LjONLtSQVfZTx3m-IK3EqbkYdk,5375
31
+ xoscar/backends/context.py,sha256=XfDPG2eDhAhE6hWBEkEsHTnyyOYN9R3houlMjAL7BFw,16329
32
+ xoscar/backends/core.py,sha256=EH-fHlV9x3bnruEHaUtGYO7osKLfLJ4AQHtuzA_mr2g,10857
33
+ xoscar/backends/message.cpython-39-aarch64-linux-gnu.so,sha256=WnATOEBB-Vds5IK4yGokL7oNXsDy00VT7FBww5F2tfc,3327400
34
+ xoscar/backends/message.pyx,sha256=krGVtZ1YDaZX8yWhaNHwZiudQooLvcGlw6x3Sq7jxjE,19685
35
+ xoscar/backends/pool.py,sha256=nrh8qobaukkjUOOOTR9t90i-wbXlgma3TNRjvwkwmcg,60528
36
+ xoscar/backends/router.py,sha256=MVl5naz-FYf-Wla7XRn3kRxOpWV0SjKDsKNluifVA8M,10532
37
+ xoscar/backends/communication/__init__.py,sha256=oFIg83Ga93-AhrG52TE85Z2LgpGZu1RCgQu1RWi62zQ,1063
38
+ xoscar/backends/communication/base.py,sha256=0P4Tr35GSWpRp394e9jVWUUoKKa-gIk177eYPw1BnSU,7421
39
+ xoscar/backends/communication/core.py,sha256=sJeE3foRIqVPXldzYpFKHDSsabfAIFBU4JuXY4OyklY,2130
40
+ xoscar/backends/communication/dummy.py,sha256=6kLkxjNk4xTQ-IlNZD6cftNCx5UsGOur2jk7ikrNUCg,8157
41
+ xoscar/backends/communication/errors.py,sha256=V3CdBe2xX9Rwv32f2dH2Msc84yaUhlyerZ42-739o1Q,723
42
+ xoscar/backends/communication/socket.py,sha256=6Pf9RJWHuvobjZ1eAU6bUuGY7PzYga3Vyc4PAKF-k2M,14428
43
+ xoscar/backends/communication/ucx.py,sha256=_Dp9Ld2MWIa1txSGMnmfYwJDT0esxS-GOd2FQ4BdHiM,19960
44
+ xoscar/backends/communication/utils.py,sha256=AmovE-hmWLXNCPwHafYuaRjOk8m42BUyT3XBqfXQRVI,3664
45
+ xoscar/backends/indigen/__init__.py,sha256=tKHP5ClzedBRBpZsLRVErR3EUNbbDm4CY4u0rCFJr44,685
46
+ xoscar/backends/indigen/__main__.py,sha256=-pfio-Y4Ogbk6lBFksH-gRatp-N6sZ7wuNc-i2YsLJc,510
47
+ xoscar/backends/indigen/backend.py,sha256=znl_fZzWGEtLH8hZ9j9Kkf0fva25jEem2_KO7I1RVvc,1612
48
+ xoscar/backends/indigen/driver.py,sha256=VGzkacYKykegW5qhCuhx01gdgBZEKJjNIyfNCnA6Nm8,952
49
+ xoscar/backends/indigen/fate_sharing.py,sha256=3QUHwq5Cjk9oCKFUISvkqHaoxWZIaXcq8JNOetdBl-A,8655
50
+ xoscar/backends/indigen/pool.py,sha256=t8zQ1i6Kf3JEy8EMMX7vTbKakilkn4TuxPdsxaxh27A,16573
51
+ xoscar/backends/indigen/shared_memory.py,sha256=wqbckbgnd0qNm5KzlP_hklF3F_n8fKnCehSox5uMwNs,19082
52
+ xoscar/backends/test/__init__.py,sha256=j2ZfD6prD9WjUxRUDC7Eq5Z7N7TkL6fFr59oNyc_vY4,682
53
+ xoscar/backends/test/backend.py,sha256=nv9WFhH5Bbq4Q1HB9yfpciZBaeHT4IQAtzugBWESrUY,1263
54
+ xoscar/backends/test/pool.py,sha256=1MrdNnQZkeBJMYrn3NGUe1VpvsUM_HlTm3l7SSynzpo,6882
55
+ xoscar/collective/__init__.py,sha256=XsClIkO_3Jd8GDifYuAbZCmJLAo9ZqGvnjUn9iuogmU,774
56
+ xoscar/collective/common.py,sha256=INAnISbfnRicbbbDHTqbSr9ITb89ZphH5BUkSpEdXXU,3561
57
+ xoscar/collective/core.py,sha256=NVR-7Iaq3aDPCN6fgXcq9Ew6uFEszRwxYqmUG9FLcws,23502
58
+ xoscar/collective/process_group.py,sha256=zy7LcIFnEcmrcxuECI89v0bQlUbSqQMkVyBw468WBnk,22599
59
+ xoscar/collective/utils.py,sha256=3S4qF4JEnAUD3RiWVBUj-ZptL83CBSwGYyVZyIasAsE,1178
60
+ xoscar/collective/xoscar_pygloo.cpython-39-aarch64-linux-gnu.so,sha256=7AR25egqbfmhqUKfPoQa5v4UdoVhn5zxHhq07uYiPCA,1516912
61
+ xoscar/metrics/__init__.py,sha256=9Badi7rxYikGm2dQiNCrj9GgMRBxwuR3JaEKcFZmfak,705
62
+ xoscar/metrics/api.py,sha256=BBlMIFvVAGVfrtpeJ1YlH9Tqhy9OzGavwvGyeHcQ0Tk,8856
63
+ xoscar/metrics/backends/__init__.py,sha256=h_JgzSqV5lP6vQ6XX_17kE4IY4BRnvKta_7VLQAL1ms,581
64
+ xoscar/metrics/backends/metric.py,sha256=aPhyc8JgH22L3rcHP8IjsmgrhSODjg6B5TZVnre97y8,4446
65
+ xoscar/metrics/backends/console/__init__.py,sha256=h_JgzSqV5lP6vQ6XX_17kE4IY4BRnvKta_7VLQAL1ms,581
66
+ xoscar/metrics/backends/console/console_metric.py,sha256=y5CCtH33j3AqI5_Uhwi4mgOcAhyhb4cWv_YvR6fxcbQ,2082
67
+ xoscar/metrics/backends/prometheus/__init__.py,sha256=h_JgzSqV5lP6vQ6XX_17kE4IY4BRnvKta_7VLQAL1ms,581
68
+ xoscar/metrics/backends/prometheus/prometheus_metric.py,sha256=MxoMvVrg0pOkKpkjJ0PcAuEaaEJR2FZljmPrLjQ1-oc,2050
69
+ xoscar/serialization/__init__.py,sha256=v76XC2OQLp-Yk4_U3_IVguEylMeyRw1UrkU_DPDMh0U,856
70
+ xoscar/serialization/aio.py,sha256=5DySPgDxU43ec7_5Ct44-Oqt7YNSJBfuf8VdQgQlChA,4731
71
+ xoscar/serialization/core.cpython-39-aarch64-linux-gnu.so,sha256=QtGeo5J617jVCA2FFsxfSElFA_6RQZqP24her4HvwKc,3628848
72
+ xoscar/serialization/core.pxd,sha256=k4RoJgX5E5LGs4jdCQ7vvcn26MabXbrWoWhkO49X6YI,985
73
+ xoscar/serialization/core.pyx,sha256=bjR-zXGm9qersk7kYPzpjpMIxDl_Auur4BCubRfKmfA,29626
74
+ xoscar/serialization/cuda.py,sha256=iFUEnN4SiquBIhyieyOrfw3TnKnW-tU_vYgqOxO_DrA,3758
75
+ xoscar/serialization/exception.py,sha256=Jy8Lsk0z-VJyEUaWeuZIwkmxqaoB-nLKMa1D15Cl4js,1634
76
+ xoscar/serialization/mlx.py,sha256=tRu_7o6RizdRhbr88EasHrZtShimAsLy3pIEO-by29o,2118
77
+ xoscar/serialization/numpy.py,sha256=5Kem87CvpJmzUMp3QHk4WeHU30FoQWTJJP2SwIcaQG0,2919
78
+ xoscar/serialization/pyfury.py,sha256=sifOnVMYoS82PzZEkzkfxesmMHei23k5UAUUKUyoOYQ,1163
79
+ xoscar/serialization/scipy.py,sha256=yOEi0NB8cqQ6e2UnCZ1w006RsB7T725tIL-DM_hNcsU,2482
80
+ xoscar/virtualenv/__init__.py,sha256=65t9_X1DvbanNjFy366SiiWZrRTpa9SXWMXPmqayE-4,1117
81
+ xoscar/virtualenv/core.py,sha256=Ij36UQaej9fFaz1PfqkEtL1ss8yBribXHcWT115kH-o,8098
82
+ xoscar/virtualenv/platform.py,sha256=3f5EQEXbq_sf4pRJ_0lg4y1V_22qadUdQjmVjIaZaoU,1403
83
+ xoscar/virtualenv/utils.py,sha256=qKHw7Gg0n3JuzKFjhBnftPq2QWlgNJLk1sGPr5GzamM,2875
84
+ xoscar/virtualenv/uv.py,sha256=bkFN2Vp6b2mz6YXpodH2plGIGBA-YUU4vE5p2j0mKkg,11046
85
+ xoscar-0.7.15.dist-info/METADATA,sha256=CXVH-87HF_k_eIeE9lFHs4lbz3_LkCpWi-YN5XSYIkI,9135
86
+ xoscar-0.7.15.dist-info/WHEEL,sha256=PGBZJ0HXRvKYfGueyVeuY-4089-0luU2ZMzWKBxAFSE,151
87
+ xoscar-0.7.15.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
88
+ xoscar-0.7.15.dist-info/RECORD,,
@@ -0,0 +1,6 @@
1
+ Wheel-Version: 1.0
2
+ Generator: bdist_wheel (0.45.1)
3
+ Root-Is-Purelib: false
4
+ Tag: cp39-cp39-manylinux_2_26_aarch64
5
+ Tag: cp39-cp39-manylinux_2_28_aarch64
6
+
@@ -0,0 +1,2 @@
1
+ xoscar
2
+ xoscar_pygloo