Skip to content
Snippets Groups Projects
Verified Commit 85337b7a authored by Yannick DAYER's avatar Yannick DAYER
Browse files

feat!: moving resources.py to the "bob bio" group.

parent 230ab887
No related branches found
No related tags found
1 merge request!322meta(deps): add bob as dependency in new structure
...@@ -75,8 +75,6 @@ ...@@ -75,8 +75,6 @@
[tool.setuptools.dynamic] [tool.setuptools.dynamic]
readme = {file = "README.md", content-type = "text/markdown"} readme = {file = "README.md", content-type = "text/markdown"}
[project.scripts]
"resources.py" = "bob.bio.base.script.resources:resources"
[project.entry-points."bob.bio.config"] [project.entry-points."bob.bio.config"]
dummy = "bob.bio.base.config.dummy.config" # for test purposes only dummy = "bob.bio.base.config.dummy.config" # for test purposes only
...@@ -93,6 +91,7 @@ ...@@ -93,6 +91,7 @@
vulnerability = "bob.bio.base.script.vulnerability:vulnerability" vulnerability = "bob.bio.base.script.vulnerability:vulnerability"
[project.entry-points."bob.bio.cli"] [project.entry-points."bob.bio.cli"]
resources = "bob.bio.base.script.resources:resources"
annotate = "bob.bio.base.script.annotate:annotate" annotate = "bob.bio.base.script.annotate:annotate"
annotate-samples = "bob.bio.base.script.annotate:annotate_samples" annotate-samples = "bob.bio.base.script.annotate:annotate_samples"
metrics = "bob.bio.base.script.commands:metrics" metrics = "bob.bio.base.script.commands:metrics"
......
"""Prints a detailed list of all resources that are registered, including the modules, where they have been registered.""" """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 os
import warnings
import bob.bio.base import click
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)",
)
parser.add_argument( import bob.bio.base
"--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.",
)
args = parser.parse_args(command_line_parameters)
kwargs = {"verbose": args.details, "packages": args.packages} @click.command()
if args.no_strip_dummy: @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"] = [] kwargs["strip"] = []
if "d" in args.types or "database" in args.types: if "database" in types:
print( 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)) print(bob.bio.base.list_resources("database", **kwargs))
if "an" in args.types or "annotator" in args.types: if "annotator" in types:
print( 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)) print(bob.bio.base.list_resources("annotator", **kwargs))
if "p" in args.types or "pipeline" in args.types: if "pipeline" in types:
print( 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)) print(bob.bio.base.list_resources("pipeline", **kwargs))
if "c" in args.types or "config" in args.types: if "config" in types:
print( 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)) 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("\nList of registered dask clients")
print( print(
bob.bio.base.list_resources( bob.bio.base.list_resources(
...@@ -97,6 +91,9 @@ def resources(command_line_parameters=None): ...@@ -97,6 +91,9 @@ def resources(command_line_parameters=None):
def databases(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 import argparse
database_replacement = "%s/.bob_bio_databases.txt" % os.environ["HOME"] database_replacement = "%s/.bob_bio_databases.txt" % os.environ["HOME"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment