-
Notifications
You must be signed in to change notification settings - Fork 11
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
BF: Raise early and informative when extracting from a non-existing file #355
Conversation
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 ReportPatch coverage:
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
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. |
There was a problem hiding this 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
There was a problem hiding this 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
This fixes #354.
However, its only one step towards a proper solution. As outlined by @mih in the chat, the
path
argument ofmeta-extract
should ideally get a constraint such asEnsurePath(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.