Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BF: Raise early and informative when extracting from a non-existing file #355

Merged
merged 3 commits into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions datalad_metalad/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ def __call__(
f"dataset given by {source_dataset.pathobj}"
)
path_object = relative_path
# a basic sanity check: Does the to-be-extracted file exist (as a
# file or symlink)
if not (source_dataset.pathobj / path_object).exists() and \
not (source_dataset.pathobj / path_object).is_symlink():
raise ValueError(
"To-be-extracted file %s does not exist" % str(path_object)
)

_, file_tree_path = get_path_info(source_dataset, path_object, None)

Expand Down
2 changes: 1 addition & 1 deletion datalad_metalad/tests/test_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ def check_with_file_path(dfe_mock: type(unittest.mock.MagicMock),


@with_tempfile(mkdir=True)
def test_not_tracked_error_catching(temp_dir=None):
def test_not_existent_error_catching(temp_dir=None):
# expect a value error, if the provided file is not tracked.
ds_path = Path(temp_dir) / "dataset"
ds = Dataset(ds_path).create()
Expand Down