xoscar 0.7.0rc1__cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl → 0.7.2__cp39-cp39-manylinux_2_17_aarch64.manylinux2014_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.

xoscar/__init__.py CHANGED
@@ -33,6 +33,7 @@ from .api import (
33
33
  wait_actor_pool_recovered,
34
34
  get_pool_config,
35
35
  generator,
36
+ wait_for,
36
37
  )
37
38
  from .backends import allocate_strategy
38
39
  from .backends.pool import MainActorPoolType
xoscar/api.py CHANGED
@@ -26,6 +26,7 @@ from numbers import Number
26
26
  from typing import (
27
27
  TYPE_CHECKING,
28
28
  Any,
29
+ Awaitable,
29
30
  Dict,
30
31
  Generic,
31
32
  List,
@@ -181,6 +182,39 @@ async def create_actor_pool(
181
182
  )
182
183
 
183
184
 
185
+ async def wait_for(fut: Awaitable[Any], timeout: int | float | None = None) -> Any:
186
+ # asyncio.wait_for() on Xoscar actor call cannot work as expected,
187
+ # because when time out, the future will be cancelled, but an actor call will catch this error,
188
+ # and send a CancelMessage to the dest pool, if the CancelMessage cannot be processed correctly(e.g. the dest pool hangs),
189
+ # the time out will never happen. Thus this PR added a new API so that no matter the CancelMessage delivered or not,
190
+ # the timeout will happen as expected.
191
+ loop = asyncio.get_running_loop()
192
+ new_fut = loop.create_future()
193
+ task = asyncio.ensure_future(fut)
194
+
195
+ def on_done(f: asyncio.Future):
196
+ if new_fut.done():
197
+ return
198
+ if f.cancelled():
199
+ new_fut.cancel()
200
+ elif f.exception():
201
+ new_fut.set_exception(f.exception()) # type: ignore
202
+ else:
203
+ new_fut.set_result(f.result())
204
+
205
+ task.add_done_callback(on_done)
206
+
207
+ try:
208
+ return await asyncio.wait_for(new_fut, timeout)
209
+ except asyncio.TimeoutError:
210
+ if not task.done():
211
+ try:
212
+ task.cancel() # Try to cancel without waiting
213
+ except Exception:
214
+ logger.warning("Failed to cancel task", exc_info=True)
215
+ raise
216
+
217
+
184
218
  def buffer_ref(address: str, buffer: Any) -> BufferRef:
185
219
  """
186
220
  Init buffer ref according address and buffer.
Binary file
xoscar/utils.py CHANGED
@@ -89,7 +89,7 @@ def wrap_exception(
89
89
  ) -> BaseException:
90
90
  """Generate an exception wraps the cause exception."""
91
91
 
92
- def __init__(self):
92
+ def __init__(self, *args, **kwargs):
93
93
  pass
94
94
 
95
95
  def __getattr__(self, item):
xoscar/virtualenv/core.py CHANGED
@@ -14,6 +14,7 @@
14
14
 
15
15
  from __future__ import annotations
16
16
 
17
+ import importlib
17
18
  from abc import ABC, abstractmethod
18
19
  from pathlib import Path
19
20
 
@@ -35,12 +36,49 @@ class VirtualEnvManager(ABC):
35
36
  def install_packages(self, packages: list[str], **kwargs):
36
37
  pass
37
38
 
39
+ @staticmethod
40
+ def process_packages(packages: list[str]) -> list[str]:
41
+ """
42
+ Process a list of package names, replacing placeholders like #system_<package>#
43
+ with the installed version of the corresponding package from the system environment.
44
+
45
+ Example:
46
+ "#system_torch#" -> "torch==2.1.0" (if torch 2.1.0 is installed)
47
+
48
+ Args:
49
+ packages (list[str]): A list of package names, which may include placeholders.
50
+
51
+ Returns:
52
+ list[str]: A new list with resolved package names and versions.
53
+
54
+ Raises:
55
+ RuntimeError: If a specified system package is not found in the environment.
56
+ """
57
+ processed = []
58
+
59
+ for pkg in packages:
60
+ if pkg.startswith("#system_") and pkg.endswith("#"):
61
+ real_pkg = pkg[
62
+ len("#system_") : -1
63
+ ] # Extract actual package name, e.g., "torch"
64
+ try:
65
+ version = importlib.metadata.version(real_pkg)
66
+ except importlib.metadata.PackageNotFoundError:
67
+ raise RuntimeError(
68
+ f"System package '{real_pkg}' not found. Cannot resolve '{pkg}'."
69
+ )
70
+ processed.append(f"{real_pkg}=={version}")
71
+ else:
72
+ processed.append(pkg)
73
+
74
+ return processed
75
+
38
76
  @abstractmethod
39
77
  def cancel_install(self):
40
78
  pass
41
79
 
42
80
  @abstractmethod
43
- def get_python_path(self) -> str:
81
+ def get_python_path(self) -> str | None:
44
82
  pass
45
83
 
46
84
  @abstractmethod
xoscar/virtualenv/uv.py CHANGED
@@ -46,17 +46,28 @@ class UVVirtualEnvManager(VirtualEnvManager):
46
46
  if not packages:
47
47
  return
48
48
 
49
+ # extend the ability of pip
50
+ # maybe replace #system_torch# to the real version
51
+ packages = self.process_packages(packages)
52
+
49
53
  cmd = ["uv", "pip", "install", "-p", str(self.env_path)] + packages
50
54
 
51
55
  # Handle known pip-related kwargs
52
56
  if "index_url" in kwargs and kwargs["index_url"]:
53
57
  cmd += ["-i", kwargs["index_url"]]
54
- if "extra_index_url" in kwargs and kwargs["extra_index_url"]:
55
- cmd += ["--extra-index-url", kwargs["extra_index_url"]]
56
- if "find_links" in kwargs and kwargs["find_links"]:
57
- cmd += ["-f", kwargs["find_links"]]
58
- if "trusted_host" in kwargs and kwargs["trusted_host"]:
59
- cmd += ["--trusted-host", kwargs["trusted_host"]]
58
+ param_and_option = [
59
+ ("extra_index_url", "--extra-index-url"),
60
+ ("find_links", "-f"),
61
+ ("trusted_host", "--trusted-host"),
62
+ ]
63
+ for param, option in param_and_option:
64
+ if param in kwargs and kwargs[param]:
65
+ param_value = kwargs[param]
66
+ if isinstance(param_value, list):
67
+ for it in param_value:
68
+ cmd += [option, it]
69
+ else:
70
+ cmd += [option, param_value]
60
71
 
61
72
  self._install_process = process = subprocess.Popen(cmd)
62
73
  returncode = process.wait()
@@ -71,8 +82,10 @@ class UVVirtualEnvManager(VirtualEnvManager):
71
82
  self._install_process.terminate()
72
83
  self._install_process.wait()
73
84
 
74
- def get_python_path(self) -> str:
75
- return str(self.env_path.joinpath("bin/python"))
85
+ def get_python_path(self) -> str | None:
86
+ if self.env_path.exists():
87
+ return str(self.env_path.joinpath("bin/python"))
88
+ return None
76
89
 
77
90
  def get_lib_path(self) -> str:
78
91
  return sysconfig.get_path("purelib", vars={"base": str(self.env_path)})
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xoscar
3
- Version: 0.7.0rc1
3
+ Version: 0.7.2
4
4
  Summary: Python actor framework for heterogeneous computing.
5
5
  Home-page: http://github.com/xorbitsai/xoscar
6
6
  Author: Qin Xuye
@@ -1,16 +1,16 @@
1
- xoscar/__init__.py,sha256=0zX8kKaio3ZIrlzB79WybcravMJw1OxPWjDspTgJFyQ,1608
2
- xoscar/_utils.cpython-39-aarch64-linux-gnu.so,sha256=qRMQ7LzvQNxm00SYPXHHSt7FwK3QERk5buM_SE1NDi8,1183744
1
+ xoscar/__init__.py,sha256=sy7Wtn2EuQZI0I4Az_MfsBVZm4G0DRj46qRyExgmnJk,1622
2
+ xoscar/_utils.cpython-39-aarch64-linux-gnu.so,sha256=zhOkx2BC5eJmT5MYHeInAMh2V_c3RqspZph3m2ztPtU,1187200
3
3
  xoscar/_utils.pxd,sha256=5KYAL3jfPdejsHnrGGT2s--ZUX5SXznQWpHVSno429k,1157
4
4
  xoscar/_utils.pyx,sha256=frgVQ5xGp92jBKc4PsPmjOlVsXlKeHWtTOAMfHmBaII,7380
5
5
  xoscar/_version.py,sha256=ClSPrUjgGRGHIkVMQV9XQnkQ-n0akJMnq_rh819nqFE,23719
6
- xoscar/api.py,sha256=3hztPoOxg8A_mlhWyWgVP7FMXG0PATA1TP4Rbaj7A-g,13327
6
+ xoscar/api.py,sha256=zxNqOjGiTIKuAip9WJ0LOoM7yevD6P5rb-sLynpZ2Zo,14648
7
7
  xoscar/backend.py,sha256=is436OPkZfSpQXaoqTRVta5eoye_pp45RFgCstAk2hU,1850
8
8
  xoscar/batch.py,sha256=DpArS0L3WYJ_HVPG-6hSYEwoAFY1mY2-mlC4Jp5M_Dw,7872
9
9
  xoscar/constants.py,sha256=QHHSREw6uWBBjQDCFqlNfTvBZgniJPGy42KSIsR8Fqw,787
10
- xoscar/context.cpython-39-aarch64-linux-gnu.so,sha256=A8AZvvYAELnnsZwhIsCRxiHXBA9_85ca7nZIlAmajH4,1443792
10
+ xoscar/context.cpython-39-aarch64-linux-gnu.so,sha256=E2UT-jWWX3TDGWUkOtS1c5E7JJMeFY_rDrCLrVitlkQ,1529080
11
11
  xoscar/context.pxd,sha256=qKa0OyDPZtVymftSh447m-RzFZgmz8rGqQBa7qlauvc,725
12
12
  xoscar/context.pyx,sha256=8CdgPnWcE9eOp3N600WgDQ03MCi8P73eUOGcfV7Zksg,10942
13
- xoscar/core.cpython-39-aarch64-linux-gnu.so,sha256=k8i9g565_jnfK2rLHgskz03POievPWCxWQ5BD4LPuvc,3505232
13
+ xoscar/core.cpython-39-aarch64-linux-gnu.so,sha256=JVckWxjPXoTliOdVnG2xIJxXwBTlMqNkMKlG8rWUhM8,3658944
14
14
  xoscar/core.pxd,sha256=I_C2ka7XryyGnnAVXUVm8xfS1gtIrCs6X-9rswgOcUU,1317
15
15
  xoscar/core.pyx,sha256=phN-yYV0A0QI8WFi2jCu0nc4CnShTepfDi0V7ZrLYPY,22092
16
16
  xoscar/debug.py,sha256=9Z8SgE2WaKYQcyDo-5-DxEJQ533v7kWjrvCd28pSx3E,5069
@@ -19,7 +19,7 @@ xoscar/errors.py,sha256=wBlQOKsXf0Fc4skN39tDie0YZT-VIAuLNRgoDl2pZcA,1241
19
19
  xoscar/libcpp.pxd,sha256=DJqBxLFOKL4iRr9Kale5UH3rbvPRD1x5bTSOPHFpz9I,1147
20
20
  xoscar/nvutils.py,sha256=qmW4mKLU0WB2yCs198ccQOgLL02zB7Fsa-AotO3NOmg,20412
21
21
  xoscar/profiling.py,sha256=BC5OF0HzSaXv8V7w-y-B8r5gV5DgxHFoTEIF6jCMioQ,8015
22
- xoscar/utils.py,sha256=jUw6OICZUPBbmS1b3GE4vLctJf6fCKXrYtLtBuK-Oqc,16483
22
+ xoscar/utils.py,sha256=MaKiW4Vphwhh8c0yoqN8G8hbJr1zXgpf49EdvmGc1ZU,16500
23
23
  xoscar/aio/__init__.py,sha256=kViDKR_kJe59VQViHITKEfBcIgN4ZJblUyd8zl0E3ZI,675
24
24
  xoscar/aio/base.py,sha256=9j0f1piwfE5R5GIvV212vSD03ixdaeSzSSsO2kxJZVE,2249
25
25
  xoscar/aio/file.py,sha256=PBtkLp-Q7XtYl-zk00s18TtgIrkNr60J3Itf66ctO1o,1486
@@ -30,7 +30,7 @@ xoscar/backends/allocate_strategy.py,sha256=tC1Nbq2tJohahUwd-zoRYHEDX65wyuX8tmeY
30
30
  xoscar/backends/config.py,sha256=4tZMiXAMMS8qQ4SX_LjONLtSQVfZTx3m-IK3EqbkYdk,5375
31
31
  xoscar/backends/context.py,sha256=XfDPG2eDhAhE6hWBEkEsHTnyyOYN9R3houlMjAL7BFw,16329
32
32
  xoscar/backends/core.py,sha256=EH-fHlV9x3bnruEHaUtGYO7osKLfLJ4AQHtuzA_mr2g,10857
33
- xoscar/backends/message.cpython-39-aarch64-linux-gnu.so,sha256=pd7mZFf7M7yca6HejdEXk-gkavQ-xqfWxGe0aFKi3ao,3337768
33
+ xoscar/backends/message.cpython-39-aarch64-linux-gnu.so,sha256=TaJyZnIR5kin_75EY391h0ZzeqqTzA6VoaWeyTu9HEg,3426840
34
34
  xoscar/backends/message.pyx,sha256=krGVtZ1YDaZX8yWhaNHwZiudQooLvcGlw6x3Sq7jxjE,19685
35
35
  xoscar/backends/pool.py,sha256=nrh8qobaukkjUOOOTR9t90i-wbXlgma3TNRjvwkwmcg,60528
36
36
  xoscar/backends/router.py,sha256=MVl5naz-FYf-Wla7XRn3kRxOpWV0SjKDsKNluifVA8M,10532
@@ -68,7 +68,7 @@ xoscar/metrics/backends/prometheus/__init__.py,sha256=h_JgzSqV5lP6vQ6XX_17kE4IY4
68
68
  xoscar/metrics/backends/prometheus/prometheus_metric.py,sha256=MxoMvVrg0pOkKpkjJ0PcAuEaaEJR2FZljmPrLjQ1-oc,2050
69
69
  xoscar/serialization/__init__.py,sha256=v76XC2OQLp-Yk4_U3_IVguEylMeyRw1UrkU_DPDMh0U,856
70
70
  xoscar/serialization/aio.py,sha256=5DySPgDxU43ec7_5Ct44-Oqt7YNSJBfuf8VdQgQlChA,4731
71
- xoscar/serialization/core.cpython-39-aarch64-linux-gnu.so,sha256=J4JMEMbAygFLrMPwyRbmsysjmqs0iRGN35AIQbC3iK0,3203944
71
+ xoscar/serialization/core.cpython-39-aarch64-linux-gnu.so,sha256=JbBQUyjRjdGIGOxaK_biho6n3283JDuD6W1nTGygp-c,3584672
72
72
  xoscar/serialization/core.pxd,sha256=k4RoJgX5E5LGs4jdCQ7vvcn26MabXbrWoWhkO49X6YI,985
73
73
  xoscar/serialization/core.pyx,sha256=bjR-zXGm9qersk7kYPzpjpMIxDl_Auur4BCubRfKmfA,29626
74
74
  xoscar/serialization/cuda.py,sha256=iFUEnN4SiquBIhyieyOrfw3TnKnW-tU_vYgqOxO_DrA,3758
@@ -78,9 +78,9 @@ xoscar/serialization/numpy.py,sha256=5Kem87CvpJmzUMp3QHk4WeHU30FoQWTJJP2SwIcaQG0
78
78
  xoscar/serialization/pyfury.py,sha256=sifOnVMYoS82PzZEkzkfxesmMHei23k5UAUUKUyoOYQ,1163
79
79
  xoscar/serialization/scipy.py,sha256=yOEi0NB8cqQ6e2UnCZ1w006RsB7T725tIL-DM_hNcsU,2482
80
80
  xoscar/virtualenv/__init__.py,sha256=65t9_X1DvbanNjFy366SiiWZrRTpa9SXWMXPmqayE-4,1117
81
- xoscar/virtualenv/core.py,sha256=Rob00FR0K8ev_8cEpgARJuOgm8hHy7H5ASnmgEttXik,1335
82
- xoscar/virtualenv/uv.py,sha256=sdMx4bneEYaZPPJRREQnkcV84QaTS5bMNV-CRtlzIsE,2964
83
- xoscar-0.7.0rc1.dist-info/METADATA,sha256=uyQqQ6egyhRkr-DqLMEk3Zo1uW3C-UrKwacDLVMxxdE,9137
84
- xoscar-0.7.0rc1.dist-info/WHEEL,sha256=OyU_a3_0g4nHrDfscT3ntE6UTOgLWum2-dKsAfzpQqc,150
85
- xoscar-0.7.0rc1.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
86
- xoscar-0.7.0rc1.dist-info/RECORD,,
81
+ xoscar/virtualenv/core.py,sha256=dZqwg2IzHsLEERvohZx0rvBINopMRUImqxG3HHGO0q4,2744
82
+ xoscar/virtualenv/uv.py,sha256=_A32kMVtTolw8wb0rFQONbw_pAFJgNVMJo1s1WkqFrc,3329
83
+ xoscar-0.7.2.dist-info/METADATA,sha256=kycUtCi7lCcrW_pSYGtGWuB1ZFRGxkF2Ew7BmrP24Xk,9134
84
+ xoscar-0.7.2.dist-info/WHEEL,sha256=OyU_a3_0g4nHrDfscT3ntE6UTOgLWum2-dKsAfzpQqc,150
85
+ xoscar-0.7.2.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
86
+ xoscar-0.7.2.dist-info/RECORD,,