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

version: improve link type detection fall back #4479

Merged
merged 3 commits into from
Sep 3, 2020
Merged

version: improve link type detection fall back #4479

merged 3 commits into from
Sep 3, 2020

Conversation

IvanRubanov
Copy link
Contributor

Create temporary file in cache dir. And use it to detect the supported cache types. Clear after cache type detection.

Fixes #2788

Comment on lines 69 to 70
if create_tmp_cache_dir:
shutil.rmtree(repo.cache.local.cache_dir, ignore_errors=True)
Copy link
Member

@efiop efiop Aug 27, 2020

Choose a reason for hiding this comment

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

A bit worried about this racing in shared cache scenarios, where cache dir might be accidentally deleted. Also, we might simply not have any rights to create that cache_dir, so btter to wrap makedirs above in a try&except logic. Also, we will be leaving traces in a form of parent directories that didn't exist before. But if we are not able to create even a temporary dir, then we will still need to show some message about it, which is actually the same thing as was suggested in the original ticket by @shcheklein as a first option. That makes me wonder if we really shouldn't overcomplicate this and just stick to the first option and just not even try to create a temporary directory. Sorry for not suggesting it earlier 🙁

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for detailed explanation about shared cache scenario.
Just to be sure I understood your message correctly. The final solution is to remove warning completely. No new code required. Is it correct?

Copy link
Member

@efiop efiop Aug 27, 2020

Choose a reason for hiding this comment

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

@IvanRubanov Yes, I think removing it and, for example, adding something like

Cache types: https://error.dvc.org/unable-to-detect-cache-type

to the dvc version output would be the best overall solution here in terms of complexity and effectiveness. Thank you so much for looking into this!

Copy link
Member

@efiop efiop left a comment

Choose a reason for hiding this comment

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

Hi @IvanRubanov !

Thank you so much for contributing! 🙏 Please see a comment above.

@IvanRubanov
Copy link
Contributor Author

@efiop could you check this PR once again?

@skshetry skshetry requested a review from efiop September 1, 2020 08:12
Comment on lines 61 to 63
info.append(
"Cache types: "
+ "https://error.dvc.org/unable-to-detect-cache-type"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
info.append(
"Cache types: "
+ "https://error.dvc.org/unable-to-detect-cache-type"
info.append(
"Cache types: " + error_link("unable-to-detect-cache-type")

error_link helper is defined in dvc.utils. Could you also add such a section to https://dvc.org/doc/user-guide/troubleshooting, please? There is an edit button at the bottom right corner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Updated PR + created new PR for web site documentation.

If failed to determine cache type print link to related web page.

Fixes #2788
Copy link
Member

@efiop efiop left a comment

Choose a reason for hiding this comment

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

Thank you @IvanRubanov ! 🙏

Comment on lines 62 to 63
logger.warning(
"Unable to detect supported link types, as cache "
"directory '{}' doesn't exist. It is usually auto-created "
"by commands such as `dvc add/fetch/pull/run/import`, "
"but you could create it manually to enable this "
"check.".format(relpath(repo.cache.local.cache_dir))
info.append(
"Cache types: " + error_link("unable-to-detect-cache-type")
Copy link
Contributor

Choose a reason for hiding this comment

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

Hi! Should some info on what the problem is be presented to the user at least? Other than just Cache types: http://error... Maybe I'm not seeing the full output just from this code.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also could we shorten the link path a bit? Maybe "no-dvc-cache"

Copy link
Contributor

Choose a reason for hiding this comment

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

(Please see also iterative/dvc.org#1751 (review).)

Copy link
Member

Choose a reason for hiding this comment

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

@jorgeorpinel Adding more info will defeat the purpose of this PR, will make the desc too long.

dvc/command/version.py Outdated Show resolved Hide resolved
@efiop efiop merged commit d460d18 into iterative:master Sep 3, 2020
@efiop
Copy link
Member

efiop commented Sep 3, 2020

Thank you @IvanRubanov ! 🙏

@skshetry skshetry added the enhancement Enhances DVC label Sep 3, 2020
@IvanRubanov IvanRubanov deleted the issue-2788 branch September 3, 2020 13:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Enhances DVC
Projects
None yet
Development

Successfully merging this pull request may close these issues.

version: improve link type detection fall back
4 participants