From 4cd052e81d3b7cff9afaa7ca1870a04ef35adeda Mon Sep 17 00:00:00 2001 From: Ines Montani Date: Wed, 25 Aug 2021 22:58:01 +1000 Subject: [PATCH] Include component factories in third-party dependencies resolver (#9009) * Include component factories in third-party dependencies resolver * Increment catalogue and update test --- requirements.txt | 2 +- setup.cfg | 2 +- spacy/cli/package.py | 3 +++ spacy/tests/test_cli.py | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index ad8c70318..74dd11375 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ ml_datasets>=0.2.0,<0.3.0 murmurhash>=0.28.0,<1.1.0 wasabi>=0.8.1,<1.1.0 srsly>=2.4.1,<3.0.0 -catalogue>=2.0.4,<2.1.0 +catalogue>=2.0.6,<2.1.0 typer>=0.3.0,<0.4.0 pathy>=0.3.5 # Third party dependencies diff --git a/setup.cfg b/setup.cfg index 1fa5b828d..06ab3ca40 100644 --- a/setup.cfg +++ b/setup.cfg @@ -48,7 +48,7 @@ install_requires = blis>=0.4.0,<0.8.0 wasabi>=0.8.1,<1.1.0 srsly>=2.4.1,<3.0.0 - catalogue>=2.0.4,<2.1.0 + catalogue>=2.0.6,<2.1.0 typer>=0.3.0,<0.4.0 pathy>=0.3.5 # Third-party dependencies diff --git a/spacy/cli/package.py b/spacy/cli/package.py index b6b993267..9350b58e4 100644 --- a/spacy/cli/package.py +++ b/spacy/cli/package.py @@ -206,6 +206,9 @@ def get_third_party_dependencies( for path, value in util.walk_dict(config): if path[-1].startswith("@"): # collect all function references by registry funcs[path[-1][1:]].add(value) + for component in config.get("components", {}).values(): + if "factory" in component: + funcs["factories"].add(component["factory"]) modules = set() for reg_name, func_names in funcs.items(): sub_registry = getattr(util.registry, reg_name) diff --git a/spacy/tests/test_cli.py b/spacy/tests/test_cli.py index 1841de317..e84159b64 100644 --- a/spacy/tests/test_cli.py +++ b/spacy/tests/test_cli.py @@ -539,4 +539,6 @@ def test_get_third_party_dependencies_runs(): # We can't easily test the detection of third-party packages here, but we # can at least make sure that the function and its importlib magic runs. nlp = Dutch() + # Test with component factory based on Cython module + nlp.add_pipe("tagger") assert get_third_party_dependencies(nlp.config) == []