From 4a1e20c219103e589837b769aa0651bf18aac667 Mon Sep 17 00:00:00 2001 From: Ruslan Kuprieiev Date: Thu, 8 Mar 2018 08:33:57 +0200 Subject: [PATCH] repro: don't fail if dir cache is not present Fixes #518 Signed-off-by: Ruslan Kuprieiev --- dvc/output.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/dvc/output.py b/dvc/output.py index f86070e17..815c28304 100644 --- a/dvc/output.py +++ b/dvc/output.py @@ -237,12 +237,22 @@ class Output(Dependency): @staticmethod def load_dir_cache(path): - with open(path, 'r') as fd: - d = yaml.safe_load(fd) + if os.path.isabs(path): + relpath = os.path.relpath(path) + else: + relpath = path + + try: + with open(path, 'r') as fd: + d = yaml.safe_load(fd) + except Exception as exc: + msg = u'Failed to load dir cache \'{}\'' + Logger.error(msg.format(relpath), exc) + return [] if not isinstance(d, list): msg = u'Dir cache file format error \'{}\': skipping the file' - Logger.error(msg.format(path)) + Logger.error(msg.format(relpath)) return [] return d