Skip to content

Commit d37edc4

Browse files
authored
Merge pull request #2021 from transformerlab/fix/storage-makedirs-per-path-fs
Fix path resolution at storage level
2 parents ad3ec58 + ac18dae commit d37edc4

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

api/localprovider_pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ dependencies = [
3232
"soundfile==0.13.1",
3333
"tensorboardX==2.6.2.2",
3434
"timm==1.0.15",
35-
"transformerlab==0.1.32",
35+
"transformerlab==0.1.35",
3636
"transformerlab-inference==0.2.52",
3737
"transformers==4.57.1",
3838
"wandb==0.23.1",

api/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies = [
2525
"python-dotenv==1.1.0",
2626
"python-multipart==0.0.20",
2727
"sqlalchemy[asyncio]==2.0.40",
28-
"transformerlab==0.1.34",
28+
"transformerlab==0.1.35",
2929
"transformerlab-inference==0.2.52",
3030
"uvicorn==0.35.0",
3131
"watchfiles==1.0.5",

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.1.34"
7+
version = "0.1.35"
88
description = "Python SDK for Transformer Lab"
99
readme = "README.md"
1010
requires-python = ">=3.10"

lab-sdk/src/lab/storage.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ async def root_join(*parts: str) -> str:
357357

358358

359359
async def exists(path: str) -> bool:
360-
fs = await filesystem()
360+
fs, _ = _get_fs_for_path(path)
361361
try:
362362
return await asyncio.to_thread(fs.exists, path)
363363
finally:
@@ -368,7 +368,8 @@ async def exists(path: str) -> bool:
368368
async def isdir(path: str, fs=None) -> bool:
369369
filesys = fs
370370
try:
371-
filesys = fs if fs is not None else await filesystem()
371+
if fs is None:
372+
filesys, _ = _get_fs_for_path(path)
372373
return await asyncio.to_thread(filesys.isdir, path)
373374
except Exception:
374375
return False
@@ -381,7 +382,7 @@ async def isdir(path: str, fs=None) -> bool:
381382
async def isfile(path: str) -> bool:
382383
fs = None
383384
try:
384-
fs = await filesystem()
385+
fs, _ = _get_fs_for_path(path)
385386
return await asyncio.to_thread(fs.isfile, path)
386387
except Exception:
387388
return False
@@ -391,7 +392,7 @@ async def isfile(path: str) -> bool:
391392

392393

393394
async def makedirs(path: str, exist_ok: bool = True) -> None:
394-
fs = await filesystem()
395+
fs, _ = _get_fs_for_path(path)
395396
try:
396397
await asyncio.to_thread(fs.makedirs, path, exist_ok=exist_ok)
397398
except TypeError:
@@ -404,8 +405,12 @@ async def makedirs(path: str, exist_ok: bool = True) -> None:
404405

405406

406407
async def ls(path: str, detail: bool = False, fs=None):
407-
# Use provided filesystem or get default
408-
filesys = fs if fs is not None else await filesystem()
408+
# Use provided filesystem or pick one based on the path's scheme so that
409+
# local paths don't get routed through a configured remote filesystem.
410+
if fs is not None:
411+
filesys = fs
412+
else:
413+
filesys, _ = _get_fs_for_path(path)
409414
try:
410415
paths = await asyncio.to_thread(filesys.ls, path, detail=detail)
411416
is_remote = path.startswith(_REMOTE_PATH_PREFIXES)

0 commit comments

Comments
 (0)