b10-transfer 0.1.8__py3-none-any.whl → 0.2.0__py3-none-any.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.
b10_transfer/__init__.py CHANGED
@@ -9,7 +9,7 @@ from .constants import OperationStatus
9
9
  from .logging_utils import get_b10_logger
10
10
 
11
11
  # Version
12
- __version__ = "0.1.8"
12
+ __version__ = "0.2.0"
13
13
 
14
14
  __all__ = [
15
15
  "CacheError",
@@ -0,0 +1,124 @@
1
+ # src/b10_tcache/cli.py
2
+ from __future__ import annotations
3
+
4
+ import logging
5
+ import os
6
+ import sys
7
+ import time
8
+ import urllib.error
9
+ import urllib.request
10
+ from dataclasses import dataclass
11
+
12
+
13
+ @dataclass(frozen=True)
14
+ class WaitCfg:
15
+ url: str
16
+ timeout_s: float
17
+ interval_s: float
18
+ loglevel: str
19
+
20
+
21
+ DEFAULT_URL = os.getenv("B10_TRANSFER_VLLM_URL", "http://127.0.0.1:8000/v1/models")
22
+ DEFAULT_TIMEOUT_S = float(os.getenv("B10_TRANSFER_TIMEOUT_S", "1800")) # 30m default
23
+ DEFAULT_INTERVAL_S = float(os.getenv("B10_TRANSFER_INTERVAL_S", "2"))
24
+ DEFAULT_LOGLEVEL = os.getenv("B10_TRANSFER_CLI_LOGLEVEL", "INFO").upper()
25
+
26
+
27
+ VLLM_CACHE_DIR = os.getenv("VLLM_CACHE_ROOT", "~/.cache/vllm")
28
+
29
+
30
+ def _setup_logging(level: str) -> logging.Logger:
31
+ logging.basicConfig(
32
+ level=getattr(logging, level, logging.INFO),
33
+ format="%(asctime)s | %(levelname)s | %(message)s",
34
+ )
35
+ return logging.getLogger("b10_transfer.cli")
36
+
37
+
38
+ def _http_ok(url: str, logger: logging.Logger) -> bool:
39
+ """
40
+ Return True if vLLM readiness looks good.
41
+
42
+ We consider it 'ready' if GET <url> returns 200.
43
+ """
44
+ try:
45
+ req = urllib.request.Request(url, method="GET")
46
+ with urllib.request.urlopen(req, timeout=5) as resp:
47
+ if resp.status != 200:
48
+ return False
49
+ return True
50
+ except (urllib.error.URLError, urllib.error.HTTPError) as e:
51
+ logger.debug("Readiness probe failed: %s", e)
52
+ return False
53
+ except Exception as e:
54
+ logger.debug("Unexpected readiness error: %s", e)
55
+ return False
56
+
57
+
58
+ def _wait_for_ready(cfg: WaitCfg, logger: logging.Logger) -> bool:
59
+ t0 = time.monotonic()
60
+ logger.info(
61
+ "Waiting for vLLM readiness at %s (timeout=%.0fs, interval=%.1fs)",
62
+ cfg.url,
63
+ cfg.timeout_s,
64
+ cfg.interval_s,
65
+ )
66
+
67
+ while True:
68
+ if _http_ok(cfg.url, logger):
69
+ logger.info("vLLM reported ready at %s", cfg.url)
70
+ return True
71
+ if time.monotonic() - t0 > cfg.timeout_s:
72
+ logger.error(
73
+ "Timed out after %.0fs waiting for vLLM readiness.", cfg.timeout_s
74
+ )
75
+ return False
76
+
77
+ time.sleep(cfg.interval_s)
78
+
79
+
80
+ def main() -> None:
81
+ # Configure torch compile cache location
82
+ os.environ["TORCHINDUCTOR_CACHE_DIR"] = VLLM_CACHE_DIR
83
+
84
+ # Import here to allow environment variables to be set before the imported script uses them
85
+ from cache import load_compile_cache, save_compile_cache
86
+
87
+ cfg = WaitCfg(
88
+ url=DEFAULT_URL,
89
+ timeout_s=DEFAULT_TIMEOUT_S,
90
+ interval_s=DEFAULT_INTERVAL_S,
91
+ loglevel=DEFAULT_LOGLEVEL,
92
+ )
93
+
94
+ logger = _setup_logging(cfg.loglevel)
95
+
96
+ # 1) Preload any existing cache (non-fatal on error)
97
+ try:
98
+ logger.info("Calling load_compile_cache() …")
99
+ load_compile_cache()
100
+ logger.info("load_compile_cache() returned.")
101
+ except Exception as e:
102
+ logger.exception("load_compile_cache() failed: %s", e)
103
+
104
+ # 2) Wait for vLLM HTTP to be ready
105
+ try:
106
+ ready = _wait_for_ready(cfg, logger)
107
+ except Exception as e:
108
+ logger.exception("Readiness wait crashed: %s", e)
109
+ sys.exit(3)
110
+
111
+ if not ready:
112
+ # Loop timed out. Safe exit.
113
+ sys.exit(4)
114
+
115
+ # 3) Save compile cache
116
+ try:
117
+ logger.info("Calling save_compile_cache() …")
118
+ save_compile_cache()
119
+ logger.info("save_compile_cache() completed.")
120
+ except Exception as e:
121
+ logger.exception("save_compile_cache() failed: %s", e)
122
+ sys.exit(5)
123
+
124
+ logger.info("vLLM automatic torch compile cache done.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: b10-transfer
3
- Version: 0.1.8
3
+ Version: 0.2.0
4
4
  Summary: Distributed PyTorch file transfer for Baseten - Environment-aware, lock-free file transfer management
5
5
  License: MIT
6
6
  Keywords: pytorch,file-transfer,cache,machine-learning,inference
@@ -1,6 +1,7 @@
1
- b10_transfer/__init__.py,sha256=ik92ay-2iZ3qcRWOP9yNuWiM6TVKzFZBA_m8UTWiKCQ,729
1
+ b10_transfer/__init__.py,sha256=K4E2V4gYvauE65ZCgS0Artx6aVJpEFsGAUDNjHE0Sj4,729
2
2
  b10_transfer/archive.py,sha256=gunAZ6oTUz0SxodUCho1uP-MNLuQyuhMKFusx7E0xDg,6439
3
3
  b10_transfer/cache.py,sha256=k759Cs4IIUdAJ90ctK1m8ws3Fceje8ckug09L8X6W5I,17518
4
+ b10_transfer/cache_cli.py,sha256=I_MOUgYqMdtxjX0caP__jmp957koQy86VsSDwn4CmtU,3602
4
5
  b10_transfer/cleanup.py,sha256=IAjRlpzCcXVrokTXdOsm_EJo_-U5kiy8KJoip8V4vvk,6345
5
6
  b10_transfer/constants.py,sha256=iuLShDW6hInhyz2YTQ8CzBanqW4chCkQOAzPZkCtOoA,4322
6
7
  b10_transfer/core.py,sha256=Ny4lViiPup4Zb_OCx_Z2IcbcWq42Ymj_zF7xyVroHxE,4668
@@ -9,6 +10,7 @@ b10_transfer/info.py,sha256=WlpSQNEKi93d3EYo2HnbbzrLazOhK9dpX5w7Kf6DVfA,6339
9
10
  b10_transfer/logging_utils.py,sha256=vnjnuVsVO5bibHSHiF5sYhHqfprIezU0fM3YaCugMC0,3488
10
11
  b10_transfer/space_monitor.py,sha256=-hFc9f29K-7gF1vDZRrKDa-FrHkmD6OBLsV8l8knrMM,10761
11
12
  b10_transfer/utils.py,sha256=XG4dGLAlQQyUPeIK48OzuDkz1SOpdEs2_GrXKd8fr5M,12061
12
- b10_transfer-0.1.8.dist-info/METADATA,sha256=bV0Qk7Dwsq3ZWroigvDCKqvzERNAdCDiHaMv6pqCauA,4108
13
- b10_transfer-0.1.8.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
14
- b10_transfer-0.1.8.dist-info/RECORD,,
13
+ b10_transfer-0.2.0.dist-info/METADATA,sha256=iP567IJPB9rTq3L4FSFz8QQVF89vnak4iJvrBbgzkRA,4108
14
+ b10_transfer-0.2.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
15
+ b10_transfer-0.2.0.dist-info/entry_points.txt,sha256=6vj8KpPhV5qkaix1Vs7c--RL8nmuaGx_jIvkp4mRXoY,60
16
+ b10_transfer-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ b10-transfer=b10_transfer.cache_cli:main
3
+