b10-transfer 0.1.2__tar.gz → 0.1.3__tar.gz
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-0.1.2 → b10_transfer-0.1.3}/PKG-INFO +1 -1
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/pyproject.toml +1 -1
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/src/b10_transfer/__init__.py +1 -1
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/src/b10_transfer/constants.py +7 -0
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/src/b10_transfer/core.py +85 -0
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/README.md +0 -0
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/src/b10_transfer/archive.py +0 -0
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/src/b10_transfer/cleanup.py +0 -0
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/src/b10_transfer/environment.py +0 -0
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/src/b10_transfer/info.py +0 -0
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/src/b10_transfer/space_monitor.py +0 -0
- {b10_transfer-0.1.2 → b10_transfer-0.1.3}/src/b10_transfer/utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: b10-transfer
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.3
|
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
|
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
|
|
4
4
|
|
5
5
|
[tool.poetry]
|
6
6
|
name = "b10-transfer"
|
7
|
-
version = "0.1.
|
7
|
+
version = "0.1.3"
|
8
8
|
description = "Distributed PyTorch file transfer for Baseten - Environment-aware, lock-free file transfer management"
|
9
9
|
authors = ["Shounak Ray <shounak.noreply@baseten.co>", "Fred Liu <fred.liu.noreply@baseten.co>"]
|
10
10
|
maintainers = ["Fred Liu <fred.liu.noreply@baseten.co>", "Shounak Ray <shounak.noreply@baseten.co>"]
|
@@ -35,6 +35,7 @@ from .constants import (
|
|
35
35
|
CACHE_INCOMPLETE_SUFFIX,
|
36
36
|
LoadStatus,
|
37
37
|
SaveStatus,
|
38
|
+
TransferStatus,
|
38
39
|
)
|
39
40
|
|
40
41
|
logger = logging.getLogger(__name__)
|
@@ -286,6 +287,90 @@ def save_compile_cache() -> SaveStatus:
|
|
286
287
|
space_monitor.stop()
|
287
288
|
|
288
289
|
|
290
|
+
@timed_fn(logger=logger, name="Transferring file")
|
291
|
+
@safe_execute("Transfer failed", TransferStatus.ERROR)
|
292
|
+
def transfer(source: str, dest: str) -> TransferStatus:
|
293
|
+
"""Transfer a file from source to destination with space monitoring.
|
294
|
+
|
295
|
+
This function copies a file from source to destination using the same
|
296
|
+
monitored process approach as the cache operations. It monitors disk space
|
297
|
+
at the destination and can interrupt the transfer if space becomes insufficient.
|
298
|
+
|
299
|
+
Args:
|
300
|
+
source: Path to the source file to copy.
|
301
|
+
dest: Path to the destination where the file will be copied.
|
302
|
+
|
303
|
+
Returns:
|
304
|
+
TransferStatus:
|
305
|
+
TransferStatus.SUCCESS if transfer was successful
|
306
|
+
TransferStatus.ERROR if transfer failed due to insufficient disk space,
|
307
|
+
file not found, or other errors.
|
308
|
+
|
309
|
+
Raises:
|
310
|
+
CacheOperationInterrupted: If transfer interrupted due to insufficient
|
311
|
+
disk space (caught and returns TransferStatus.ERROR).
|
312
|
+
Exception: Any other errors during transfer (caught and returns TransferStatus.ERROR).
|
313
|
+
"""
|
314
|
+
source_path = Path(source)
|
315
|
+
dest_path = Path(dest)
|
316
|
+
|
317
|
+
# Validate source file exists
|
318
|
+
if not source_path.exists():
|
319
|
+
logger.error(f"Source file does not exist: {source}")
|
320
|
+
return TransferStatus.ERROR
|
321
|
+
|
322
|
+
# Create destination directory if it doesn't exist
|
323
|
+
dest_path.parent.mkdir(parents=True, exist_ok=True)
|
324
|
+
|
325
|
+
# Determine appropriate space threshold based on destination directory
|
326
|
+
dest_dir = dest_path.parent
|
327
|
+
if str(dest_dir).startswith(B10FS_CACHE_DIR):
|
328
|
+
# Transferring to b10fs - use b10fs space requirements
|
329
|
+
space_threshold_mb = REQUIRED_B10FS_SPACE_MB
|
330
|
+
logger.debug(
|
331
|
+
f"Transfer to b10fs detected, using {space_threshold_mb:.1f}MB threshold"
|
332
|
+
)
|
333
|
+
else:
|
334
|
+
# Transferring to local directory - use local space requirements
|
335
|
+
space_threshold_mb = MIN_LOCAL_SPACE_MB
|
336
|
+
logger.debug(
|
337
|
+
f"Transfer to local directory detected, using {space_threshold_mb:.1f}MB threshold"
|
338
|
+
)
|
339
|
+
|
340
|
+
# Initial disk space check
|
341
|
+
check_sufficient_disk_space(dest_dir, space_threshold_mb, "file transfer")
|
342
|
+
logger.debug(
|
343
|
+
f"Initial space check passed: {space_threshold_mb:.1f}MB required at destination"
|
344
|
+
)
|
345
|
+
|
346
|
+
# Start background space monitoring for destination directory
|
347
|
+
space_monitor = CacheSpaceMonitor(space_threshold_mb, dest_dir)
|
348
|
+
space_monitor.start()
|
349
|
+
|
350
|
+
try:
|
351
|
+
# Run monitored copy process
|
352
|
+
logger.info(f"Starting transfer: {source} -> {dest}")
|
353
|
+
run_monitored_process(
|
354
|
+
_cache_copy_worker,
|
355
|
+
(str(source_path), str(dest_path)),
|
356
|
+
space_monitor,
|
357
|
+
"file transfer",
|
358
|
+
cleanup_func=lambda: safe_unlink(
|
359
|
+
dest_path, f"Failed to cleanup interrupted transfer {dest_path}"
|
360
|
+
),
|
361
|
+
)
|
362
|
+
|
363
|
+
logger.info("File transfer complete")
|
364
|
+
return TransferStatus.SUCCESS
|
365
|
+
|
366
|
+
except CacheOperationInterrupted as e:
|
367
|
+
logger.warning(f"File transfer interrupted: {e}")
|
368
|
+
return TransferStatus.ERROR
|
369
|
+
|
370
|
+
finally:
|
371
|
+
space_monitor.stop()
|
372
|
+
|
373
|
+
|
289
374
|
@safe_execute("Clear failed", False)
|
290
375
|
def clear_local_cache() -> bool:
|
291
376
|
"""Clear the local PyTorch compilation cache directory.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|