diff --git a/bob/bio/base/annotator/FailSafe.py b/bob/bio/base/annotator/FailSafe.py index caa57719e13d3e34ea2715797494096524bd38d6..4ba32ad673d088a7d8bdfffc9a2447dc835d488a 100644 --- a/bob/bio/base/annotator/FailSafe.py +++ b/bob/bio/base/annotator/FailSafe.py @@ -26,7 +26,7 @@ class FailSafe(Annotator): def annotate(self, sample, **kwargs): if 'annotations' not in kwargs or kwargs['annotations'] is None: - kwargs['annotations'] = None + kwargs['annotations'] = {} for annotator in self.annotators: try: annotations = annotator(sample, **kwargs) diff --git a/bob/bio/base/script/annotate.py b/bob/bio/base/script/annotate.py index 4df5c528719a3e66ef8a7b123ea205b72d17a412..e9dc135abbd6e42b19ac39e6d9f39fc709ae6965 100644 --- a/bob/bio/base/script/annotate.py +++ b/bob/bio/base/script/annotate.py @@ -77,9 +77,9 @@ def annotate(database, annotator, output_dir, force, array, **kwargs): outpath = biofile.make_path(output_dir, '.json') if isfile(outpath): if force: - logger.debug("Overwriting the annotations file `%s'", outpath) + logger.info("Overwriting the annotations file `%s'", outpath) else: - logger.debug("The annotation `%s' already exists", outpath) + logger.info("The annotation `%s' already exists", outpath) continue logger.info( diff --git a/bob/bio/base/test/dummy/annotator.py b/bob/bio/base/test/dummy/annotator.py index e58f6c62d3cc8c030100db4301de85ef70f3b113..0a780fee2efa661b0097269bd67e29f04a907d05 100644 --- a/bob/bio/base/test/dummy/annotator.py +++ b/bob/bio/base/test/dummy/annotator.py @@ -1,11 +1,17 @@ +from random import random from bob.bio.base.annotator import FailSafe, Callable -def simple_annotator(image, **kwargs): - return { - 'topleft': (0, 0), - 'bottomright': image.shape, - } +def moody_annotator(image, **kwargs): + if random() < 0.5: + return { + 'topleft': (0, 0), + } + else: + return { + 'topleft': (0, 0), + 'bottomright': image.shape, + } def fail_annotator(image, **kwargs): @@ -14,6 +20,6 @@ def fail_annotator(image, **kwargs): annotator = FailSafe( [Callable(fail_annotator), - Callable(simple_annotator)], + Callable(moody_annotator)], required_keys=['topleft', 'bottomright'], ) diff --git a/bob/bio/base/test/test_annotators.py b/bob/bio/base/test/test_annotators.py index ee4cdc77f1872fffadc2a602c6f8f95b76909320..b8735b1e748e5c8d637fc429db3bfe3b1b551714 100644 --- a/bob/bio/base/test/test_annotators.py +++ b/bob/bio/base/test/test_annotators.py @@ -13,7 +13,13 @@ def test_annotate(): runner = CliRunner() result = runner.invoke(annotate, args=( '-d', 'dummy', '-a', 'dummy', '-o', tmp_dir)) - assert result.exit_code == 0, result.output + assertion_error_message = ( + 'Command exited with this output: `{}\' \n' + 'If the output is empty, you can run this script locally to see ' + 'what is wrong:\n' + 'bin/bob bio annotate -vvv --force -d dummy -a dummy -o /tmp/temp_annotations' + ''.format(result.output)) + assert result.exit_code == 0, assertion_error_message # test if annotations exist for dirpath, dirnames, filenames in os.walk(tmp_dir):