Skip to content
Snippets Groups Projects
Commit 404c96e0 authored by André MAYORAZ's avatar André MAYORAZ
Browse files

Removed bob.extension from source code

parent b1b51794
No related branches found
No related tags found
1 merge request!105Resolve "Switch to new CI/CD configuration"
...@@ -10,14 +10,10 @@ import click ...@@ -10,14 +10,10 @@ import click
import jinja2 import jinja2
import yaml import yaml
from exposed.click import log_parameters, verbosity_option
from tabulate import tabulate from tabulate import tabulate
from bob.bio.base.score.load import get_negatives_positives, load_score from bob.bio.base.score.load import get_negatives_positives, load_score
from bob.extension.scripts.click_helper import (
bool_option,
log_parameters,
verbosity_option,
)
from bob.measure import farfrr from bob.measure import farfrr
from bob.measure.script import common_options from bob.measure.script import common_options
from bob.measure.utils import get_fta from bob.measure.utils import get_fta
...@@ -28,6 +24,47 @@ from .pad_commands import CRITERIA ...@@ -28,6 +24,47 @@ from .pad_commands import CRITERIA
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def bool_option(name, short_name, desc, dflt=False, **kwargs):
"""Generic provider for boolean options
Parameters
----------
name : str
name of the option
short_name : str
short name for the option
desc : str
short description for the option
dflt : bool or None
Default value
**kwargs
All kwargs are passed to click.option.
Returns
-------
``callable``
A decorator to be used for adding this option.
"""
def custom_bool_option(func):
def callback(ctx, param, value):
ctx.meta[name.replace("-", "_")] = value
return value
return click.option(
"-%s/-n%s" % (short_name, short_name),
"--%s/--no-%s" % (name, name),
default=dflt,
help=desc,
show_default=True,
callback=callback,
is_eager=True,
**kwargs,
)(func)
return custom_bool_option
def _ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=dict): def _ordered_load(stream, Loader=yaml.Loader, object_pairs_hook=dict):
"""Loads the contents of the YAML stream into :py:class:`collections.OrderedDict`'s """Loads the contents of the YAML stream into :py:class:`collections.OrderedDict`'s
...@@ -234,7 +271,7 @@ Examples: ...@@ -234,7 +271,7 @@ Examples:
@common_options.table_option() @common_options.table_option()
@common_options.output_log_metric_option() @common_options.output_log_metric_option()
@common_options.decimal_option(dflt=2, short="-dec") @common_options.decimal_option(dflt=2, short="-dec")
@verbosity_option() @verbosity_option(logger)
@click.pass_context @click.pass_context
def cross( def cross(
ctx, ctx,
......
"""Finalizes the scores that are produced by bob pad run-pipeline. """Finalizes the scores that are produced by bob pad run-pipeline.
""" """
import logging
import click import click
from bob.extension.scripts.click_helper import log_parameters, verbosity_option from exposed.click import log_parameters, verbosity_option
logger = logging.getLogger(__name__)
@click.command( @click.command(
...@@ -27,7 +31,7 @@ Examples: ...@@ -27,7 +31,7 @@ Examples:
@click.option( @click.option(
"--backup/--no-backup", default=True, help="Whether to backup scores." "--backup/--no-backup", default=True, help="Whether to backup scores."
) )
@verbosity_option() @verbosity_option(logger)
def finalize_scores(scores, method, backup, verbose): def finalize_scores(scores, method, backup, verbose):
"""Finalizes the scores given by bob pad run-pipeline """Finalizes the scores given by bob pad run-pipeline
When using bob.pad.base, Algorithms can produce several score values for When using bob.pad.base, Algorithms can produce several score values for
...@@ -37,13 +41,11 @@ def finalize_scores(scores, method, backup, verbose): ...@@ -37,13 +41,11 @@ def finalize_scores(scores, method, backup, verbose):
The conversion is done in-place (original files will be backed up). The conversion is done in-place (original files will be backed up).
The order of scores will change. The order of scores will change.
""" """
import logging
import shutil import shutil
import numpy import numpy
import pandas as pd import pandas as pd
logger = logging.getLogger(__name__)
log_parameters(logger) log_parameters(logger)
mean = { mean = {
......
...@@ -4,8 +4,7 @@ import click ...@@ -4,8 +4,7 @@ import click
import pkg_resources import pkg_resources
from click_plugins import with_plugins from click_plugins import with_plugins
from exposed.click import AliasedGroup
from bob.extension.scripts.click_helper import AliasedGroup
@with_plugins(pkg_resources.iter_entry_points("bob.pad.cli")) @with_plugins(pkg_resources.iter_entry_points("bob.pad.cli"))
......
"""The main entry for bob pad commands. """The main entry for bob pad commands.
""" """
import logging
import os import os
from csv import DictWriter from csv import DictWriter
...@@ -8,14 +9,17 @@ from functools import partial ...@@ -8,14 +9,17 @@ from functools import partial
import click import click
import numpy import numpy
from exposed.click import verbosity_option
import bob.measure.script.figure as measure_figure import bob.measure.script.figure as measure_figure
from bob.extension.scripts.click_helper import verbosity_option
from bob.measure.script import common_options from bob.measure.script import common_options
from ..error_utils import split_csv_pad, split_csv_pad_per_pai from ..error_utils import split_csv_pad, split_csv_pad_per_pai
from . import pad_figure as figure from . import pad_figure as figure
logger = logging.getLogger(__name__)
SCORE_FORMAT = "Files must be in CSV format." SCORE_FORMAT = "Files must be in CSV format."
CRITERIA = ( CRITERIA = (
"eer", "eer",
...@@ -190,7 +194,7 @@ def gen_pad_csv_scores( ...@@ -190,7 +194,7 @@ def gen_pad_csv_scores(
) )
@click.option("-s", "--n-samples", default=2, type=click.INT, show_default=True) @click.option("-s", "--n-samples", default=2, type=click.INT, show_default=True)
@click.option("-a", "--n-attacks", default=2, type=click.INT, show_default=True) @click.option("-a", "--n-attacks", default=2, type=click.INT, show_default=True)
@verbosity_option() @verbosity_option(logger)
@click.pass_context @click.pass_context
def gen( def gen(
ctx, ctx,
......
...@@ -5,11 +5,13 @@ import logging ...@@ -5,11 +5,13 @@ import logging
import click import click
from bob.extension.scripts.click_helper import ( from exposed.click import (
ConfigCommand, ConfigCommand,
ResourceOption, ResourceOption,
log_parameters,
verbosity_option, verbosity_option,
) )
from bob.pipelines.distributed import ( from bob.pipelines.distributed import (
VALID_DASK_CLIENT_STRINGS, VALID_DASK_CLIENT_STRINGS,
dask_get_partition_size, dask_get_partition_size,
...@@ -113,7 +115,7 @@ logger = logging.getLogger(__name__) ...@@ -113,7 +115,7 @@ logger = logging.getLogger(__name__)
help="If set, it will not use Dask for the execution of the pipeline.", help="If set, it will not use Dask for the execution of the pipeline.",
cls=ResourceOption, cls=ResourceOption,
) )
@verbosity_option(cls=ResourceOption) @verbosity_option(cls=ResourceOption, logger=logger)
def run_pipeline( def run_pipeline(
pipeline, pipeline,
decision_function, decision_function,
...@@ -129,8 +131,6 @@ def run_pipeline( ...@@ -129,8 +131,6 @@ def run_pipeline(
): ):
"""Runs the simplest PAD pipeline.""" """Runs the simplest PAD pipeline."""
from bob.extension.scripts.click_helper import log_parameters
log_parameters(logger) log_parameters(logger)
execute_pipeline( execute_pipeline(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment