Skip to content

Commit 36e8c4c

Browse files
author
Dave Berenbaum
authored
wrap cache warnings to suppress errors (#644)
1 parent 72b9125 commit 36e8c4c

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

Diff for: src/dvclive/live.py

+28-27
Original file line numberDiff line numberDiff line change
@@ -446,35 +446,36 @@ def log_artifact(
446446
)
447447

448448
def cache(self, path):
449-
if self._inside_dvc_exp:
450-
msg = f"Skipping dvc add {path} because `dvc exp run` is running."
451-
path_stage = None
452-
for stage in self._dvc_repo.index.stages:
453-
for out in stage.outs:
454-
if out.fspath == str(Path(path).absolute()):
455-
path_stage = stage
456-
break
457-
if not path_stage:
458-
msg += (
459-
"\nTo track it automatically during `dvc exp run`, "
460-
"add it as an output of the pipeline stage."
461-
)
462-
logger.warning(msg)
463-
elif path_stage.cmd:
464-
msg += "\nIt is already being tracked automatically."
465-
logger.info(msg)
466-
else:
467-
msg += (
468-
"\nTo track it automatically during `dvc exp run`:"
469-
f"\n1. Run `dvc exp remove {path_stage.addressing}` "
470-
"to stop tracking it outside the pipeline."
471-
"\n2. Add it as an output of the pipeline stage."
472-
)
473-
logger.warning(msg)
474-
return
475-
476449
try:
450+
if self._inside_dvc_exp:
451+
msg = f"Skipping dvc add {path} because `dvc exp run` is running."
452+
path_stage = None
453+
for stage in self._dvc_repo.index.stages:
454+
for out in stage.outs:
455+
if out.fspath == str(Path(path).absolute()):
456+
path_stage = stage
457+
break
458+
if not path_stage:
459+
msg += (
460+
"\nTo track it automatically during `dvc exp run`, "
461+
"add it as an output of the pipeline stage."
462+
)
463+
logger.warning(msg)
464+
elif path_stage.cmd:
465+
msg += "\nIt is already being tracked automatically."
466+
logger.info(msg)
467+
else:
468+
msg += (
469+
"\nTo track it automatically during `dvc exp run`:"
470+
f"\n1. Run `dvc exp remove {path_stage.addressing}` "
471+
"to stop tracking it outside the pipeline."
472+
"\n2. Add it as an output of the pipeline stage."
473+
)
474+
logger.warning(msg)
475+
return
476+
477477
stage = self._dvc_repo.add(str(path))
478+
478479
except Exception as e: # noqa: BLE001
479480
logger.warning(f"Failed to dvc add {path}: {e}")
480481
return

0 commit comments

Comments
 (0)