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

Conversation

adswa
Copy link
Member

@adswa adswa commented Mar 1, 2023

This fixes #354.
However, its only one step towards a proper solution. As outlined by @mih in the chat, the path argument of meta-extract should ideally get a constraint such as EnsurePath(lexists=True) (https://github.com/datalad/datalad-next/blob/c3f60e9e55ab0d9e77fb5cc2f02479a092445cc8/datalad_next/constraints/basic.py#L328) that can perform this input validation automatically before the command runs. This change is more along the lines of how-we-do-it-in-core (add a series of sanity checks at the start of a command)

Nevertheless, its an improvement from the status quo (which delayed raising the error to the last possible point in time, after an internal status call didn't return a status, and raised it with less informative error about the lack of a dataset status), and would behavior-wise be compatible/identical to what future proper parameter validation would do from the perspective of a user (throw an exception).

This PR also renames test which implied to test behavior on untracked files, when in reality it tested behavior on non-existing files.

adswa added 2 commits March 1, 2023 08:53
Meta-extract cannot work with non-existing files. Thus, whether or not a
given path exists is an imperative check. Ideally, this check should be done
with proper parameter constraints and input validation as done in datalad-next.
As a step towards this, this change makes meta-extract raise a ValueError
when a provided path does not exist.

Any proper parameter validation that would be implemented in the future would
also raise a ValueError such that the pattern introduced here now would be
consistent when better validation is in place

The new behavior is an improvement from the status quo, which threw an error
at the last possible moment: When an internal status() call on the non-existent
path would not return a result. With this change, the problem is caught as
early as currently possible
This test doesn't test what happens with untracked files, it tests what
happens with non-existent files
@codecov-commenter
Copy link

codecov-commenter commented Mar 1, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.02 ⚠️

Comparison is base (fc20e5c) 86.42% compared to head (fc180c4) 86.40%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #355      +/-   ##
==========================================
- Coverage   86.42%   86.40%   -0.02%     
==========================================
  Files          88       88              
  Lines        4831     4833       +2     
==========================================
+ Hits         4175     4176       +1     
- Misses        656      657       +1     
Impacted Files Coverage Δ
datalad_metalad/extract.py 90.72% <100.00%> (-0.34%) ⬇️
datalad_metalad/tests/test_extract.py 99.65% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@christian-monch christian-monch changed the base branch from master to maint_0.4 March 3, 2023 14:18
@christian-monch christian-monch changed the base branch from maint_0.4 to master March 3, 2023 14:18
@christian-monch christian-monch changed the base branch from master to maint_0.4 March 3, 2023 14:41
Copy link
Collaborator

@christian-monch christian-monch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks @adswa for this

Copy link
Collaborator

@christian-monch christian-monch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx @adswa, nice work

@christian-monch christian-monch merged commit 570a214 into datalad:maint_0.4 May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

meta-extract: Catch non-existing paths earlier
3 participants