diff --git a/dvc/command/data_sync.py b/dvc/command/data_sync.py index d52006d09..8217465a3 100644 --- a/dvc/command/data_sync.py +++ b/dvc/command/data_sync.py @@ -22,9 +22,11 @@ class CmdDataBase(CmdBase): class CmdDataPull(CmdDataBase): + UP_TO_DATE_MSG = "Everything is up-to-date." + def do_run(self, target=None): try: - self.repo.pull( + processed_files_count = self.repo.pull( target=target, jobs=self.args.jobs, remote=self.args.remote, @@ -38,13 +40,17 @@ class CmdDataPull(CmdDataBase): except Exception: logger.error("failed to pull data from the cloud") return 1 + if processed_files_count == 0: + logger.info(self.UP_TO_DATE_MSG) return 0 class CmdDataPush(CmdDataBase): + UP_TO_DATE_MSG = "Everything is up-to-date." + def do_run(self, target=None): try: - self.repo.push( + processed_files_count = self.repo.push( target=target, jobs=self.args.jobs, remote=self.args.remote, @@ -57,13 +63,17 @@ class CmdDataPush(CmdDataBase): except Exception: logger.error("failed to push data to the cloud") return 1 + if processed_files_count == 0: + logger.info(self.UP_TO_DATE_MSG) return 0 class CmdDataFetch(CmdDataBase): + UP_TO_DATE_MSG = "Everything is up-to-date." + def do_run(self, target=None): try: - self.repo.fetch( + processed_files_count = self.repo.fetch( target=target, jobs=self.args.jobs, remote=self.args.remote, @@ -76,6 +86,8 @@ class CmdDataFetch(CmdDataBase): except Exception: logger.error("failed to fetch data from the cloud") return 1 + if processed_files_count == 0: + logger.info(self.UP_TO_DATE_MSG) return 0 diff --git a/dvc/remote/local.py b/dvc/remote/local.py index 63ea651c1..2d8c6c661 100644 --- a/dvc/remote/local.py +++ b/dvc/remote/local.py @@ -657,8 +657,7 @@ class RemoteLOCAL(RemoteBase): chunks = self._get_chunks(download, remote, status_info, status, jobs) if len(chunks) == 0: - print("Everything up-to-date") - return + return 0 futures = [] with ThreadPoolExecutor(max_workers=jobs) as executor: @@ -669,8 +668,10 @@ class RemoteLOCAL(RemoteBase): for f in futures: f.result() + return len(chunks) + def push(self, checksum_infos, remote, jobs=None, show_checksums=False): - self._process( + return self._process( checksum_infos, remote, jobs=jobs, @@ -679,7 +680,7 @@ class RemoteLOCAL(RemoteBase): ) def pull(self, checksum_infos, remote, jobs=None, show_checksums=False): - self._process( + return self._process( checksum_infos, remote, jobs=jobs, diff --git a/dvc/repo/fetch.py b/dvc/repo/fetch.py index 4cdc03dca..94d3c9002 100644 --- a/dvc/repo/fetch.py +++ b/dvc/repo/fetch.py @@ -23,6 +23,6 @@ def fetch( jobs=jobs, recursive=recursive, )["local"] - self.cloud.pull( + return self.cloud.pull( used, jobs, remote=remote, show_checksums=show_checksums ) diff --git a/dvc/repo/pull.py b/dvc/repo/pull.py index e0f94f4d1..7496fa56b 100644 --- a/dvc/repo/pull.py +++ b/dvc/repo/pull.py @@ -13,7 +13,7 @@ def pull( force=False, recursive=False, ): - self.fetch( + processed_files_count = self.fetch( target, jobs, remote=remote, @@ -26,3 +26,4 @@ def pull( self.checkout( target=target, with_deps=with_deps, force=force, recursive=recursive ) + return processed_files_count diff --git a/dvc/repo/push.py b/dvc/repo/push.py index 96b7263a5..09ddca34c 100644 --- a/dvc/repo/push.py +++ b/dvc/repo/push.py @@ -23,6 +23,6 @@ def push( jobs=jobs, recursive=recursive, )["local"] - self.cloud.push( + return self.cloud.push( used, jobs, remote=remote, show_checksums=show_checksums )