diff --git a/conda/meta.yaml b/conda/meta.yaml index f80906f875d81cfba625634c51d609e034bfbd50..5f0355a5f0e8977448440fafe7e20b88c0d87547 100644 --- a/conda/meta.yaml +++ b/conda/meta.yaml @@ -21,12 +21,12 @@ requirements: - python {{ python }} - setuptools {{ setuptools }} - pip {{ pip }} - - clapper - - bob.extension >5.0.1 + - bob - bob.io.base - bob.learn.em - bob.measure - bob.pipelines + - clapper {{ clapper }} - click {{ click }} - click-plugins {{ click_plugins }} - dask {{ dask }} @@ -37,12 +37,12 @@ requirements: run: - python - setuptools - - clapper - - bob.extension + - bob - bob.io.base - bob.learn.em - bob.measure - bob.pipelines + - {{ pin_compatible('clapper') }} - {{ pin_compatible('click') }} - {{ pin_compatible('click-plugins') }} - {{ pin_compatible('dask') }} diff --git a/pyproject.toml b/pyproject.toml index 029856de2c3ed8105c642554b14be518e6411c22..7087b36895c72dc641a1b28a5534f2af278935ac 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,15 +24,15 @@ "Topic :: Scientific/Engineering :: Artificial Intelligence", ] dependencies = [ - "bob.extension > 5.0.1", + "bob", "bob.io.base", "bob.learn.em", "bob.measure", "bob.pipelines", + "clapper", "click", "click-plugins", "dask", - "clapper", "numpy", "pandas", "scipy", @@ -75,8 +75,6 @@ [tool.setuptools.dynamic] readme = {file = "README.md", content-type = "text/markdown"} -[project.scripts] - "resources.py" = "bob.bio.base.script.resources:resources" [project.entry-points."bob.bio.config"] dummy = "bob.bio.base.config.dummy.config" # for test purposes only @@ -93,6 +91,7 @@ vulnerability = "bob.bio.base.script.vulnerability:vulnerability" [project.entry-points."bob.bio.cli"] + resources = "bob.bio.base.script.resources:resources" annotate = "bob.bio.base.script.annotate:annotate" annotate-samples = "bob.bio.base.script.annotate:annotate_samples" metrics = "bob.bio.base.script.commands:metrics" diff --git a/src/bob/bio/base/script/resources.py b/src/bob/bio/base/script/resources.py index 2534d144e8b717ce826bec883ae9b3e4f8584056..bf16d88705732ea207b6227a30188750b74fd0cd 100644 --- a/src/bob/bio/base/script/resources.py +++ b/src/bob/bio/base/script/resources.py @@ -1,91 +1,85 @@ """Prints a detailed list of all resources that are registered, including the modules, where they have been registered.""" -from __future__ import print_function - import os +import warnings -import bob.bio.base - - -def resources(command_line_parameters=None): - import argparse - - parser = argparse.ArgumentParser( - description=__doc__, - formatter_class=argparse.ArgumentDefaultsHelpFormatter, - ) - parser.add_argument( - "--types", - "-t", - nargs="+", - choices=( - "d", - "database", - "an", - "annotator", - "p", - "pipeline", - "c", - "config", - "C", - "dask", - ), - default=("d", "an", "p", "c", "C"), - help="Select the resource types that should be listed.", - ) - - parser.add_argument( - "--details", - "-d", - action="store_true", - help="Prints the complete configuration for all resources", - ) - - parser.add_argument( - "--packages", - "-p", - nargs="+", - help="If given, shows only resources defined in the given package(s)", - ) +import click - parser.add_argument( - "--no-strip-dummy", - "-s", - action="store_true", - help="If given, the dummy elements (usually used for testing purposes only) are **not** removed from the list.", - ) +import bob.bio.base - args = parser.parse_args(command_line_parameters) - kwargs = {"verbose": args.details, "packages": args.packages} - if args.no_strip_dummy: +@click.command() +@click.option( + "--types", + "-t", + type=click.Choice( + ["database", "annotator", "pipeline", "config", "dask"], + case_sensitive=False, + ), + multiple=True, + default=["database", "annotator", "pipeline", "config", "dask"], + help="Select the resource types that should be listed.", +) +@click.option( + "--details", + "-d", + is_flag=True, + default=False, + help="Prints the complete configuration for all resources", +) +@click.option( + "--packages", + "-p", + multiple=True, + help="If given, shows only resources defined in the given package(s)", +) +@click.option( + "--no-strip-dummy", + "-s", + is_flag=True, + default=False, + help="If given, the dummy elements (usually used for testing purposes only) are **not** removed from the list.", +) +def resources(types, details, packages, no_strip_dummy): + """Lists the currently registered configurations for this environment.""" + + # TODO This needs to be updated! + + kwargs = {"verbose": details, "packages": packages} + if no_strip_dummy: kwargs["strip"] = [] - if "d" in args.types or "database" in args.types: + if "database" in types: print( - "\nList of registered databases (can be used after the --database option):" + "\nList of registered databases (can be used after the --database " + "option):" ) print(bob.bio.base.list_resources("database", **kwargs)) - if "an" in args.types or "annotator" in args.types: + if "annotator" in types: print( - "\nList of registered annotators (can be used after the --annotator option):" + "\nList of registered annotators (can be used after the " + "--annotator option):" ) print(bob.bio.base.list_resources("annotator", **kwargs)) - if "p" in args.types or "pipeline" in args.types: + if "pipeline" in types: print( - "\nList of registered pipelines (can be used after the --pipeline option):" + "\nList of registered pipelines (can be used after the --pipeline " + "option):" ) print(bob.bio.base.list_resources("pipeline", **kwargs)) - if "c" in args.types or "config" in args.types: + if "config" in types: print( - "\nList of registered configs. Configs may contain multiple resources and they also allow chain loading (see bob.extension docs on chain loading). Configs are used as arguments to commands such as simple):" + "\nList of registered configs. Configs may contain multiple " + "resources and they also allow chain loading (see bob.extension " + "docs on chain loading). Configs are used as arguments to commands " + "such as simple):" ) print(bob.bio.base.list_resources("config", **kwargs)) - if "C" in args.types or "dask" in args.types: + if "dask" in types: print("\nList of registered dask clients") print( bob.bio.base.list_resources( @@ -97,6 +91,9 @@ def resources(command_line_parameters=None): def databases(command_line_parameters=None): + warnings.warn( + "The databases command is deprecated. You should not be using it!" + ) import argparse database_replacement = "%s/.bob_bio_databases.txt" % os.environ["HOME"]