@@ -446,35 +446,36 @@ def log_artifact(
446
446
)
447
447
448
448
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
- "\n To 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 += "\n It is already being tracked automatically."
465
- logger .info (msg )
466
- else :
467
- msg += (
468
- "\n To track it automatically during `dvc exp run`:"
469
- f"\n 1. Run `dvc exp remove { path_stage .addressing } ` "
470
- "to stop tracking it outside the pipeline."
471
- "\n 2. Add it as an output of the pipeline stage."
472
- )
473
- logger .warning (msg )
474
- return
475
-
476
449
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
+ "\n To 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 += "\n It is already being tracked automatically."
466
+ logger .info (msg )
467
+ else :
468
+ msg += (
469
+ "\n To track it automatically during `dvc exp run`:"
470
+ f"\n 1. Run `dvc exp remove { path_stage .addressing } ` "
471
+ "to stop tracking it outside the pipeline."
472
+ "\n 2. Add it as an output of the pipeline stage."
473
+ )
474
+ logger .warning (msg )
475
+ return
476
+
477
477
stage = self ._dvc_repo .add (str (path ))
478
+
478
479
except Exception as e : # noqa: BLE001
479
480
logger .warning (f"Failed to dvc add { path } : { e } " )
480
481
return
0 commit comments