Commit dec5fa81 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Write parameters in a temporary config file to enable chain loading

parent 46d00036
Pipeline #20307 passed with stage
in 38 minutes and 32 seconds
......@@ -34,7 +34,7 @@ def get_available_databases():
available_databases[database]["groups"] = []
# Searching for database groups
groups = list(database_entry_point.groups())
groups = list(database_entry_point.groups()) or ["dev"]
for g in ["dev", "eval"]:
available_databases[database]["groups"] += [g] if g in groups else []
except Exception:
......@@ -8,11 +8,14 @@ A script to run biometric recognition baselines
from .. import load_resource
import os
from .verify import main as verify
from ..baseline import get_available_databases, search_preprocessor
from bob.extension.scripts.click_helper import verbosity_option
import click
import tempfile
import logging
logger = logging.getLogger("")
@click.command(context_settings={'ignore_unknown_options': True,
......@@ -45,29 +48,45 @@ def baseline(ctx, baseline, database):
Hint: pass `--temp-directory <dir>` to set the directory for temporary files
Hint: pass `--result-directory <dir>` to set the directory for resulting score files
# Triggering training for each baseline/database
loaded_baseline = load_resource(
baseline, 'baseline', package_prefix="")
# this is the default sub-directory that is used
sub_directory = os.path.join(database, baseline)
# find the compatible preprocessor for this database
database_data = get_available_databases()[database]
db = search_preprocessor(database, loaded_baseline.preprocessors.keys())
preprocessor = loaded_baseline.preprocessors[db]
# call verify with all parameters
parameters = [
'-p', preprocessor,
'-e', loaded_baseline.extractor,
'-d', database,
'-a', loaded_baseline.algorithm,
'--sub-directory', sub_directory
] + ['-v'] * ctx.meta['verbosity']
parameters += ['--groups'] + database_data["groups"]
verify(parameters + ctx.args)
logger.debug('Database groups are %s', database_data["groups"])
# call verify with newly generated config file. We will create a new config
# file to allow people to use chain-loading and further modify the
# baselines. See:
config = '''
preprocessor = '{preprocessor}'
extractor = '{extractor}'
algorithm = '{algorithm}'
database = '{database}'
sub_directory = '{sub_directory}'
groups = ['{groups}']
verbose = {verbose}
groups="', '".join(database_data["groups"]),
with tempfile.NamedTemporaryFile(mode='w+t', prefix='{}_'.format(baseline),
suffix='.py', delete=False, dir='.') as f:
verify([] + ctx.args)
click.echo("You may want to delete `{}' after the experiments are "
"finished running.".format(
......@@ -10,11 +10,11 @@ def test_baselines():
runner = CliRunner()
result = runner.invoke(baseline, args=('dummy', 'dummy', '-T', tmp_dir, '-R', tmp_dir))
assertion_error_message = (
'Command exited with this output: `{}\' \n'
'Command exited with this output and exception: `{}\' \n `{}\' \n'
'If the output is empty, you can run this script locally to see '
'what is wrong:\n'
'bin/bob bio baseline -d dummy -a dummy -o /tmp/temp_annotations'
'bin/bob bio baseline dummy dummy -T /tmp/baseline -R /tmp/baseline'
''.format(result.output, result.exception))
assert result.exit_code == 0, assertion_error_message
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment