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

use cache dir as a default remote when importing from local repo #2915

Merged
merged 15 commits into from Dec 11, 2019

Conversation

maykulkarni
Copy link
Contributor

@maykulkarni maykulkarni commented Dec 7, 2019

If the URL is local dvc repo, the import/get should fetch from the source project cache.

Fixes #2599

  • ❗ 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 addressed. 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. πŸ™

If the URL is local dvc repo, the import/get should fetch from the source project cache.

Fixes iterative#2599
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
@efiop efiop changed the title [WIP] fix for local file import fail [WIP] use cache dir as a default remote when importing from local repo Dec 7, 2019
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
Copy link
Contributor

@pared pared left a comment

Choose a reason for hiding this comment

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

General remark:
I think that we should not modify config of remote repo
EDIT:
@efiop had the same suggestion and it has not been resolved yet

dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/remote/config.py Outdated Show resolved Hide resolved
dvc/remote/config.py Outdated Show resolved Hide resolved
tests/conftest.py Show resolved Hide resolved
tests/func/test_get.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
Copy link
Contributor

@pared pared left a comment

Choose a reason for hiding this comment

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

Some minor things, LGTM besides that.

dvc/remote/config.py Outdated Show resolved Hide resolved
dvc/remote/config.py Outdated Show resolved Hide resolved
dvc/external_repo.py Outdated Show resolved Hide resolved
dvc/remote/config.py Outdated Show resolved Hide resolved
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.

Looks good! Just a few more minor comments.

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.

Looks good! Thanks!

@efiop efiop changed the title [WIP] use cache dir as a default remote when importing from local repo use cache dir as a default remote when importing from local repo Dec 11, 2019
@efiop efiop merged commit 53c33a2 into iterative:master Dec 11, 2019
@efiop
Copy link
Member

efiop commented Dec 11, 2019

@maykulkarni Could you also create a ticket for the docs or create a PR for docs to reflect this new logic?

Comment on lines +73 to +77
# check if the URL is local and no default remote is present
# add default remote pointing to the original repo's cache location
if os.path.isdir(url):
rconfig = RemoteConfig(repo.config)
if not _default_remote_set(rconfig):
Copy link
Contributor

Choose a reason for hiding this comment

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

@maykulkarni @efiop does this logic mean that if there's a default remote setup, still DVC skips the local cache? Because I think it should try the local cache first regardless of remotes.

Copy link
Member

Choose a reason for hiding this comment

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

@jorgeorpinel Yes, precisely. It is hard for us to try both right now, as we don't have that kind of cascading remote logic implemented. I would wait for someone to ask for this.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I'm not sure I understand:

  1. Every DVC repo has a cache directory right? So in theory it can always be the first place to get stuff from when using get/import from another local project. Why does this require complicated remote checking logic?

  2. Does this PR really close import: get from source project cache if url/path are in the local systemΒ #2599 per that issue's description and discussion?

Copy link
Member

Choose a reason for hiding this comment

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

  1. Yes, but "first place to get stuff from" means that there is a second place, and our code is not ready to cascade from first to second yet, if it can't find all the stuff it needs in the local cache dir.

  2. From what we've understood initially - yes, but now it looks like we didn't quite understand each other.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. OK!

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.

import: get from source project cache if url/path are in the local system
4 participants