xoscar 0.7.0rc1__cp312-cp312-win_amd64.whl → 0.7.2__cp312-cp312-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.

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
Binary file
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/collective/uv.dll CHANGED
Binary file
Binary file
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.4
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=dlwtB7dnDp5WME6CZVQY7d9lk1yJ9s___H5UxjGlAd4,1668
2
- xoscar/_utils.cp312-win_amd64.pyd,sha256=qTSAoPZX-Di6jfGvBhQ8w5ZfaWDqB-5TAJFQE0rPZlA,115200
1
+ xoscar/__init__.py,sha256=lzCXUmkuIjcjkiNQFekysdJR_ZhlbjcfR5ka1bZZNQg,1683
2
+ xoscar/_utils.cp312-win_amd64.pyd,sha256=rNsqnCgaVQqlfZGFxrC1gThlPFzhS1H4ytVJ561diaU,108032
3
3
  xoscar/_utils.pxd,sha256=rlNbTg5lhXA-jCOLksqF4jhUlNn0xw2jx1HxdLa34pc,1193
4
4
  xoscar/_utils.pyx,sha256=TWScgqmJGYzjbWBOShBLkq07ldfYEQ5fw6V4OytX_IA,7626
5
5
  xoscar/_version.py,sha256=bsfCVAo_o9LkiP3AjPsP4SRRqhjuS0t4D1WGJPzbdls,24412
6
- xoscar/api.py,sha256=B5oXv4vgMxMteh1YNaBmNFDrUFmYa_dCdzfaWwwZnCo,13820
6
+ xoscar/api.py,sha256=QQDHn-_FiDExmOxEk8BUnq4Qrx13VX3shSlEEqPQJo0,15175
7
7
  xoscar/backend.py,sha256=8G5JwjoOT6Q2slb11eXNApxgcmvNQUCdQzkoIMDwLcQ,1917
8
8
  xoscar/batch.py,sha256=Jk5BSpvMFAV9DrRy0a9tgPvIo_dt8cbJReZBL0cnOPc,8128
9
9
  xoscar/constants.py,sha256=GJ1KEOxwnqksc9K_GH42TSWpQECeC6ti3KJmE3PUcTw,810
10
- xoscar/context.cp312-win_amd64.pyd,sha256=1mvEB4so4ahN5jIMh2ZbEUrqnmoaBszxm7j4wYGcq10,159232
10
+ xoscar/context.cp312-win_amd64.pyd,sha256=FK-IGbZJx0c5vnvJLgSRloXC-eVRRAXErFgpVBdA1MU,154112
11
11
  xoscar/context.pxd,sha256=6n6IAbmArSRq8EjcsbS6npW8xP1jI0qOoS1fF0oyj-o,746
12
12
  xoscar/context.pyx,sha256=FOJVerGOvxe2USryXEQA0rpaFX_ScxISH6QWKUcahY8,11310
13
- xoscar/core.cp312-win_amd64.pyd,sha256=Ti6S-LW_yeStV1U-wMJRZx3mWIUH1gL7ewXDxNsSqkI,332800
13
+ xoscar/core.cp312-win_amd64.pyd,sha256=PUWgzEszNfc7fDO1ezvyHRenAZyLhZmCdV88GgsNFmY,313856
14
14
  xoscar/core.pxd,sha256=9IZP7dYGfnF1I-obIls8R8b6forxDOPbiM3v5nVslLk,1368
15
15
  xoscar/core.pyx,sha256=U6jCZN74MQHi7HkQRaVGm_w5q-FMsw0nnE3aU6533_Q,22756
16
16
  xoscar/debug.py,sha256=hrmxIH6zvTKasQo6PUUgXu5mgEsR0g87Fvpw7CoHipg,5257
@@ -19,7 +19,7 @@ xoscar/errors.py,sha256=hfIAlYuSVfB3dAQYr8hTLAMmfy5en6Y8mihdtw1gTEE,1304
19
19
  xoscar/libcpp.pxd,sha256=XGy887HXdRsvF47s-A7PvHX6Gaf15d_azRscWJY0Hc8,1178
20
20
  xoscar/nvutils.py,sha256=z6RCVs0sgKFm55TTgAYG3qy5f_AKJzjcH2kcRB-wTJQ,21129
21
21
  xoscar/profiling.py,sha256=LUqkj6sSxaFj0ltS7Yk2kFsh5ieHY417xypTYHwQOb4,8275
22
- xoscar/utils.py,sha256=wiDLdRUi4hgdrKVehzDMVRpym8oEcbdpo900o3BpoMM,17000
22
+ xoscar/utils.py,sha256=lYZWgnyTLL3vowzJ37ycPPPeaxQPhunGsYadRc0sAaM,17017
23
23
  xoscar/aio/__init__.py,sha256=ZLJlVJJH5EhItKD6tLTBri-4FV4kT1O2qdIfBC-df98,691
24
24
  xoscar/aio/base.py,sha256=ytknTCjTjNQbTM7l7QGXqPYYUkD7qq-zVBGVZ34L1Tc,2335
25
25
  xoscar/aio/file.py,sha256=x1wrvDgtTFMv-6gjSPpBU26jAO5uEAlXGGnFtx7uevQ,1545
@@ -30,7 +30,7 @@ xoscar/backends/allocate_strategy.py,sha256=DzvTlixwzTANURI2mDLHm3vcaugSPDxU6UQZ
30
30
  xoscar/backends/config.py,sha256=86j0g_Xrl8ENPzBWi296yWg9QEcljvdKK-yJbfYTvQ0,5532
31
31
  xoscar/backends/context.py,sha256=qWwksx8JxYcKR-LQA3PvXh4ReuuTTEyDaLbjpxGXcTA,16766
32
32
  xoscar/backends/core.py,sha256=fbekAxys_t1Dv7if-1R6uVvC_yAxNkXLeQ1V1ZSAfC0,11161
33
- xoscar/backends/message.cp312-win_amd64.pyd,sha256=8eVSsaVL86R6jL9mOZWJHShEzs0WhiBSaiI1QeT5uQQ,284160
33
+ xoscar/backends/message.cp312-win_amd64.pyd,sha256=YwDkPAFYiUpDWTy7utsqnRsehCX1P2CvcJ1kyLVwZjo,253952
34
34
  xoscar/backends/message.pyi,sha256=m1PrSLvj-IbrHuVfQGoPDs6prI-GJV1vQJqZ5WdQcY4,6798
35
35
  xoscar/backends/message.pyx,sha256=lBEjMJv4VyxmeO9lHXJJazOajbFnTLak4PSBcLoPZvU,20331
36
36
  xoscar/backends/pool.py,sha256=bS_m8XBkfQQsCOaLEzM6HkV5e78dPPp1bCH6yjvPEss,62153
@@ -58,8 +58,8 @@ xoscar/collective/common.py,sha256=9c7xq3IOUvfA0I9GnpalUqXZOzmF6IEILv4zL64BYVE,3
58
58
  xoscar/collective/core.py,sha256=191aPxbUgWpjzrqyozndImDAQhZFmqoQdBkHFLDfXN0,24239
59
59
  xoscar/collective/process_group.py,sha256=kTPbrLMJSGhqbiWvTIiz-X3W0rZWd_CFn_zUIlXbOlM,23286
60
60
  xoscar/collective/utils.py,sha256=p3WEVtXvnVhkuO5mRgQBhBRFr1dKHcDKMjrbMyuiyfg,1219
61
- xoscar/collective/uv.dll,sha256=hErZjWl6tIzSRCAoz4BKptqN8wVEukWqpzl7fNQwLjI,620544
62
- xoscar/collective/xoscar_pygloo.cp312-win_amd64.pyd,sha256=yrYa352aGgoj4524ZId36d9qpH_vcNUY4TUHRf3PiRs,838656
61
+ xoscar/collective/uv.dll,sha256=zQEDeoVesb0MB3t0Mhxkpt3_XTFCLIGuTd9cFh_1E4g,620544
62
+ xoscar/collective/xoscar_pygloo.cp312-win_amd64.pyd,sha256=QajdyhHwrczR0kzLNOO58zmal6K-hOjvlkOpezIUCw8,838656
63
63
  xoscar/collective/xoscar_pygloo.pyi,sha256=6KRzElgNBBKWh-VivUw1b5Dolp17MgwA91hQo33EysU,7616
64
64
  xoscar/metrics/__init__.py,sha256=RjXuuYw4I2YYgD8UY2Z5yCZk0Z56xMJ1n40O80Dtxf8,726
65
65
  xoscar/metrics/api.py,sha256=dtJ4QrIqQNXhJedeqOPs4TXKgrRGZFFN50xAd9SCfec,9144
@@ -71,7 +71,7 @@ xoscar/metrics/backends/prometheus/__init__.py,sha256=ZHepfhCDRuK9yz4pAM7bjpWDvS
71
71
  xoscar/metrics/backends/prometheus/prometheus_metric.py,sha256=65hb8O3tmsEJ7jgOrIwl_suj9SE5Tmqcfjuk0urkLvE,2120
72
72
  xoscar/serialization/__init__.py,sha256=tS8C49yrW_geWNEsbgW3phK1q4YN1ojI6CN-vroIFYM,876
73
73
  xoscar/serialization/aio.py,sha256=7YLXgkWpQ3ANy-TZ1qO8Mt4_J3cZFhFh2FEgUgxMT60,4873
74
- xoscar/serialization/core.cp312-win_amd64.pyd,sha256=RUNWPYgXlM54rVXbWDDBk9yGZHkywk27OUDteibi4SQ,292352
74
+ xoscar/serialization/core.cp312-win_amd64.pyd,sha256=DWj6rJZ2QS89oXFiR9qePRy-Wku868V2ChfT_86QfG0,271360
75
75
  xoscar/serialization/core.pxd,sha256=X-47bqBM2Kzw5SkLqICdKD0gU6CpmLsBxC3kfW--wVk,1013
76
76
  xoscar/serialization/core.pyi,sha256=Zof9373qy2lmjenSuMznEiTSCNW6WQB7rmSXrRbjUo0,1931
77
77
  xoscar/serialization/core.pyx,sha256=ZKexLRnRwZXXn2045kR7xfM_szcoPNrDuouQCWtpFp8,30570
@@ -82,9 +82,9 @@ xoscar/serialization/numpy.py,sha256=C6WVx-Sdl2OHBAvVY34DFjAKXlekMbpc2ni6bR8wxYo
82
82
  xoscar/serialization/pyfury.py,sha256=3ucal29Hr7PX9_1SfB2x43FE2xw_C0rLkVv3foL7qwM,1200
83
83
  xoscar/serialization/scipy.py,sha256=9ph-yoRoNiwUZTwQrn35U60VPirWlncXNAg6EXvqMR4,2554
84
84
  xoscar/virtualenv/__init__.py,sha256=rhJ7I6x7aXjKOCzSqsKLwqFJMh4YC2sqchEIJNEfI58,1151
85
- xoscar/virtualenv/core.py,sha256=9Uo3_0lrv8-tuxqi8Zt7PbAjAn015ozA5tNwFOpo94o,1387
86
- xoscar/virtualenv/uv.py,sha256=lHYh_vTljCKjV1YFn4jrE4V2ns8VlMO2PJF1xCdDfvI,3046
87
- xoscar-0.7.0rc1.dist-info/METADATA,sha256=BBcGc-2N-8aExxlPtpWPtG3FI-ki1R3YSUvwChPmYlM,9420
88
- xoscar-0.7.0rc1.dist-info/WHEEL,sha256=VryZucl_XSB78oskhQFN0jfmderyetLlP0R6bZqf7Ys,101
89
- xoscar-0.7.0rc1.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
90
- xoscar-0.7.0rc1.dist-info/RECORD,,
85
+ xoscar/virtualenv/core.py,sha256=ygnDO6QA3gXoT-uiME8Cn-ET_PtwCUxy1i8uCOd9J7Q,2834
86
+ xoscar/virtualenv/uv.py,sha256=xTya0Qo3PjbF5bxFjMtNLQpem6u9Ouvl-bm8vd6K-g4,3424
87
+ xoscar-0.7.2.dist-info/METADATA,sha256=gEgMmPpsr1KzyuzzLt4uGA8M7qkIFWHnnhIoD-rzsZo,9417
88
+ xoscar-0.7.2.dist-info/WHEEL,sha256=b7PoVIxzH_MOHKjftqMzQiGKfdHRlRFepVBVPg0y3vc,101
89
+ xoscar-0.7.2.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
90
+ xoscar-0.7.2.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.3.1)
2
+ Generator: setuptools (80.7.1)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp312-cp312-win_amd64
5
5