Skip to content

Commit 73070cf

Browse files
authored
Merge pull request #1431 from transformerlab/fix/copy-dir
Fix copy_dir in storage.py to do proper remote -> remote copies
2 parents a09b91a + 2107181 commit 73070cf

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ dependencies = [
3333
"soundfile==0.13.1",
3434
"tensorboardX==2.6.2.2",
3535
"timm==1.0.15",
36-
"transformerlab==0.0.84",
36+
"transformerlab==0.0.85",
3737
"transformerlab-inference==0.2.52",
3838
"transformers==4.57.1",
3939
"wandb==0.23.1",

lab-sdk/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "transformerlab"
7-
version = "0.0.84"
7+
version = "0.0.85"
88
description = "Python SDK for Transformer Lab"
99
readme = "README.md"
1010
requires-python = ">=3.10"

lab-sdk/src/lab/storage.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,12 @@ async def copy_dir(src_dir: str, dest_dir: str) -> None:
520520
await makedirs(dest_dir, exist_ok=True)
521521
# Determine the source filesystem independently of destination
522522
src_fs, _ = _get_fs_for_path(src_dir)
523+
# Remember protocol for remote paths so that we can reconstruct full URIs
524+
# from keys returned by fsspec (which may omit the protocol).
525+
src_protocol: Optional[str] = None
526+
if is_remote_path(src_dir):
527+
src_protocol = src_dir.split("://", 1)[0]
528+
523529
try:
524530
src_files = src_fs.find(src_dir)
525531
except Exception:
@@ -529,8 +535,14 @@ async def copy_dir(src_dir: str, dest_dir: str) -> None:
529535
for f in files:
530536
src_files.append(f)
531537

532-
for src_file in src_files:
533-
# Compute relative path with respect to the source dir
538+
for raw_src_file in src_files:
539+
# For remote filesystems, ensure we have a full URI (e.g., s3://bucket/...)
540+
src_file = raw_src_file
541+
if src_protocol is not None and not is_remote_path(raw_src_file):
542+
src_file = f"{src_protocol}://{raw_src_file.lstrip('/')}"
543+
544+
# Compute relative path with respect to the source dir using the
545+
# normalized src_file URI/path.
534546
rel_path = src_file[len(src_dir) :].lstrip("/")
535547
dest_file = join(dest_dir, rel_path)
536548
# Ensure destination directory exists

0 commit comments

Comments
 (0)