Skip to content

Commit a1df7a7

Browse files
[Internal] revert Support Models in dbutils.fs operations (#750) (#778)
This reverts commit 3162545. Verified that /Models download still work correctly. ## Changes <!-- Summary of your changes that are easy to understand --> ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> - [ ] `make test` run locally - [ ] `make fmt` applied - [ ] relevant integration tests applied
1 parent 79b096f commit a1df7a7

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

databricks/sdk/mixins/files.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def __repr__(self) -> str:
167167
return f"<_DbfsIO {self._path} {'read' if self.readable() else 'write'}=True>"
168168

169169

170-
class _FilesIO(BinaryIO):
170+
class _VolumesIO(BinaryIO):
171171

172172
def __init__(self, api: files.FilesAPI, path: str, *, read: bool, write: bool, overwrite: bool):
173173
self._buffer = []
@@ -262,7 +262,7 @@ def __exit__(self, __t, __value, __traceback):
262262
self.close()
263263

264264
def __repr__(self) -> str:
265-
return f"<_FilesIO {self._path} {'read' if self.readable() else 'write'}=True>"
265+
return f"<_VolumesIO {self._path} {'read' if self.readable() else 'write'}=True>"
266266

267267

268268
class _Path(ABC):
@@ -398,7 +398,7 @@ def __repr__(self) -> str:
398398
return f'<_LocalPath {self._path}>'
399399

400400

401-
class _FilesPath(_Path):
401+
class _VolumesPath(_Path):
402402

403403
def __init__(self, api: files.FilesAPI, src: Union[str, pathlib.Path]):
404404
self._path = pathlib.PurePosixPath(str(src).replace('dbfs:', '').replace('file:', ''))
@@ -411,7 +411,7 @@ def _is_dbfs(self) -> bool:
411411
return False
412412

413413
def child(self, path: str) -> Self:
414-
return _FilesPath(self._api, str(self._path / path))
414+
return _VolumesPath(self._api, str(self._path / path))
415415

416416
def _is_dir(self) -> bool:
417417
try:
@@ -431,7 +431,7 @@ def exists(self) -> bool:
431431
return self.is_dir
432432

433433
def open(self, *, read=False, write=False, overwrite=False) -> BinaryIO:
434-
return _FilesIO(self._api, self.as_string, read=read, write=write, overwrite=overwrite)
434+
return _VolumesIO(self._api, self.as_string, read=read, write=write, overwrite=overwrite)
435435

436436
def list(self, *, recursive=False) -> Generator[files.FileInfo, None, None]:
437437
if not self.is_dir:
@@ -458,13 +458,13 @@ def list(self, *, recursive=False) -> Generator[files.FileInfo, None, None]:
458458
def delete(self, *, recursive=False):
459459
if self.is_dir:
460460
for entry in self.list(recursive=False):
461-
_FilesPath(self._api, entry.path).delete(recursive=True)
461+
_VolumesPath(self._api, entry.path).delete(recursive=True)
462462
self._api.delete_directory(self.as_string)
463463
else:
464464
self._api.delete(self.as_string)
465465

466466
def __repr__(self) -> str:
467-
return f'<_FilesPath {self._path}>'
467+
return f'<_VolumesPath {self._path}>'
468468

469469

470470
class _DbfsPath(_Path):
@@ -589,8 +589,8 @@ def _path(self, src):
589589
'UC Volumes paths, not external locations or DBFS mount points.')
590590
if src.scheme == 'file':
591591
return _LocalPath(src.geturl())
592-
if src.path.startswith(('/Volumes', '/Models')):
593-
return _FilesPath(self._files_api, src.geturl())
592+
if src.path.startswith('/Volumes'):
593+
return _VolumesPath(self._files_api, src.geturl())
594594
return _DbfsPath(self._dbfs_api, src.geturl())
595595

596596
def copy(self, src: str, dst: str, *, recursive=False, overwrite=False):

tests/test_dbfs_mixins.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import pytest
22

33
from databricks.sdk.errors import NotFound
4-
from databricks.sdk.mixins.files import (DbfsExt, _DbfsPath, _FilesPath,
5-
_LocalPath)
4+
from databricks.sdk.mixins.files import (DbfsExt, _DbfsPath, _LocalPath,
5+
_VolumesPath)
66

77

88
def test_moving_dbfs_file_to_local_dir(config, tmp_path, mocker):
@@ -55,14 +55,11 @@ def test_moving_local_dir_to_dbfs(config, tmp_path, mocker):
5555

5656

5757
@pytest.mark.parametrize('path,expected_type', [('/path/to/file', _DbfsPath),
58-
('/Volumes/path/to/file', _FilesPath),
59-
('/Models/path/to/file', _FilesPath),
58+
('/Volumes/path/to/file', _VolumesPath),
6059
('dbfs:/path/to/file', _DbfsPath),
61-
('dbfs:/Volumes/path/to/file', _FilesPath),
62-
('dbfs:/Models/path/to/file', _FilesPath),
60+
('dbfs:/Volumes/path/to/file', _VolumesPath),
6361
('file:/path/to/file', _LocalPath),
64-
('file:/Volumes/path/to/file', _LocalPath),
65-
('file:/Models/path/to/file', _LocalPath), ])
62+
('file:/Volumes/path/to/file', _LocalPath), ])
6663
def test_fs_path(config, path, expected_type):
6764
dbfs_ext = DbfsExt(config)
6865
assert isinstance(dbfs_ext._path(path), expected_type)

0 commit comments

Comments
 (0)