From 7f2d2e55c9385127620c046b7fa999c31e09a4db Mon Sep 17 00:00:00 2001 From: David de la Iglesia Castro Date: Tue, 13 Dec 2022 00:02:50 +0100 Subject: [PATCH] live: Don't log unnecessary warnings. Only log warnings about Studio if `studio_token` is set. Only log warnings about DVC Repo if `save_dvc_exp` is True. --- src/dvclive/dvc.py | 4 ---- src/dvclive/live.py | 10 +++++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/dvclive/dvc.py b/src/dvclive/dvc.py index 2cfd92d7..ea70967f 100644 --- a/src/dvclive/dvc.py +++ b/src/dvclive/dvc.py @@ -84,10 +84,6 @@ def get_dvc_repo(): try: return Repo() except (NotDvcRepoError, SCMError): - logger.warning( - "Can't save experiment without a DVC Repo." - "\nYou can create a DVC Repo by calling `dvc init`." - ) return None diff --git a/src/dvclive/live.py b/src/dvclive/live.py index 850176d3..fd54245d 100644 --- a/src/dvclive/live.py +++ b/src/dvclive/live.py @@ -126,8 +126,17 @@ def _init_dvc(self): self._dvc_repo.scm, self._baseline_rev ) mark_dvclive_only_started() + else: + logger.warning( + "Can't save experiment without a DVC Repo." + "\nYou can create a DVC Repo by calling `dvc init`." + ) def _init_studio(self): + self._studio_token = os.getenv(env.STUDIO_TOKEN, None) + if not self._studio_token: + return + if not self._dvc_repo: logger.warning("`studio` report can't be used without a DVC Repo.") return @@ -137,7 +146,6 @@ def _init_studio(self): self._studio_url = get_studio_repo_url( self._dvc_repo.scm.gitpython.repo ) - self._studio_token = os.getenv(env.STUDIO_TOKEN, None) if self._studio_url and self._studio_token: if self._inside_dvc_exp: