-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
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. |
dvc/repo/__init__.py
Outdated
@@ -418,10 +418,15 @@ def stages(self): | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So why do we need this if we have find_outs_by_relpath
already?
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.
Ah, I see you've removed it.
dvc/dependency/repo.py
Outdated
@@ -49,10 +49,10 @@ def _make_repo(self, **overrides): | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this was required?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pared yeah, but why do we need to make find_out_by_path
accept relpaths? Just wondering.
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.
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
dvc/repo/__init__.py
Outdated
abs_path = ( | ||
os.path.join(self.root_dir, path) | ||
if not os.path.isabs(path) | ||
else path | ||
) |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
dvc/external_repo.py
Outdated
try: | ||
yield repo | ||
except OutputNotFoundError as cause: | ||
raise NoOutputInExternalRepoError(url, cause.failed_output) |
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.
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:
raise
I 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