import: intercept and rephrase OutputNotFound message#2777
Conversation
|
Example: was: after change: |
|
The thing with this it affects not only import, but also get as well as It says basically wrap the |
|
Thanks @Suor for pointing that out. Ill fix that. |
| return get_stages(self.graph) | ||
|
|
||
| def find_outs_by_path(self, path, outs=None, recursive=False): | ||
| abs_path = ( |
There was a problem hiding this comment.
So why do we need this if we have find_outs_by_relpath already?
There was a problem hiding this comment.
Ah, I see you've removed it.
| def status(self): | ||
| with self._make_repo() as repo: | ||
| current = repo.find_out_by_relpath(self.def_path).info | ||
| current = repo.find_out_by_path(self.def_path).info |
There was a problem hiding this comment.
Not sure why this was required?
There was a problem hiding this comment.
Technically its not required, though considering change in find_outs_by_path, now find_out_by_relpath will work both with abs and relpath, thats why I decided to rename it.
There was a problem hiding this comment.
@pared yeah, but why do we need to make find_out_by_path accept relpaths? Just wondering.
There was a problem hiding this comment.
To pass original path to OutputNotFoundError. It makes sense because it passes originally inputed path to error, which is easier to understand, since its user input. Calculating relpaths/abspaths was the original reason for ambiguous paths flooding stderr when output could not be found.
27db275 to
5c59d74
Compare
There was a problem hiding this comment.
It used to support paths relative to curdir, it won't after this change. Now it understands non absolute paths as relative to root dir. So this is a change in semantics. Will it break something? Why do we need it?
There was a problem hiding this comment.
Oh, you are right, should make abspath out of it.
I moved abspath calculation here so that I could pass path to OutputNotFoundError. In case of relative path passed by user, OutputNotFoundError can use the input for error message, which is more meaningful than printing full path or path relative to curdir, as it used to be.
https://asciinema.org/a/280576
vs
https://asciinema.org/a/280577
There was a problem hiding this comment.
But it should stay relative to curdir for outs within current repo. Like it or not, but it is what we are doing everywhere now.
There was a problem hiding this comment.
I know I suggested it, but it is fragile. We don't know whether that OutputNotFoundError we catch here comes from the yielded repo. To fix this we will probably need to pass repo to OutputNotFoundError and check it here:
if cause.repo is repo:
# wrap
else:
raiseI also wouldn't call it cause but simply exc, it only becomes a cause when we wrap it not when we catch it.
efd50fc to
a55292b
Compare
291dfc3 to
822f5c1
Compare
|
@Suor @jorgeorpinel Please review. EDIT: sorry, nevermind, this is a WIP, seems like |
|
@Suor, @jorgeorpinel I think it should be ready now. |
|
For the record: unrelated tests failed, that are already fixed on master. |
❗ Have you followed the guidelines in the Contributing to DVC list?
📖 Check this box if this PR does not require documentation updates, or if it does and you have created a separate PR in dvc.org with such updates (or at least opened an issue about it in that repo). Please link below to your PR (or issue) in the dvc.org repo.
❌ Have you checked DeepSource, CodeClimate, and other sanity checks below? We consider their findings recommendatory and don't expect everything to be addresses. Please review them carefully and fix those that actually improve code or fix bugs.
Thank you for the contribution - we'll try to review it as soon as possible. 🙏
Related to #2602