|
| 1 | +from typing import Dict, Iterable, Optional, Tuple |
| 2 | + |
| 3 | + |
| 4 | +CommandPath = Tuple[str, ...] |
| 5 | + |
| 6 | + |
| 7 | +TOP_LEVEL_MODULES: Dict[str, Tuple[str, ...]] = { |
| 8 | + "apply": ("spacy.cli.apply",), |
| 9 | + "assemble": ("spacy.cli.assemble",), |
| 10 | + "convert": ("spacy.cli.convert",), |
| 11 | + "debug-data": ("spacy.cli.debug_data",), |
| 12 | + "download": ("spacy.cli.download",), |
| 13 | + "evaluate": ("spacy.cli.evaluate",), |
| 14 | + "find-function": ("spacy.cli.find_function",), |
| 15 | + "find-threshold": ("spacy.cli.find_threshold",), |
| 16 | + "info": ("spacy.cli.info",), |
| 17 | + "package": ("spacy.cli.package",), |
| 18 | + "pretrain": ("spacy.cli.pretrain",), |
| 19 | + "profile": ("spacy.cli.profile",), |
| 20 | + "train": ("spacy.cli.train",), |
| 21 | + "validate": ("spacy.cli.validate",), |
| 22 | +} |
| 23 | + |
| 24 | + |
| 25 | +GROUP_MODULES: Dict[str, Tuple[str, ...]] = { |
| 26 | + "benchmark": ( |
| 27 | + "spacy.cli.benchmark_speed", |
| 28 | + "spacy.cli.evaluate", |
| 29 | + ), |
| 30 | + "debug": ( |
| 31 | + "spacy.cli.debug_config", |
| 32 | + "spacy.cli.debug_data", |
| 33 | + "spacy.cli.debug_diff", |
| 34 | + "spacy.cli.debug_model", |
| 35 | + "spacy.cli.profile", |
| 36 | + ), |
| 37 | + "init": ( |
| 38 | + "spacy.cli.init_config", |
| 39 | + "spacy.cli.init_pipeline", |
| 40 | + ), |
| 41 | +} |
| 42 | + |
| 43 | + |
| 44 | +SUBCOMMAND_MODULES: Dict[CommandPath, Tuple[str, ...]] = { |
| 45 | + ("benchmark", "accuracy"): ("spacy.cli.evaluate",), |
| 46 | + ("benchmark", "speed"): ("spacy.cli.benchmark_speed",), |
| 47 | + ("debug", "config"): ("spacy.cli.debug_config",), |
| 48 | + ("debug", "data"): ("spacy.cli.debug_data",), |
| 49 | + ("debug", "diff-config"): ("spacy.cli.debug_diff",), |
| 50 | + ("debug", "model"): ("spacy.cli.debug_model",), |
| 51 | + ("debug", "profile"): ("spacy.cli.profile",), |
| 52 | + ("init", "config"): ("spacy.cli.init_config",), |
| 53 | + ("init", "fill-config"): ("spacy.cli.init_config",), |
| 54 | + ("init", "labels"): ("spacy.cli.init_pipeline",), |
| 55 | + ("init", "nlp"): ("spacy.cli.init_pipeline",), |
| 56 | + ("init", "vectors"): ("spacy.cli.init_pipeline",), |
| 57 | +} |
| 58 | + |
| 59 | + |
| 60 | +PUBLIC_ATTRS: Dict[str, Tuple[str, Optional[str]]] = { |
| 61 | + "app": ("spacy.cli._util", "app"), |
| 62 | + "apply": ("spacy.cli.apply", "apply"), |
| 63 | + "assemble_cli": ("spacy.cli.assemble", "assemble_cli"), |
| 64 | + "benchmark_speed_cli": ("spacy.cli.benchmark_speed", "benchmark_speed_cli"), |
| 65 | + "convert": ("spacy.cli.convert", "convert"), |
| 66 | + "debug_config": ("spacy.cli.debug_config", "debug_config"), |
| 67 | + "debug_data": ("spacy.cli.debug_data", "debug_data"), |
| 68 | + "debug_diff": ("spacy.cli.debug_diff", "debug_diff"), |
| 69 | + "debug_model": ("spacy.cli.debug_model", "debug_model"), |
| 70 | + "download": ("spacy.cli.download", "download"), |
| 71 | + "download_module": ("spacy.cli.download", None), |
| 72 | + "evaluate": ("spacy.cli.evaluate", "evaluate"), |
| 73 | + "fill_config": ("spacy.cli.init_config", "fill_config"), |
| 74 | + "find_function": ("spacy.cli.find_function", "find_function"), |
| 75 | + "find_threshold": ("spacy.cli.find_threshold", "find_threshold"), |
| 76 | + "info": ("spacy.cli.info", "info"), |
| 77 | + "init_config": ("spacy.cli.init_config", "init_config"), |
| 78 | + "init_pipeline_cli": ("spacy.cli.init_pipeline", "init_pipeline_cli"), |
| 79 | + "package": ("spacy.cli.package", "package"), |
| 80 | + "pretrain": ("spacy.cli.pretrain", "pretrain"), |
| 81 | + "profile": ("spacy.cli.profile", "profile"), |
| 82 | + "project_assets": ("spacy.cli.project.assets", "project_assets"), |
| 83 | + "project_clone": ("spacy.cli.project.clone", "project_clone"), |
| 84 | + "project_document": ("spacy.cli.project.document", "project_document"), |
| 85 | + "project_pull": ("spacy.cli.project.pull", "project_pull"), |
| 86 | + "project_push": ("spacy.cli.project.push", "project_push"), |
| 87 | + "project_run": ("spacy.cli.project.run", "project_run"), |
| 88 | + "project_update_dvc": ("spacy.cli.project.dvc", "project_update_dvc"), |
| 89 | + "train_cli": ("spacy.cli.train", "train_cli"), |
| 90 | + "validate": ("spacy.cli.validate", "validate"), |
| 91 | +} |
| 92 | + |
| 93 | + |
| 94 | +def iter_builtin_modules() -> Iterable[str]: |
| 95 | + seen = set() |
| 96 | + for modules in TOP_LEVEL_MODULES.values(): |
| 97 | + for module in modules: |
| 98 | + if module not in seen: |
| 99 | + seen.add(module) |
| 100 | + yield module |
| 101 | + for modules in GROUP_MODULES.values(): |
| 102 | + for module in modules: |
| 103 | + if module not in seen: |
| 104 | + seen.add(module) |
| 105 | + yield module |
0 commit comments