-
Notifications
You must be signed in to change notification settings - Fork 1.2k
status: implement support for imported files #3150
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
Changes from all commits
f949b31
c9b0593
8f464c2
cfbdccd
e5d35cb
3228b47
1a26d3b
799d902
289797e
008a531
4ada384
a0bdaa4
5883d3d
a9bdaec
cd3ef18
fcb7681
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,8 +9,10 @@ | |
| from dvc.external_repo import external_repo | ||
| from dvc.exceptions import NotDvcRepoError | ||
| from dvc.exceptions import OutputNotFoundError | ||
| from dvc.exceptions import NoOutputInExternalRepoError | ||
| from dvc.exceptions import PathMissingError | ||
| from dvc.utils.fs import fs_copy | ||
| from dvc.path_info import PathInfo | ||
| from dvc.scm import SCM | ||
|
|
||
|
|
||
|
|
@@ -46,14 +48,31 @@ def _make_repo(self, **overrides): | |
| with external_repo(**merge(self.def_repo, overrides)) as repo: | ||
| yield repo | ||
|
|
||
| def status(self): | ||
| with self._make_repo() as repo: | ||
| current = repo.find_out_by_relpath(self.def_path).info | ||
| def _get_checksum(self, updated=False): | ||
| rev_lock = None | ||
| if not updated: | ||
| rev_lock = self.def_repo.get(self.PARAM_REV_LOCK) | ||
|
|
||
| with self._make_repo(rev_lock=None) as repo: | ||
| updated = repo.find_out_by_relpath(self.def_path).info | ||
| try: | ||
| with self._make_repo(rev_lock=rev_lock) as repo: | ||
| return repo.find_out_by_relpath(self.def_path).info["md5"] | ||
| except (NotDvcRepoError, NoOutputInExternalRepoError): | ||
| # Fall through and clone | ||
| pass | ||
|
|
||
| repo_path = cached_clone( | ||
| self.def_repo[self.PARAM_URL], | ||
| rev=rev_lock or self.def_repo.get(self.PARAM_REV), | ||
| ) | ||
| path = PathInfo(os.path.join(repo_path, self.def_path)) | ||
|
|
||
| return self.repo.cache.local.get_checksum(path) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We really shouldn't do this. If path happens to be a dir then it will add that dir listing to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Suor It is not an issue really. Those are tiny files and will get cleaned up on gc. |
||
|
|
||
| def status(self): | ||
| current_checksum = self._get_checksum(updated=False) | ||
| updated_checksum = self._get_checksum(updated=True) | ||
|
|
||
| if current != updated: | ||
| if current_checksum != updated_checksum: | ||
| return {str(self): "update available"} | ||
|
|
||
| return {} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,28 +10,32 @@ | |
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def _local_status(self, targets=None, with_deps=False): | ||
| def _joint_status(stages): | ||
| status = {} | ||
|
|
||
| if targets: | ||
| stages = cat(self.collect(t, with_deps=with_deps) for t in targets) | ||
| else: | ||
| stages = self.collect(None, with_deps=with_deps) | ||
|
|
||
|
Comment on lines
-16
to
-20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess you've split these because of deep source, right? Nothing wrong with that, just asking 🙂 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's exactly it :) |
||
| for stage in stages: | ||
| if stage.locked: | ||
| if stage.locked and not stage.is_repo_import: | ||
| logger.warning( | ||
| "DVC-file '{path}' is locked. Its dependencies are" | ||
| " not going to be shown in the status output.".format( | ||
| path=stage.relpath | ||
| ) | ||
| ) | ||
|
|
||
| status.update(stage.status()) | ||
| status.update(stage.status(check_updates=True)) | ||
|
|
||
| return status | ||
|
|
||
|
|
||
| def _local_status(self, targets=None, with_deps=False): | ||
| if targets: | ||
| stages = cat(self.collect(t, with_deps=with_deps) for t in targets) | ||
| else: | ||
| stages = self.collect(None, with_deps=with_deps) | ||
|
|
||
| return _joint_status(stages) | ||
|
|
||
|
|
||
| def _cloud_status( | ||
| self, | ||
| targets=None, | ||
|
|
||
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.
Luckily we do have
git + dvcclones refactor on our todo list 🙂Not a part of this PR or anything, it is just us messing up earlier. 😅