xoscar 0.8.0__cp313-cp313-win_amd64.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 (94) hide show
  1. xoscar/__init__.py +61 -0
  2. xoscar/_utils.cp313-win_amd64.pyd +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 +352 -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 +509 -0
  32. xoscar/backends/indigen/shared_memory.py +548 -0
  33. xoscar/backends/message.cp313-win_amd64.pyd +0 -0
  34. xoscar/backends/message.pyi +255 -0
  35. xoscar/backends/message.pyx +646 -0
  36. xoscar/backends/pool.py +1630 -0
  37. xoscar/backends/router.py +285 -0
  38. xoscar/backends/test/__init__.py +16 -0
  39. xoscar/backends/test/backend.py +38 -0
  40. xoscar/backends/test/pool.py +233 -0
  41. xoscar/batch.py +256 -0
  42. xoscar/collective/__init__.py +27 -0
  43. xoscar/collective/backend/__init__.py +13 -0
  44. xoscar/collective/backend/nccl_backend.py +160 -0
  45. xoscar/collective/common.py +102 -0
  46. xoscar/collective/core.py +737 -0
  47. xoscar/collective/process_group.py +687 -0
  48. xoscar/collective/utils.py +41 -0
  49. xoscar/collective/uv.dll +0 -0
  50. xoscar/collective/xoscar_pygloo.cp313-win_amd64.pyd +0 -0
  51. xoscar/collective/xoscar_pygloo.pyi +239 -0
  52. xoscar/constants.py +23 -0
  53. xoscar/context.cp313-win_amd64.pyd +0 -0
  54. xoscar/context.pxd +21 -0
  55. xoscar/context.pyx +368 -0
  56. xoscar/core.cp313-win_amd64.pyd +0 -0
  57. xoscar/core.pxd +51 -0
  58. xoscar/core.pyx +664 -0
  59. xoscar/debug.py +188 -0
  60. xoscar/driver.py +42 -0
  61. xoscar/errors.py +63 -0
  62. xoscar/libcpp.pxd +31 -0
  63. xoscar/metrics/__init__.py +21 -0
  64. xoscar/metrics/api.py +288 -0
  65. xoscar/metrics/backends/__init__.py +13 -0
  66. xoscar/metrics/backends/console/__init__.py +13 -0
  67. xoscar/metrics/backends/console/console_metric.py +82 -0
  68. xoscar/metrics/backends/metric.py +149 -0
  69. xoscar/metrics/backends/prometheus/__init__.py +13 -0
  70. xoscar/metrics/backends/prometheus/prometheus_metric.py +70 -0
  71. xoscar/nvutils.py +717 -0
  72. xoscar/profiling.py +260 -0
  73. xoscar/serialization/__init__.py +20 -0
  74. xoscar/serialization/aio.py +142 -0
  75. xoscar/serialization/core.cp313-win_amd64.pyd +0 -0
  76. xoscar/serialization/core.pxd +28 -0
  77. xoscar/serialization/core.pyi +57 -0
  78. xoscar/serialization/core.pyx +944 -0
  79. xoscar/serialization/cuda.py +111 -0
  80. xoscar/serialization/exception.py +48 -0
  81. xoscar/serialization/mlx.py +67 -0
  82. xoscar/serialization/numpy.py +82 -0
  83. xoscar/serialization/pyfury.py +37 -0
  84. xoscar/serialization/scipy.py +72 -0
  85. xoscar/utils.py +522 -0
  86. xoscar/virtualenv/__init__.py +34 -0
  87. xoscar/virtualenv/core.py +268 -0
  88. xoscar/virtualenv/platform.py +56 -0
  89. xoscar/virtualenv/utils.py +100 -0
  90. xoscar/virtualenv/uv.py +321 -0
  91. xoscar-0.8.0.dist-info/METADATA +229 -0
  92. xoscar-0.8.0.dist-info/RECORD +94 -0
  93. xoscar-0.8.0.dist-info/WHEEL +5 -0
  94. xoscar-0.8.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,321 @@
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
+ if not packages:
243
+ return
244
+
245
+ log = kwargs.pop("log", False)
246
+ skip_installed = kwargs.pop("skip_installed", SKIP_INSTALLED)
247
+ uv_path = self._get_uv_path()
248
+
249
+ if skip_installed:
250
+ packages = self._filter_packages_not_installed(packages)
251
+ if not packages:
252
+ logger.info("All required packages are already installed.")
253
+ return
254
+
255
+ cmd = [
256
+ uv_path,
257
+ "pip",
258
+ "install",
259
+ "-p",
260
+ str(self.env_path),
261
+ "--color=always",
262
+ "--no-deps",
263
+ ] + packages
264
+ else:
265
+ cmd = [
266
+ uv_path,
267
+ "pip",
268
+ "install",
269
+ "-p",
270
+ str(self.env_path),
271
+ "--color=always",
272
+ ] + packages
273
+
274
+ if "index_url" in kwargs and kwargs["index_url"]:
275
+ cmd += ["-i", kwargs["index_url"]]
276
+ param_and_option = [
277
+ ("extra_index_url", "--extra-index-url"),
278
+ ("find_links", "-f"),
279
+ ("trusted_host", "--trusted-host"),
280
+ ]
281
+ for param, option in param_and_option:
282
+ if param in kwargs and kwargs[param]:
283
+ val = kwargs[param]
284
+ cmd += (
285
+ [option, val]
286
+ if isinstance(val, str)
287
+ else [opt for v in val for opt in (option, v)]
288
+ )
289
+
290
+ if kwargs.get("no_build_isolation", False):
291
+ cmd += ["--no-build-isolation"]
292
+
293
+ logger.info("Installing packages via command: %s", cmd)
294
+ if not log:
295
+ self._install_process = process = subprocess.Popen(cmd)
296
+ returncode = process.wait()
297
+ else:
298
+ with run_subprocess_with_logger(cmd) as process:
299
+ self._install_process = process
300
+ returncode = process.returncode
301
+
302
+ self._install_process = None
303
+ if returncode != 0:
304
+ raise subprocess.CalledProcessError(returncode, cmd)
305
+
306
+ def cancel_install(self):
307
+ if self._install_process and self._install_process.poll() is None:
308
+ self._install_process.terminate()
309
+ self._install_process.wait()
310
+
311
+ def get_python_path(self) -> str | None:
312
+ if self.env_path.exists():
313
+ return str(self.env_path.joinpath("bin/python"))
314
+ return None
315
+
316
+ def get_lib_path(self) -> str:
317
+ return sysconfig.get_path("purelib", vars={"base": str(self.env_path)})
318
+
319
+ def remove_env(self):
320
+ if self.env_path.exists():
321
+ shutil.rmtree(self.env_path, ignore_errors=True)
@@ -0,0 +1,229 @@
1
+ Metadata-Version: 2.4
2
+ Name: xoscar
3
+ Version: 0.8.0
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 :: 3.13
19
+ Classifier: Programming Language :: Python :: Implementation :: CPython
20
+ Classifier: Topic :: Software Development :: Libraries
21
+ Description-Content-Type: text/markdown
22
+ Requires-Dist: numpy>=1.14.0
23
+ Requires-Dist: pandas>=1.0.0
24
+ Requires-Dist: scipy>=1.0.0; sys_platform != "win32" or python_version >= "3.10"
25
+ Requires-Dist: scipy<=1.9.1,>=1.0.0; sys_platform == "win32" and python_version < "3.10"
26
+ Requires-Dist: cloudpickle>=1.5.0
27
+ Requires-Dist: psutil>=5.9.0
28
+ Requires-Dist: tblib>=1.7.0
29
+ Requires-Dist: uvloop>=0.14.0; sys_platform != "win32"
30
+ Requires-Dist: packaging
31
+ Requires-Dist: click
32
+ Provides-Extra: dev
33
+ Requires-Dist: cython>=0.29; extra == "dev"
34
+ Requires-Dist: pytest>=3.5.0; extra == "dev"
35
+ Requires-Dist: pytest-cov>=2.5.0; extra == "dev"
36
+ Requires-Dist: pytest-timeout>=1.2.0; extra == "dev"
37
+ Requires-Dist: pytest-forked>=1.0; extra == "dev"
38
+ Requires-Dist: pytest-asyncio>=0.14.0; extra == "dev"
39
+ Requires-Dist: ipython>=6.5.0; extra == "dev"
40
+ Requires-Dist: sphinx; extra == "dev"
41
+ Requires-Dist: pydata-sphinx-theme>=0.3.0; extra == "dev"
42
+ Requires-Dist: sphinx-intl>=0.9.9; extra == "dev"
43
+ Requires-Dist: flake8>=3.8.0; extra == "dev"
44
+ Requires-Dist: black; extra == "dev"
45
+ Requires-Dist: uv; extra == "dev"
46
+ Requires-Dist: click; extra == "dev"
47
+ Provides-Extra: doc
48
+ Requires-Dist: ipython>=6.5.0; extra == "doc"
49
+ Requires-Dist: sphinx; extra == "doc"
50
+ Requires-Dist: pydata-sphinx-theme>=0.3.0; extra == "doc"
51
+ Requires-Dist: sphinx-intl>=0.9.9; extra == "doc"
52
+ Provides-Extra: extra
53
+ Requires-Dist: pyarrow>=5.0.0; extra == "extra"
54
+ Provides-Extra: kubernetes
55
+ Requires-Dist: kubernetes>=10.0.0; extra == "kubernetes"
56
+ Provides-Extra: ray
57
+ Requires-Dist: xoscar_ray>=0.0.1; extra == "ray"
58
+ Dynamic: description
59
+ Dynamic: description-content-type
60
+
61
+ <div align="center">
62
+ <img width="77%" alt="" src="https://raw.githubusercontent.com/xprobe-inc/xoscar/main/doc/source/_static/Xoscar.svg"><br>
63
+ </div>
64
+
65
+ # Python actor framework for heterogeneous computing.
66
+ [![PyPI Latest Release](https://img.shields.io/pypi/v/xoscar.svg?style=for-the-badge)](https://pypi.org/project/xoscar/)
67
+ [![Coverage](https://img.shields.io/codecov/c/github/xorbitsai/xoscar?style=for-the-badge)](https://codecov.io/gh/xorbitsai/xoscar)
68
+ [![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)
69
+ [![License](https://img.shields.io/pypi/l/xoscar.svg?style=for-the-badge)](https://github.com/xorbitsai/xoscar/blob/main/LICENSE)
70
+
71
+ ## What is actor
72
+ Writing parallel and distributed programs is often challenging and requires a lot of time to deal with concurrency
73
+ issues. Actor model provides a high-level, scalable and robust abstraction for building distributed applications.
74
+ It provides several benefits:
75
+ - Scalability: Actors easily scale across nodes. The asynchronous, non-blocking nature of actors allows them to handle huge volumes of concurrent tasks efficiently.
76
+ - Concurrency: The actor model abstracts over concurrency, allowing developers to avoid raw threads and locks.
77
+ - Modularity: An actor system decomposes naturally into a collection of actors that can be understood independently. Actor logic is encapsulated within the actor itself.
78
+
79
+ ## Why Xoscar
80
+ Xoscar implements the actor model in Python and provides user-friendly APIs that offer significant benefits for building
81
+ applications on heterogeneous hardware:
82
+ - **Abstraction over low-level communication details**: Xoscar handles all communication between actors transparently,
83
+ whether on CPUs, GPUs, or across nodes. Developers focus on application logic rather than managing hardware resources
84
+ and optimizing data transfer.
85
+ - **Flexible actor models**: Xoscar supports both stateful and stateless actors. Stateful actors ensure thread safety for
86
+ concurrent systems while stateless actors can handle massive volumes of concurrent messages. Developers choose the
87
+ appropriate actor model for their needs.
88
+ - **Batch method**: Xoscar provides a batch interface to significantly improve call efficiency when an actor interface is
89
+ invoked a large number of times.
90
+ - **Advanced debugging support**: Xoscar can detect potential issues like deadlocks, long-running calls, and performance
91
+ bottlenecks that would otherwise be nearly impossible to troubleshoot in a heterogeneous environment.
92
+ - **Automated recovery**: If an actor fails for any reason, Xoscar will automatically restart it if you want. It can monitor
93
+ actors and restart them upon failure, enabling fault-tolerant systems.
94
+
95
+ ## Overview
96
+ ![architecture.png](doc/source/_static/architecture.png)
97
+ Xoscar allows you to create multiple actor pools on each worker node, typically binding an actor pool to a CPU core or
98
+ a GPU card. Xoscar provides allocation policies so that whenever an actor is created, it will be instantiated in the
99
+ appropriate pool based on the specified policy.
100
+
101
+ When actors communicate, Xoscar will choose the optimal communication mechanism based on which pools the actors
102
+ belong to. This allows Xoscar to optimize communication in heterogeneous environments with multiple processing
103
+ units and accelerators.
104
+
105
+ ## Where to get it
106
+
107
+ ### PyPI
108
+ Binary installers for the latest released version are available at the [Python
109
+ Package Index (PyPI)](https://pypi.org/project/xoscar).
110
+
111
+ ```shell
112
+ # PyPI
113
+ pip install xoscar
114
+ ```
115
+
116
+ ### Build from source
117
+ The source code is currently hosted on GitHub at: https://github.com/xorbitsai/xoscar .
118
+
119
+ Building from source requires that you have cmake and gcc installed on your system.
120
+
121
+ - cmake >= 3.11
122
+ - gcc >= 8
123
+
124
+ ```shell
125
+ # If you have never cloned xoscar before
126
+ git clone --recursive https://github.com/xorbitsai/xoscar.git
127
+ cd xoscar/python
128
+ pip install -e .
129
+
130
+ # If you have already cloned xoscar before
131
+ cd xoscar
132
+ git submodule init
133
+ git submodule update
134
+ cd python && pip install -e .
135
+ ```
136
+
137
+ ## APIs
138
+ Here are basic APIs for Xoscar.
139
+ #### Define an actor
140
+ ```python
141
+ import xoscar as xo
142
+
143
+ # stateful actor, for stateless actor, inherit from xo.StatelessActor
144
+ class MyActor(xo.Actor):
145
+ def __init__(self, *args, **kwargs):
146
+ pass
147
+
148
+ async def __post_create__(self):
149
+ # called after created
150
+ pass
151
+
152
+ async def __pre_destroy__(self):
153
+ # called before destroy
154
+ pass
155
+
156
+ def method_a(self, arg_1, arg_2, **kw_1): # user-defined function
157
+ pass
158
+
159
+ async def method_b(self, arg_1, arg_2, **kw_1): # user-defined async function
160
+ pass
161
+ ```
162
+
163
+ #### Create an actor
164
+ ```python
165
+ import xoscar as xo
166
+
167
+ actor_ref = await xo.create_actor(
168
+ MyActor, 1, 2, a=1, b=2,
169
+ address='<ip>:<port>', uid='UniqueActorName')
170
+ ```
171
+
172
+ #### Get an actor reference
173
+ ```python
174
+ import xoscar as xo
175
+
176
+ actor_ref = await xo.actor_ref(address, actor_id)
177
+ ```
178
+
179
+ #### Invoke a method
180
+ ```python
181
+ # send
182
+ await actor_ref.method_a.send(1, 2, a=1, b=2)
183
+ # equivalent to actor_ref.method_a.send
184
+ await actor_ref.method_a(1, 2, a=1, b=2)
185
+ # tell, it sends a message asynchronously and does not wait for a response.
186
+ await actor_ref.method_a.tell(1, 2, a=1, b=2)
187
+ ```
188
+ ### Batch method
189
+ Xoscar provides a set of APIs to write batch methods. You can simply add a `@extensible` decorator to your actor method
190
+ and create a batch version. All calls wrapped in a batch will be sent together, reducing possible RPC cost.
191
+ #### Define a batch method
192
+ ```python
193
+ import xoscar as xo
194
+
195
+ class ExampleActor(xo.Actor):
196
+ @xo.extensible
197
+ async def batch_method(self, a, b=None):
198
+ pass
199
+ ```
200
+ Xoscar also supports creating a batch version of the method:
201
+ ```python
202
+ class ExampleActor(xo.Actor):
203
+ @xo.extensible
204
+ async def batch_method(self, a, b=None):
205
+ raise NotImplementedError # this will redirect all requests to the batch version
206
+
207
+ @batch_method.batch
208
+ async def batch_method(self, args_list, kwargs_list):
209
+ results = []
210
+ for args, kwargs in zip(args_list, kwargs_list):
211
+ a, b = self.batch_method.bind(*args, **kwargs)
212
+ # process the request
213
+ results.append(result)
214
+ return results # return a list of results
215
+ ```
216
+ In a batch method, users can define how to more efficiently process a batch of requests.
217
+
218
+ #### Invoke a batch method
219
+ Calling batch methods is easy. You can use `<method_name>.delay` to make a batched call and use `<method_name>.batch` to send them:
220
+ ```python
221
+ ref = await xo.actor_ref(uid='ExampleActor', address='127.0.0.1:13425')
222
+ results = await ref.batch_method.batch(
223
+ ref.batch_method.delay(10, b=20),
224
+ ref.batch_method.delay(20),
225
+ )
226
+ ```
227
+
228
+ ## License
229
+ [Apache 2](LICENSE)
@@ -0,0 +1,94 @@
1
+ xoscar/__init__.py,sha256=lzCXUmkuIjcjkiNQFekysdJR_ZhlbjcfR5ka1bZZNQg,1683
2
+ xoscar/_utils.cp313-win_amd64.pyd,sha256=pQdrnZVhRk71ojJFA0CqYoUNU1UTjNYnsFf0IrEcSkk,108544
3
+ xoscar/_utils.pxd,sha256=rlNbTg5lhXA-jCOLksqF4jhUlNn0xw2jx1HxdLa34pc,1193
4
+ xoscar/_utils.pyx,sha256=TWScgqmJGYzjbWBOShBLkq07ldfYEQ5fw6V4OytX_IA,7626
5
+ xoscar/_version.py,sha256=bsfCVAo_o9LkiP3AjPsP4SRRqhjuS0t4D1WGJPzbdls,24412
6
+ xoscar/api.py,sha256=QQDHn-_FiDExmOxEk8BUnq4Qrx13VX3shSlEEqPQJo0,15175
7
+ xoscar/backend.py,sha256=8G5JwjoOT6Q2slb11eXNApxgcmvNQUCdQzkoIMDwLcQ,1917
8
+ xoscar/batch.py,sha256=Jk5BSpvMFAV9DrRy0a9tgPvIo_dt8cbJReZBL0cnOPc,8128
9
+ xoscar/constants.py,sha256=GJ1KEOxwnqksc9K_GH42TSWpQECeC6ti3KJmE3PUcTw,810
10
+ xoscar/context.cp313-win_amd64.pyd,sha256=m2C98Logzp62_TtOkrje3FfgfAUBQNAanm9zIxC0jsA,153088
11
+ xoscar/context.pxd,sha256=6n6IAbmArSRq8EjcsbS6npW8xP1jI0qOoS1fF0oyj-o,746
12
+ xoscar/context.pyx,sha256=FOJVerGOvxe2USryXEQA0rpaFX_ScxISH6QWKUcahY8,11310
13
+ xoscar/core.cp313-win_amd64.pyd,sha256=RwJwhe5xxjkTzFW-zx_3Gqrmbyv88vYgCyy6afDSESE,313856
14
+ xoscar/core.pxd,sha256=9IZP7dYGfnF1I-obIls8R8b6forxDOPbiM3v5nVslLk,1368
15
+ xoscar/core.pyx,sha256=U6jCZN74MQHi7HkQRaVGm_w5q-FMsw0nnE3aU6533_Q,22756
16
+ xoscar/debug.py,sha256=hrmxIH6zvTKasQo6PUUgXu5mgEsR0g87Fvpw7CoHipg,5257
17
+ xoscar/driver.py,sha256=EjZ7HkdSgwtE9pXGiJXXwgWfxaIn10eZyqKpBhelaoc,1414
18
+ xoscar/errors.py,sha256=hfIAlYuSVfB3dAQYr8hTLAMmfy5en6Y8mihdtw1gTEE,1304
19
+ xoscar/libcpp.pxd,sha256=XGy887HXdRsvF47s-A7PvHX6Gaf15d_azRscWJY0Hc8,1178
20
+ xoscar/nvutils.py,sha256=z6RCVs0sgKFm55TTgAYG3qy5f_AKJzjcH2kcRB-wTJQ,21129
21
+ xoscar/profiling.py,sha256=LUqkj6sSxaFj0ltS7Yk2kFsh5ieHY417xypTYHwQOb4,8275
22
+ xoscar/utils.py,sha256=v2HDyjVe5uiJEtUnzHeOyXCqfLz0k4RRmv0RS8iQlxA,17104
23
+ xoscar/aio/__init__.py,sha256=ZLJlVJJH5EhItKD6tLTBri-4FV4kT1O2qdIfBC-df98,691
24
+ xoscar/aio/base.py,sha256=ytknTCjTjNQbTM7l7QGXqPYYUkD7qq-zVBGVZ34L1Tc,2335
25
+ xoscar/aio/file.py,sha256=x1wrvDgtTFMv-6gjSPpBU26jAO5uEAlXGGnFtx7uevQ,1545
26
+ xoscar/aio/lru.py,sha256=KyUfrmqQ2ZkU07Reih-VvUKP1VOg1jmwprEAcZ8pdNE,6539
27
+ xoscar/aio/parallelism.py,sha256=egpScbxggXzAdc_evLsNmUyHafuxu62JWAYS-2ISSuI,1332
28
+ xoscar/backends/__init__.py,sha256=g9OllTquu9MRB5nySVoyiRv2z-_OSALWrOhwt7L9WXc,657
29
+ xoscar/backends/allocate_strategy.py,sha256=DzvTlixwzTANURI2mDLHm3vcaugSPDxU6UQZb89KH0U,5005
30
+ xoscar/backends/config.py,sha256=86j0g_Xrl8ENPzBWi296yWg9QEcljvdKK-yJbfYTvQ0,5532
31
+ xoscar/backends/context.py,sha256=qWwksx8JxYcKR-LQA3PvXh4ReuuTTEyDaLbjpxGXcTA,16766
32
+ xoscar/backends/core.py,sha256=edlPDR3VH2tBLx3ZmtNktKOTsrG9AUDPW2Y_QRqXiLs,13197
33
+ xoscar/backends/message.cp313-win_amd64.pyd,sha256=e0D-r7gLhXmWE457pwKGgMDb1SL7aMe-4NAhYaGyRm0,249344
34
+ xoscar/backends/message.pyi,sha256=m1PrSLvj-IbrHuVfQGoPDs6prI-GJV1vQJqZ5WdQcY4,6798
35
+ xoscar/backends/message.pyx,sha256=lBEjMJv4VyxmeO9lHXJJazOajbFnTLak4PSBcLoPZvU,20331
36
+ xoscar/backends/pool.py,sha256=vLWEdTYg08nPy0tFf8nBA8gamBh1wSslsYaIsDl7vPU,62313
37
+ xoscar/backends/router.py,sha256=EjfNpQUrhFU15eYe1kRPueziHgI2gfDViUzm7ruvXDE,10817
38
+ xoscar/backends/communication/__init__.py,sha256=i0RWfN_no-xwlzLUl8Av8zZqVWxfgBaT2qbUvOLt37s,1093
39
+ xoscar/backends/communication/base.py,sha256=wmWTeE4lcB_ohqyJJ6MdzMGcrOqy2RSKRp8y-NDuFdY,7736
40
+ xoscar/backends/communication/core.py,sha256=ZM_fU0yokoPzXcJ6j-89llp2r7J9pl3gE5iImn4b4bE,2199
41
+ xoscar/backends/communication/dummy.py,sha256=h04je_WcGCjpjf-vHUsY_Rou_s370pzP1R-Q2yeBaWg,8410
42
+ xoscar/backends/communication/errors.py,sha256=-O6ZaKs6Gz7g_ZnKU2wrz8D9btowqaYuQ9u0zCYSLWo,743
43
+ xoscar/backends/communication/socket.py,sha256=4etCT3bSzCfvXlAsHtkcTLIU4PRdk6FlrjdBABPiTMY,14926
44
+ xoscar/backends/communication/ucx.py,sha256=SQh461aiqdKKZe9fC4sDroFO2FmtQ_vX0oKSQjnqoFA,20498
45
+ xoscar/backends/communication/utils.py,sha256=F-muF5_ow9JzAPAZ3d8XaGDiz3bRZOdWmWBDwQOVLe0,3761
46
+ xoscar/backends/indigen/__init__.py,sha256=Khr2aGbaIw_04NIdY7QNhdljCKbmmzLb4NeAOM3LF8M,701
47
+ xoscar/backends/indigen/__main__.py,sha256=VeHSoiqCRyx9QMFO4Bnsiblhrn63qKY604Fv476ziVk,529
48
+ xoscar/backends/indigen/backend.py,sha256=cCMkZDEKuRQlFb6v79JvWi5lfzsvAafznOeEWlw7CWY,1663
49
+ xoscar/backends/indigen/driver.py,sha256=uLPBAxG7q8ds6yc-baeYUWu_m4K1gST3_BPqkfnlarw,978
50
+ xoscar/backends/indigen/fate_sharing.py,sha256=r1U5hJ1tVOQa-ncCcX731LKbHon1i-WQdxcqwLX5sOQ,8876
51
+ xoscar/backends/indigen/pool.py,sha256=TTMbEZk5snv8ky_YbnxEd3boa3By3yyABBVKXD83HTU,19013
52
+ xoscar/backends/indigen/shared_memory.py,sha256=bfRKIvmtnUmkx9zhgwEMFO-in082Eb-YO2txFeFvhIY,19630
53
+ xoscar/backends/test/__init__.py,sha256=xgE4hbD3g46G1GDJEeozaXIk57XaahmFMNQsnRzRcrs,698
54
+ xoscar/backends/test/backend.py,sha256=Q4C6TFQzZogjugGmPh3QZw4IigL8VGCFOJ5fKkE1Uvk,1301
55
+ xoscar/backends/test/pool.py,sha256=6oxD65EQoZLQ35UA-RecXSX6cpvY0GxjNw6teT0KFyA,8490
56
+ xoscar/collective/__init__.py,sha256=3tTgFXALDbAwmEDtmBX7PN7N6ZrcPFC4evMXMIhBtsg,801
57
+ xoscar/collective/common.py,sha256=9c7xq3IOUvfA0I9GnpalUqXZOzmF6IEILv4zL64BYVE,3663
58
+ xoscar/collective/core.py,sha256=191aPxbUgWpjzrqyozndImDAQhZFmqoQdBkHFLDfXN0,24239
59
+ xoscar/collective/process_group.py,sha256=kTPbrLMJSGhqbiWvTIiz-X3W0rZWd_CFn_zUIlXbOlM,23286
60
+ xoscar/collective/utils.py,sha256=p3WEVtXvnVhkuO5mRgQBhBRFr1dKHcDKMjrbMyuiyfg,1219
61
+ xoscar/collective/uv.dll,sha256=VCSOD5waiq21jwDWVYdNqWrcqhWEV8CkA9eiHJcF8eY,620544
62
+ xoscar/collective/xoscar_pygloo.cp313-win_amd64.pyd,sha256=BY4eMxSLWUY-wgRwMcjcPx7oB8ZJx88ulk9WMJxVBtQ,795136
63
+ xoscar/collective/xoscar_pygloo.pyi,sha256=6KRzElgNBBKWh-VivUw1b5Dolp17MgwA91hQo33EysU,7616
64
+ xoscar/collective/backend/__init__.py,sha256=ddL0XEwB6InL4A6Z6eKsYKoDbMSC9s_mwLBPhOcnDfI,594
65
+ xoscar/collective/backend/nccl_backend.py,sha256=lp05ki_qhfdYEqG8HxG2ZSSfLoLlx1oMY7uwsD5I7-0,6440
66
+ xoscar/metrics/__init__.py,sha256=RjXuuYw4I2YYgD8UY2Z5yCZk0Z56xMJ1n40O80Dtxf8,726
67
+ xoscar/metrics/api.py,sha256=dtJ4QrIqQNXhJedeqOPs4TXKgrRGZFFN50xAd9SCfec,9144
68
+ xoscar/metrics/backends/__init__.py,sha256=ZHepfhCDRuK9yz4pAM7bjpWDvS3Ijp1YgyynoUFLeuU,594
69
+ xoscar/metrics/backends/metric.py,sha256=WdQMtp_x4qasJ3_HLUDaZnoCwYca0mX2QfVrOwHpuDI,4595
70
+ xoscar/metrics/backends/console/__init__.py,sha256=ZHepfhCDRuK9yz4pAM7bjpWDvS3Ijp1YgyynoUFLeuU,594
71
+ xoscar/metrics/backends/console/console_metric.py,sha256=o6uGA65Kp3yvkMSGKrIilD2MAXKih-of1yEnOfE206I,2164
72
+ xoscar/metrics/backends/prometheus/__init__.py,sha256=ZHepfhCDRuK9yz4pAM7bjpWDvS3Ijp1YgyynoUFLeuU,594
73
+ xoscar/metrics/backends/prometheus/prometheus_metric.py,sha256=65hb8O3tmsEJ7jgOrIwl_suj9SE5Tmqcfjuk0urkLvE,2120
74
+ xoscar/serialization/__init__.py,sha256=tS8C49yrW_geWNEsbgW3phK1q4YN1ojI6CN-vroIFYM,876
75
+ xoscar/serialization/aio.py,sha256=7YLXgkWpQ3ANy-TZ1qO8Mt4_J3cZFhFh2FEgUgxMT60,4873
76
+ xoscar/serialization/core.cp313-win_amd64.pyd,sha256=AJc5SB8_fWLSuThIIrT4JTlkkfxmShMUFKpBlfJkcUQ,268800
77
+ xoscar/serialization/core.pxd,sha256=X-47bqBM2Kzw5SkLqICdKD0gU6CpmLsBxC3kfW--wVk,1013
78
+ xoscar/serialization/core.pyi,sha256=Zof9373qy2lmjenSuMznEiTSCNW6WQB7rmSXrRbjUo0,1931
79
+ xoscar/serialization/core.pyx,sha256=ZKexLRnRwZXXn2045kR7xfM_szcoPNrDuouQCWtpFp8,30570
80
+ xoscar/serialization/cuda.py,sha256=Fj4Cpr_YmkGceUCo0mQn8fRvmHP_5WcLdRx6epZ3RC0,3869
81
+ xoscar/serialization/exception.py,sha256=t6yZn_Ate04UE1RbabNh7mu739sdtwarjuPXWhASx7c,1682
82
+ xoscar/serialization/mlx.py,sha256=8QOWlYmS0eFZ1bYweDQzUkSRw5MI0dt118wOGhyGk1s,2185
83
+ xoscar/serialization/numpy.py,sha256=C6WVx-Sdl2OHBAvVY34DFjAKXlekMbpc2ni6bR8wxYo,3001
84
+ xoscar/serialization/pyfury.py,sha256=3ucal29Hr7PX9_1SfB2x43FE2xw_C0rLkVv3foL7qwM,1200
85
+ xoscar/serialization/scipy.py,sha256=9ph-yoRoNiwUZTwQrn35U60VPirWlncXNAg6EXvqMR4,2554
86
+ xoscar/virtualenv/__init__.py,sha256=rhJ7I6x7aXjKOCzSqsKLwqFJMh4YC2sqchEIJNEfI58,1151
87
+ xoscar/virtualenv/core.py,sha256=nRfOcKQbb-4TjtLmeMepFnMPLySJAIFwFJsXvXnNv44,8366
88
+ xoscar/virtualenv/platform.py,sha256=pykIAB8R5uHHQc8igPt-6dHisoVscRKnUcNPrPIFWrY,1597
89
+ xoscar/virtualenv/utils.py,sha256=WzhEnwgGNQV5sRqZrdvCyQPcJqI5V9feBLM_Mr7UD-w,2975
90
+ xoscar/virtualenv/uv.py,sha256=m95UyJ9BnWHqAoRI_yT1PFB11ulr_CS_pBd_gKkOkyU,11412
91
+ xoscar-0.8.0.dist-info/METADATA,sha256=fMDJPYUbqvX4bQEEE4afIuHSk-uXcUYkTeJU6J0ld-A,9469
92
+ xoscar-0.8.0.dist-info/WHEEL,sha256=qV0EIPljj1XC_vuSatRWjn02nZIz3N1t8jsZz7HBr2U,101
93
+ xoscar-0.8.0.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
94
+ xoscar-0.8.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp313-cp313-win_amd64
5
+
@@ -0,0 +1,2 @@
1
+ xoscar
2
+ xoscar_pygloo