From f147e798418151d359718b6ea9d60468864b33fb Mon Sep 17 00:00:00 2001
From: Pavel Korshunov <pavel.korshunov@idiap.ch>
Date: Thu, 28 Sep 2017 00:35:25 +0200
Subject: [PATCH] allow missing files projector

---
 bob/pad/base/tools/algorithm.py | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/bob/pad/base/tools/algorithm.py b/bob/pad/base/tools/algorithm.py
index 6a52b9b..f8ee01b 100644
--- a/bob/pad/base/tools/algorithm.py
+++ b/bob/pad/base/tools/algorithm.py
@@ -115,13 +115,31 @@ def project(algorithm, extractor, groups=None, indices=None, allow_missing_files
         feature_file = str(feature_files[i])
         projected_file = str(projected_files[i])
 
+        if not os.path.exists(feature_file):
+            if allow_missing_files:
+                logger.debug("... Cannot find extracted feature file %s; skipping", feature_file)
+                continue
+            else:
+                logger.error("Cannot find extracted feature file %s", feature_file)
+
         if not utils.check_file(projected_file, force, 1000):
-            logger.info("- Projection: projecting file: %s", feature_file)
+            logger.debug("... Projecting features for file '%s'", feature_file)
+
             # load feature
             feature = extractor.read_feature(feature_file)
             # project feature
             projected = algorithm.project(feature)
+
+            if projected is None:
+                if allow_missing_files:
+                    logger.debug("... Projection for extracted file %s failed; skipping", feature_file)
+                    continue
+                else:
+                    raise RuntimeError("Projection of file '%s' was not successful" % feature_file)
             # write it
             bob.io.base.create_directories_safe(os.path.dirname(projected_file))
             algorithm.write_feature(projected, projected_file)
 
+        else:
+            logger.debug("... Skipping feature file '%s' since projected file '%s' exists", feature_file, projected_file)
+
-- 
GitLab