xoscar 0.7.5__cp310-cp310-macosx_11_0_arm64.whl → 0.7.7__cp310-cp310-macosx_11_0_arm64.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.

Binary file
Binary file
Binary file
@@ -0,0 +1,84 @@
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
+ import logging
16
+ import re
17
+ import subprocess
18
+ import sys
19
+ import threading
20
+ from contextlib import contextmanager
21
+ from typing import BinaryIO, Callable, Iterator, List, Optional, TextIO, Union
22
+
23
+ logger = logging.getLogger(__name__)
24
+
25
+ ansi_escape = re.compile(r"\x1B\[[0-?]*[ -/]*[@-~]")
26
+
27
+
28
+ def clean_ansi(text: str) -> str:
29
+ """Remove ANSI escape sequences from text."""
30
+ return ansi_escape.sub("", text)
31
+
32
+
33
+ def stream_reader(
34
+ stream: BinaryIO, log_func: Callable[[str], None], output_stream: TextIO
35
+ ) -> None:
36
+ """
37
+ Read from the stream, write to logger, and also write to the terminal.
38
+ """
39
+ for line in iter(stream.readline, b""):
40
+ decoded = line.decode(errors="replace")
41
+ output_stream.write(decoded)
42
+ output_stream.flush()
43
+ log_func(clean_ansi(decoded.rstrip("\n")))
44
+
45
+
46
+ @contextmanager
47
+ def run_subprocess_with_logger(
48
+ cmd: Union[str, List[str]], cwd: Optional[str] = None, env: Optional[dict] = None
49
+ ) -> Iterator[subprocess.Popen]:
50
+ """
51
+ Run a subprocess, redirect stdout to logger.info and stderr to logger.error.
52
+ Returns the Popen object as a context manager.
53
+
54
+ :param cmd: Command to execute
55
+ :param kwargs: Additional arguments passed to subprocess.Popen
56
+ :yield: The subprocess.Popen object
57
+ """
58
+
59
+ process = subprocess.Popen(
60
+ cmd,
61
+ stdout=subprocess.PIPE,
62
+ stderr=subprocess.PIPE,
63
+ cwd=cwd,
64
+ env=env,
65
+ bufsize=1,
66
+ )
67
+
68
+ threads = [
69
+ threading.Thread(
70
+ target=stream_reader, args=(process.stdout, logger.info, sys.stdout)
71
+ ),
72
+ threading.Thread(
73
+ target=stream_reader, args=(process.stderr, logger.error, sys.stderr)
74
+ ),
75
+ ]
76
+ for t in threads:
77
+ t.start()
78
+
79
+ try:
80
+ yield process
81
+ finally:
82
+ process.wait()
83
+ for t in threads:
84
+ t.join()
xoscar/virtualenv/uv.py CHANGED
@@ -24,6 +24,7 @@ from pathlib import Path
24
24
  from typing import Optional
25
25
 
26
26
  from .core import VirtualEnvManager
27
+ from .utils import run_subprocess_with_logger
27
28
 
28
29
  UV_PATH = os.getenv("XOSCAR_UV_PATH")
29
30
  logger = logging.getLogger(__name__)
@@ -46,7 +47,14 @@ class UVVirtualEnvManager(VirtualEnvManager):
46
47
  return shutil.which("uv") is not None
47
48
 
48
49
  def create_env(self, python_path: Path | None = None) -> None:
49
- uv_path = UV_PATH or "uv"
50
+ if (uv_path := UV_PATH) is None:
51
+ try:
52
+ from uv import find_uv_bin
53
+
54
+ uv_path = find_uv_bin()
55
+ except (ImportError, FileNotFoundError):
56
+ logger.warning("Fail to find uv bin, use system one")
57
+ uv_path = "uv"
50
58
  cmd = [uv_path, "venv", str(self.env_path), "--system-site-packages"]
51
59
  if python_path:
52
60
  cmd += ["--python", str(python_path)]
@@ -70,9 +78,17 @@ class UVVirtualEnvManager(VirtualEnvManager):
70
78
  # extend the ability of pip
71
79
  # maybe replace #system_torch# to the real version
72
80
  packages = self.process_packages(packages)
81
+ log = kwargs.pop("log", False)
73
82
 
74
83
  uv_path = UV_PATH or "uv"
75
- cmd = [uv_path, "pip", "install", "-p", str(self.env_path)] + packages
84
+ cmd = [
85
+ uv_path,
86
+ "pip",
87
+ "install",
88
+ "-p",
89
+ str(self.env_path),
90
+ "--color=always",
91
+ ] + packages
76
92
 
77
93
  # Handle known pip-related kwargs
78
94
  if "index_url" in kwargs and kwargs["index_url"]:
@@ -92,8 +108,13 @@ class UVVirtualEnvManager(VirtualEnvManager):
92
108
  cmd += [option, param_value]
93
109
 
94
110
  logger.info("Installing packages via command: %s", cmd)
95
- self._install_process = process = subprocess.Popen(cmd)
96
- returncode = process.wait()
111
+ if not log:
112
+ self._install_process = process = subprocess.Popen(cmd)
113
+ returncode = process.wait()
114
+ else:
115
+ with run_subprocess_with_logger(cmd) as process:
116
+ self._install_process = process
117
+ returncode = process.returncode
97
118
 
98
119
  self._install_process = None # install finished, clear reference
99
120
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xoscar
3
- Version: 0.7.5
3
+ Version: 0.7.7
4
4
  Summary: Python actor framework for heterogeneous computing.
5
5
  Home-page: http://github.com/xorbitsai/xoscar
6
6
  Author: Qin Xuye
@@ -1,7 +1,7 @@
1
- xoscar-0.7.5.dist-info/RECORD,,
2
- xoscar-0.7.5.dist-info/WHEEL,sha256=adaOEtyuP97RoRqh2LNimBtjXokZHsp60v8dUwE5uKE,137
3
- xoscar-0.7.5.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
4
- xoscar-0.7.5.dist-info/METADATA,sha256=cdE3xpdI75n6WsPnGYXmOkfeC4xVHaBTkcs4at4ZVVM,9134
1
+ xoscar-0.7.7.dist-info/RECORD,,
2
+ xoscar-0.7.7.dist-info/WHEEL,sha256=adaOEtyuP97RoRqh2LNimBtjXokZHsp60v8dUwE5uKE,137
3
+ xoscar-0.7.7.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
4
+ xoscar-0.7.7.dist-info/METADATA,sha256=xxkpDn2341sKmMMKzwq2RdvcuBA8N5hSCDwphsv5qcU,9134
5
5
  xoscar/_utils.pyx,sha256=frgVQ5xGp92jBKc4PsPmjOlVsXlKeHWtTOAMfHmBaII,7380
6
6
  xoscar/backend.py,sha256=is436OPkZfSpQXaoqTRVta5eoye_pp45RFgCstAk2hU,1850
7
7
  xoscar/core.pxd,sha256=I_C2ka7XryyGnnAVXUVm8xfS1gtIrCs6X-9rswgOcUU,1317
@@ -10,7 +10,7 @@ xoscar/context.pxd,sha256=qKa0OyDPZtVymftSh447m-RzFZgmz8rGqQBa7qlauvc,725
10
10
  xoscar/batch.py,sha256=DpArS0L3WYJ_HVPG-6hSYEwoAFY1mY2-mlC4Jp5M_Dw,7872
11
11
  xoscar/nvutils.py,sha256=qmW4mKLU0WB2yCs198ccQOgLL02zB7Fsa-AotO3NOmg,20412
12
12
  xoscar/constants.py,sha256=QHHSREw6uWBBjQDCFqlNfTvBZgniJPGy42KSIsR8Fqw,787
13
- xoscar/_utils.cpython-310-darwin.so,sha256=eBOLoPPPd6u7cv7d7NdKu53VPV3S5XsfZ8cgBtq-N7U,168944
13
+ xoscar/_utils.cpython-310-darwin.so,sha256=7Ym8KRuv8G1gabZ3qr7R6GzUit3ibvWdTKWCio-wIg0,168944
14
14
  xoscar/__init__.py,sha256=sy7Wtn2EuQZI0I4Az_MfsBVZm4G0DRj46qRyExgmnJk,1622
15
15
  xoscar/api.py,sha256=zxNqOjGiTIKuAip9WJ0LOoM7yevD6P5rb-sLynpZ2Zo,14648
16
16
  xoscar/utils.py,sha256=MaKiW4Vphwhh8c0yoqN8G8hbJr1zXgpf49EdvmGc1ZU,16500
@@ -20,8 +20,8 @@ xoscar/context.pyx,sha256=8CdgPnWcE9eOp3N600WgDQ03MCi8P73eUOGcfV7Zksg,10942
20
20
  xoscar/errors.py,sha256=wBlQOKsXf0Fc4skN39tDie0YZT-VIAuLNRgoDl2pZcA,1241
21
21
  xoscar/core.pyx,sha256=phN-yYV0A0QI8WFi2jCu0nc4CnShTepfDi0V7ZrLYPY,22092
22
22
  xoscar/driver.py,sha256=498fowtJr6b3FE8FIOA_Tc1Vwx88nfZw7p0FxrML0h4,1372
23
- xoscar/context.cpython-310-darwin.so,sha256=SHZB4oJ_euDas2pLwQJLXrdg6OwnYBmpukLFtXXSQr4,211488
24
- xoscar/core.cpython-310-darwin.so,sha256=_-d0t34lzLtJ4XpU3dZth1btJ8k3amsQYAIRnXHP33k,409624
23
+ xoscar/context.cpython-310-darwin.so,sha256=_EOOLrvqC4td45PHei9o0riMVXxywmsKppVShiCWnPA,211488
24
+ xoscar/core.cpython-310-darwin.so,sha256=vmfNzQhy6b9xawSaY3QSkBiALcXtL8tam32xmsLiIiU,409624
25
25
  xoscar/profiling.py,sha256=BC5OF0HzSaXv8V7w-y-B8r5gV5DgxHFoTEIF6jCMioQ,8015
26
26
  xoscar/_utils.pxd,sha256=5KYAL3jfPdejsHnrGGT2s--ZUX5SXznQWpHVSno429k,1157
27
27
  xoscar/metrics/__init__.py,sha256=9Badi7rxYikGm2dQiNCrj9GgMRBxwuR3JaEKcFZmfak,705
@@ -47,11 +47,11 @@ xoscar/serialization/cuda.py,sha256=iFUEnN4SiquBIhyieyOrfw3TnKnW-tU_vYgqOxO_DrA,
47
47
  xoscar/serialization/scipy.py,sha256=yOEi0NB8cqQ6e2UnCZ1w006RsB7T725tIL-DM_hNcsU,2482
48
48
  xoscar/serialization/aio.py,sha256=5DySPgDxU43ec7_5Ct44-Oqt7YNSJBfuf8VdQgQlChA,4731
49
49
  xoscar/serialization/core.pyx,sha256=bjR-zXGm9qersk7kYPzpjpMIxDl_Auur4BCubRfKmfA,29626
50
- xoscar/serialization/core.cpython-310-darwin.so,sha256=-BZWD4VVVaZFox26Gi7rVM67R8PFI04hotGssm7T2yo,379912
50
+ xoscar/serialization/core.cpython-310-darwin.so,sha256=fJDvhrQRg4N_vN133QFbdwrKLOKUDrn3PKWkQUFZpPQ,379912
51
51
  xoscar/serialization/mlx.py,sha256=N_cvbTUBKc14XWYsPIMz4kDstyRN1DNhb4BVRgnQm8Y,1872
52
52
  xoscar/backends/config.py,sha256=4tZMiXAMMS8qQ4SX_LjONLtSQVfZTx3m-IK3EqbkYdk,5375
53
53
  xoscar/backends/allocate_strategy.py,sha256=tC1Nbq2tJohahUwd-zoRYHEDX65wyuX8tmeY45uWj_w,4845
54
- xoscar/backends/message.cpython-310-darwin.so,sha256=BLdsZyrStlVskrsTFcaUTxO7BvDRWcyy5zVrEt-o8xE,348688
54
+ xoscar/backends/message.cpython-310-darwin.so,sha256=9QaApURszJ0c5lFR2CfCNSrvRtCj50cz-GA7MegwzeU,348688
55
55
  xoscar/backends/__init__.py,sha256=VHEBQcUWM5bj027W8EUf9PiJUAP7JoMrRw3Tsvy5ySw,643
56
56
  xoscar/backends/core.py,sha256=EH-fHlV9x3bnruEHaUtGYO7osKLfLJ4AQHtuzA_mr2g,10857
57
57
  xoscar/backends/context.py,sha256=XfDPG2eDhAhE6hWBEkEsHTnyyOYN9R3houlMjAL7BFw,16329
@@ -83,4 +83,5 @@ xoscar/aio/parallelism.py,sha256=VSsjk8wP-Bw7tLeUsTyLVNgp91thjxEfE3pCrw_vF5Q,129
83
83
  xoscar/aio/base.py,sha256=9j0f1piwfE5R5GIvV212vSD03ixdaeSzSSsO2kxJZVE,2249
84
84
  xoscar/virtualenv/__init__.py,sha256=65t9_X1DvbanNjFy366SiiWZrRTpa9SXWMXPmqayE-4,1117
85
85
  xoscar/virtualenv/core.py,sha256=dZqwg2IzHsLEERvohZx0rvBINopMRUImqxG3HHGO0q4,2744
86
- xoscar/virtualenv/uv.py,sha256=mR4gevfB8eFMmSLfvOYM-QhyqWyDsqO-V4bkRuhOOWA,4145
86
+ xoscar/virtualenv/utils.py,sha256=mL_uATHhj82xec0-0IZ6N8yI-laPAB4t8G3alPUGtPA,2439
87
+ xoscar/virtualenv/uv.py,sha256=XCjeCEntMhA0kyZS0qG7qu9AWzPtIwdeTJRLYRIOiDI,4788
File without changes