xoscar 0.4.0__cp312-cp312-macosx_10_9_universal2.whl → 0.4.1__cp312-cp312-macosx_10_9_universal2.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
@@ -29,7 +29,7 @@ from typing import Any, Callable, Coroutine, Dict, Type
29
29
  from urllib.parse import urlparse
30
30
 
31
31
  from ..._utils import to_binary
32
- from ...constants import XOSCAR_UNIX_SOCKET_DIR
32
+ from ...constants import XOSCAR_CONNECT_TIMEOUT, XOSCAR_UNIX_SOCKET_DIR
33
33
  from ...serialization import AioDeserializer, AioSerializer, deserialize
34
34
  from ...utils import classproperty, implements, is_py_312, is_v6_ip
35
35
  from .base import Channel, ChannelType, Client, Server
@@ -291,7 +291,13 @@ class SocketClient(Client):
291
291
  ) -> "Client":
292
292
  host, port_str = dest_address.rsplit(":", 1)
293
293
  port = int(port_str)
294
- (reader, writer) = await asyncio.open_connection(host=host, port=port, **kwargs)
294
+ config = kwargs.get("config", {})
295
+ connect_timeout = config.get("connect_timeout", XOSCAR_CONNECT_TIMEOUT)
296
+ fut = asyncio.open_connection(host=host, port=port)
297
+ try:
298
+ reader, writer = await asyncio.wait_for(fut, timeout=connect_timeout)
299
+ except asyncio.TimeoutError:
300
+ raise ConnectionError("connect timeout")
295
301
  channel = SocketChannel(
296
302
  reader, writer, local_address=local_address, dest_address=dest_address
297
303
  )
xoscar/backends/core.py CHANGED
@@ -70,50 +70,61 @@ class ActorCaller:
70
70
  return client
71
71
 
72
72
  async def _listen(self, client: Client):
73
- while not client.closed:
74
- try:
73
+ try:
74
+ while not client.closed:
75
75
  try:
76
- message: _MessageBase = await client.recv()
77
- except (EOFError, ConnectionError, BrokenPipeError):
78
- # remote server closed, close client and raise ServerClosed
79
76
  try:
80
- await client.close()
81
- except (ConnectionError, BrokenPipeError):
82
- # close failed, ignore it
77
+ message: _MessageBase = await client.recv()
78
+ except (EOFError, ConnectionError, BrokenPipeError) as e:
79
+ # AssertionError is from get_header
80
+ # remote server closed, close client and raise ServerClosed
81
+ logger.debug(f"{client.dest_address} close due to {e}")
82
+ try:
83
+ await client.close()
84
+ except (ConnectionError, BrokenPipeError):
85
+ # close failed, ignore it
86
+ pass
87
+ raise ServerClosed(
88
+ f"Remote server {client.dest_address} closed: {e}"
89
+ ) from None
90
+ future = self._client_to_message_futures[client].pop(
91
+ message.message_id
92
+ )
93
+ if not future.done():
94
+ future.set_result(message)
95
+ except DeserializeMessageFailed as e:
96
+ message_id = e.message_id
97
+ future = self._client_to_message_futures[client].pop(message_id)
98
+ future.set_exception(e.__cause__) # type: ignore
99
+ except Exception as e: # noqa: E722 # pylint: disable=bare-except
100
+ message_futures = self._client_to_message_futures[client]
101
+ self._client_to_message_futures[client] = dict()
102
+ for future in message_futures.values():
103
+ future.set_exception(copy.copy(e))
104
+ finally:
105
+ # message may have Ray ObjectRef, delete it early in case next loop doesn't run
106
+ # as soon as expected.
107
+ try:
108
+ del message
109
+ except NameError:
83
110
  pass
84
- raise ServerClosed(
85
- f"Remote server {client.dest_address} closed"
86
- ) from None
87
- future = self._client_to_message_futures[client].pop(message.message_id)
88
- if not future.done():
89
- future.set_result(message)
90
- except DeserializeMessageFailed as e:
91
- message_id = e.message_id
92
- future = self._client_to_message_futures[client].pop(message_id)
93
- future.set_exception(e.__cause__) # type: ignore
94
- except Exception as e: # noqa: E722 # pylint: disable=bare-except
95
- message_futures = self._client_to_message_futures[client]
96
- self._client_to_message_futures[client] = dict()
97
- for future in message_futures.values():
98
- future.set_exception(copy.copy(e))
99
- finally:
100
- # message may have Ray ObjectRef, delete it early in case next loop doesn't run
101
- # as soon as expected.
102
- try:
103
- del message
104
- except NameError:
105
- pass
106
- try:
107
- del future
108
- except NameError:
109
- pass
110
- await asyncio.sleep(0)
111
+ try:
112
+ del future
113
+ except NameError:
114
+ pass
115
+ await asyncio.sleep(0)
111
116
 
112
- message_futures = self._client_to_message_futures[client]
113
- self._client_to_message_futures[client] = dict()
114
- error = ServerClosed(f"Remote server {client.dest_address} closed")
115
- for future in message_futures.values():
116
- future.set_exception(copy.copy(error))
117
+ message_futures = self._client_to_message_futures[client]
118
+ self._client_to_message_futures[client] = dict()
119
+ error = ServerClosed(f"Remote server {client.dest_address} closed")
120
+ for future in message_futures.values():
121
+ future.set_exception(copy.copy(error))
122
+ finally:
123
+ try:
124
+ await client.close()
125
+ except: # noqa: E722 # nosec # pylint: disable=bare-except
126
+ # ignore all error if fail to close at last
127
+ pass
117
128
 
118
129
  async def call_with_client(
119
130
  self, client: Client, message: _MessageBase, wait: bool = True
xoscar/backends/pool.py CHANGED
@@ -551,23 +551,31 @@ class AbstractActorPool(ABC):
551
551
  return False
552
552
 
553
553
  async def on_new_channel(self, channel: Channel):
554
- while not self._stopped.is_set():
555
- try:
556
- message = await channel.recv()
557
- except EOFError:
558
- # no data to read, check channel
554
+ try:
555
+ while not self._stopped.is_set():
559
556
  try:
560
- await channel.close()
561
- except (ConnectionError, EOFError):
562
- # close failed, ignore
563
- pass
564
- return
565
- if await self._handle_ucx_meta_message(message, channel):
566
- continue
567
- asyncio.create_task(self.process_message(message, channel))
568
- # delete to release the reference of message
569
- del message
570
- await asyncio.sleep(0)
557
+ message = await channel.recv()
558
+ except (EOFError, ConnectionError, BrokenPipeError) as e:
559
+ logger.debug(f"pool: close connection due to {e}")
560
+ # no data to read, check channel
561
+ try:
562
+ await channel.close()
563
+ except (ConnectionError, EOFError):
564
+ # close failed, ignore
565
+ pass
566
+ return
567
+ if await self._handle_ucx_meta_message(message, channel):
568
+ continue
569
+ asyncio.create_task(self.process_message(message, channel))
570
+ # delete to release the reference of message
571
+ del message
572
+ await asyncio.sleep(0)
573
+ finally:
574
+ try:
575
+ await channel.close()
576
+ except: # noqa: E722 # nosec # pylint: disable=bare-except
577
+ # ignore all error if fail to close at last
578
+ pass
571
579
 
572
580
  async def __aenter__(self):
573
581
  await self.start()
xoscar/constants.py CHANGED
@@ -19,3 +19,5 @@ XOSCAR_TEMP_DIR = Path(os.getenv("XOSCAR_DIR", Path.home())) / ".xoscar"
19
19
 
20
20
  # unix socket.
21
21
  XOSCAR_UNIX_SOCKET_DIR = XOSCAR_TEMP_DIR / "socket"
22
+
23
+ XOSCAR_CONNECT_TIMEOUT = 8
Binary file
Binary file
@@ -77,7 +77,11 @@ MALFORMED_MSG = "Received malformed data, please check Xoscar version on both si
77
77
  def get_header_length(header_bytes: bytes):
78
78
  version = struct.unpack("B", header_bytes[:1])[0]
79
79
  # now we only have default version
80
- assert version == DEFAULT_SERIALIZATION_VERSION, MALFORMED_MSG
80
+ if version != DEFAULT_SERIALIZATION_VERSION:
81
+ # when version not matched,
82
+ # we will immediately abort the connection
83
+ # EOFError will be captured by channel
84
+ raise EOFError(MALFORMED_MSG)
81
85
  # header length
82
86
  header_length = struct.unpack("<Q", header_bytes[1:9])[0]
83
87
  # compress
xoscar/utils.py CHANGED
@@ -19,11 +19,11 @@ import asyncio
19
19
  import dataclasses
20
20
  import functools
21
21
  import importlib
22
+ import importlib.util as importlib_utils
22
23
  import inspect
23
24
  import io
24
25
  import logging
25
26
  import os
26
- import pkgutil
27
27
  import random
28
28
  import socket
29
29
  import sys
@@ -267,7 +267,7 @@ def lazy_import(
267
267
  self._on_loads.append(func)
268
268
  return func
269
269
 
270
- if pkgutil.find_loader(prefix_name) is not None:
270
+ if importlib_utils.find_spec(prefix_name) is not None:
271
271
  return LazyModule()
272
272
  elif placeholder:
273
273
  return ModulePlaceholder(prefix_name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xoscar
3
- Version: 0.4.0
3
+ Version: 0.4.1
4
4
  Summary: Python actor framework for heterogeneous computing.
5
5
  Home-page: http://github.com/xorbitsai/xoscar
6
6
  Author: Qin Xuye
@@ -20,13 +20,13 @@ Classifier: Topic :: Software Development :: Libraries
20
20
  Description-Content-Type: text/markdown
21
21
  Requires-Dist: numpy>=1.14.0
22
22
  Requires-Dist: pandas>=1.0.0
23
+ Requires-Dist: scipy>=1.0.0; sys_platform != "win32" or python_version >= "3.10"
24
+ Requires-Dist: scipy<=1.9.1,>=1.0.0; sys_platform == "win32" and python_version < "3.10"
23
25
  Requires-Dist: cloudpickle>=1.5.0
24
26
  Requires-Dist: psutil>=5.9.0
25
27
  Requires-Dist: tblib>=1.7.0
26
- Requires-Dist: packaging
27
28
  Requires-Dist: uvloop>=0.14.0; sys_platform != "win32"
28
- Requires-Dist: scipy>=1.0.0; sys_platform != "win32" or python_version >= "3.10"
29
- Requires-Dist: scipy<=1.9.1,>=1.0.0; sys_platform == "win32" and python_version < "3.10"
29
+ Requires-Dist: packaging
30
30
  Provides-Extra: dev
31
31
  Requires-Dist: cython>=0.29; extra == "dev"
32
32
  Requires-Dist: pytest>=3.5.0; extra == "dev"
@@ -50,7 +50,7 @@ Requires-Dist: pyarrow>=5.0.0; extra == "extra"
50
50
  Provides-Extra: kubernetes
51
51
  Requires-Dist: kubernetes>=10.0.0; extra == "kubernetes"
52
52
  Provides-Extra: ray
53
- Requires-Dist: xoscar-ray>=0.0.1; extra == "ray"
53
+ Requires-Dist: xoscar_ray>=0.0.1; extra == "ray"
54
54
 
55
55
  <div align="center">
56
56
  <img width="77%" alt="" src="https://raw.githubusercontent.com/xprobe-inc/xoscar/main/doc/source/_static/Xoscar.svg"><br>
@@ -1,7 +1,7 @@
1
- xoscar-0.4.0.dist-info/RECORD,,
2
- xoscar-0.4.0.dist-info/WHEEL,sha256=568ptz5j2bwL99nQYci4U3-KMfBlUpekfgY5tOLXYW8,114
3
- xoscar-0.4.0.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
4
- xoscar-0.4.0.dist-info/METADATA,sha256=xfdfy3u6wkQ-IEUMahgHm_ZjZWpKu-VQkoBojz7E8eU,9042
1
+ xoscar-0.4.1.dist-info/RECORD,,
2
+ xoscar-0.4.1.dist-info/WHEEL,sha256=C4KN4YCkC-N5H4tfwAwUhpN6EeEKldmnTUCP2KygBew,114
3
+ xoscar-0.4.1.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
4
+ xoscar-0.4.1.dist-info/METADATA,sha256=EM22rICxUdVBATkQoIRlCZgvAQakKY9lKIK0GYEPCb0,9042
5
5
  xoscar/_utils.pyx,sha256=UR1FtYXAYKIdEWR9HulEpMbSOrkQWi6xGz63d4IQmG0,7059
6
6
  xoscar/backend.py,sha256=is436OPkZfSpQXaoqTRVta5eoye_pp45RFgCstAk2hU,1850
7
7
  xoscar/core.pxd,sha256=4lBq8J0kjcXcsGuvN7Kv4xcL5liHwTTFWlqyK7XAEnw,1280
@@ -9,17 +9,17 @@ xoscar/_version.py,sha256=ClSPrUjgGRGHIkVMQV9XQnkQ-n0akJMnq_rh819nqFE,23719
9
9
  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
- xoscar/constants.py,sha256=Yn59lRIOvE1VFwyuZB5G2-gxYIyhIZ1rVovbdFAR2NM,759
13
- xoscar/core.cpython-312-darwin.so,sha256=VSWbEk9PY564Is8U6LfFcuvLuYRZGtHphpm5US7JSV0,932560
12
+ xoscar/constants.py,sha256=QHHSREw6uWBBjQDCFqlNfTvBZgniJPGy42KSIsR8Fqw,787
13
+ xoscar/core.cpython-312-darwin.so,sha256=KRwfOL5Kg2z5le5yn04tCSIn4Pxq_6T3-xS6_Vg-X-A,932560
14
14
  xoscar/__init__.py,sha256=0zX8kKaio3ZIrlzB79WybcravMJw1OxPWjDspTgJFyQ,1608
15
- xoscar/context.cpython-312-darwin.so,sha256=LKkdn2DiAKapUeDaSua5NrmZ706puxlIvB8p3_-7bgA,455856
15
+ xoscar/context.cpython-312-darwin.so,sha256=bnyudUGiZCYxG9PhRKQeJO7UCecMBNr8urBgG4JaE80,455856
16
16
  xoscar/api.py,sha256=3hztPoOxg8A_mlhWyWgVP7FMXG0PATA1TP4Rbaj7A-g,13327
17
- xoscar/utils.py,sha256=vAgTMpEyzBNKT4u05-ii9wg_5-7Iq5c8TthyMpz6M_M,16451
17
+ xoscar/utils.py,sha256=jUw6OICZUPBbmS1b3GE4vLctJf6fCKXrYtLtBuK-Oqc,16483
18
18
  xoscar/debug.py,sha256=9Z8SgE2WaKYQcyDo-5-DxEJQ533v7kWjrvCd28pSx3E,5069
19
19
  xoscar/libcpp.pxd,sha256=DJqBxLFOKL4iRr9Kale5UH3rbvPRD1x5bTSOPHFpz9I,1147
20
20
  xoscar/context.pyx,sha256=8CdgPnWcE9eOp3N600WgDQ03MCi8P73eUOGcfV7Zksg,10942
21
21
  xoscar/errors.py,sha256=wBlQOKsXf0Fc4skN39tDie0YZT-VIAuLNRgoDl2pZcA,1241
22
- xoscar/_utils.cpython-312-darwin.so,sha256=kWs_BdCiBkVm6uwEHD9QZU9tsckxgaJJsC3yMHL7wlM,347312
22
+ xoscar/_utils.cpython-312-darwin.so,sha256=zKW00mx1s5MSrXjgArY6Ug0qa3KY62M_yXhR69BvghQ,347312
23
23
  xoscar/core.pyx,sha256=Aqc2i8Fetsd5wRAPF4kL0ddnBZn3E2HRNCvup79BbQc,21730
24
24
  xoscar/driver.py,sha256=498fowtJr6b3FE8FIOA_Tc1Vwx88nfZw7p0FxrML0h4,1372
25
25
  xoscar/profiling.py,sha256=BC5OF0HzSaXv8V7w-y-B8r5gV5DgxHFoTEIF6jCMioQ,8015
@@ -43,23 +43,23 @@ xoscar/serialization/exception.py,sha256=Jy8Lsk0z-VJyEUaWeuZIwkmxqaoB-nLKMa1D15C
43
43
  xoscar/serialization/pyfury.py,sha256=sifOnVMYoS82PzZEkzkfxesmMHei23k5UAUUKUyoOYQ,1163
44
44
  xoscar/serialization/core.pxd,sha256=k4RoJgX5E5LGs4jdCQ7vvcn26MabXbrWoWhkO49X6YI,985
45
45
  xoscar/serialization/core.pyi,sha256=-pQARSj91rt3iU4ftWGFH6jYwsSKYCT_Ya7EJsaGEjg,1874
46
- xoscar/serialization/core.cpython-312-darwin.so,sha256=FMhsCFzUiSeIgTPTaMXlYoK45snFwmE007MtiaSgAKc,820976
46
+ xoscar/serialization/core.cpython-312-darwin.so,sha256=6i1as59pgqCpqFJCxOg8Lf_44NbPbfWOIycQCgIAZ9Y,820976
47
47
  xoscar/serialization/__init__.py,sha256=5Y_C3cYbQJIZ09LRjeCf-jrkLma7mfN8I5bznHrdsbg,846
48
48
  xoscar/serialization/numpy.py,sha256=5Kem87CvpJmzUMp3QHk4WeHU30FoQWTJJP2SwIcaQG0,2919
49
49
  xoscar/serialization/cuda.py,sha256=iFUEnN4SiquBIhyieyOrfw3TnKnW-tU_vYgqOxO_DrA,3758
50
50
  xoscar/serialization/scipy.py,sha256=yOEi0NB8cqQ6e2UnCZ1w006RsB7T725tIL-DM_hNcsU,2482
51
- xoscar/serialization/aio.py,sha256=S9e3rHMBwqqKmJtDz7KzYAqWc8w9bttA0Dj83IBfEU0,4577
51
+ xoscar/serialization/aio.py,sha256=5DySPgDxU43ec7_5Ct44-Oqt7YNSJBfuf8VdQgQlChA,4731
52
52
  xoscar/serialization/core.pyx,sha256=bjR-zXGm9qersk7kYPzpjpMIxDl_Auur4BCubRfKmfA,29626
53
53
  xoscar/backends/config.py,sha256=EG26f0GwX_f4dAhwTW77RBjiK9h8R_3JrD-rBF1bAq8,4984
54
54
  xoscar/backends/message.pyi,sha256=__2piPWLUQBmkDzx_nsHMOC2wHG53IKVGU_47zwgdKM,6112
55
55
  xoscar/backends/allocate_strategy.py,sha256=tC1Nbq2tJohahUwd-zoRYHEDX65wyuX8tmeY45uWj_w,4845
56
56
  xoscar/backends/__init__.py,sha256=VHEBQcUWM5bj027W8EUf9PiJUAP7JoMrRw3Tsvy5ySw,643
57
- xoscar/backends/core.py,sha256=aHb3mMZ9vJe6pxg0P8kSOKvjXF1IaqgOgyhKVhHpNLM,7432
57
+ xoscar/backends/core.py,sha256=YcXVrMrTUjnrnH-RhrtUyxnCbwon8miq2UigCQv-y_Q,8039
58
58
  xoscar/backends/context.py,sha256=Vr_PibRxYCDQ_gYK7r-BOlw9TXw8VQbFsVTH7K7mHPk,15470
59
59
  xoscar/backends/router.py,sha256=mhSvM5KVfV882jricVcpyxAqHEvhS4zL6ivczC6fOTE,7746
60
- xoscar/backends/message.cpython-312-darwin.so,sha256=EpiSqBGnbJPqukQcWYXwPmwYGGqCelCdwb3H_m90S7Y,754848
60
+ xoscar/backends/message.cpython-312-darwin.so,sha256=niPWaI0RCTxbZGTDwn4AHJE2mfjrEyZ2Wb3wi1OyuvI,754848
61
61
  xoscar/backends/message.pyx,sha256=uyzilPc_7SqNwGUL4U-Zbfqku8bfZyRW_Lt_S3I_LEU,17930
62
- xoscar/backends/pool.py,sha256=itI9Ho6XjHjBY49-WPBu2absEUFOSCpQhgQ6OnUIm-4,59421
62
+ xoscar/backends/pool.py,sha256=Z7Wdab9dBF3SdQpmzgZhY0d09oTvg5gpFgzYH7vuc4w,59841
63
63
  xoscar/backends/indigen/backend.py,sha256=znl_fZzWGEtLH8hZ9j9Kkf0fva25jEem2_KO7I1RVvc,1612
64
64
  xoscar/backends/indigen/__init__.py,sha256=tKHP5ClzedBRBpZsLRVErR3EUNbbDm4CY4u0rCFJr44,685
65
65
  xoscar/backends/indigen/driver.py,sha256=VGzkacYKykegW5qhCuhx01gdgBZEKJjNIyfNCnA6Nm8,952
@@ -72,7 +72,7 @@ xoscar/backends/communication/__init__.py,sha256=tB05BlK63iWQnfJgRzKt4mFKRtmWUki
72
72
  xoscar/backends/communication/core.py,sha256=sJeE3foRIqVPXldzYpFKHDSsabfAIFBU4JuXY4OyklY,2130
73
73
  xoscar/backends/communication/utils.py,sha256=AmovE-hmWLXNCPwHafYuaRjOk8m42BUyT3XBqfXQRVI,3664
74
74
  xoscar/backends/communication/errors.py,sha256=V3CdBe2xX9Rwv32f2dH2Msc84yaUhlyerZ42-739o1Q,723
75
- xoscar/backends/communication/socket.py,sha256=DXeYt8mFPnN5Cdg3BGFsmnJc0Ck4_OONveJwAGq44OM,13389
75
+ xoscar/backends/communication/socket.py,sha256=ZSDqS_Z9-Oxs2Q2fqWUuUJ9hNf4w8lNJ8gUv5r6Ji_Y,13691
76
76
  xoscar/backends/communication/dummy.py,sha256=gaKPNiN4x2aGZV3IGaaa8eaweBVjRh8B19jU1B5t2yw,7798
77
77
  xoscar/backends/communication/base.py,sha256=0P4Tr35GSWpRp394e9jVWUUoKKa-gIk177eYPw1BnSU,7421
78
78
  xoscar/aio/__init__.py,sha256=kViDKR_kJe59VQViHITKEfBcIgN4ZJblUyd8zl0E3ZI,675
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.3.0)
2
+ Generator: setuptools (75.6.0)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp312-cp312-macosx_10_9_universal2
5
5