diff --git a/spacy/tests/serialize/test_serialize_config.py b/spacy/tests/serialize/test_serialize_config.py index d305d7719..05246c3f3 100644 --- a/spacy/tests/serialize/test_serialize_config.py +++ b/spacy/tests/serialize/test_serialize_config.py @@ -10,6 +10,7 @@ from spacy.language import Language from spacy.ml.models import MaxoutWindowEncoder, MultiHashEmbed from spacy.ml.models import build_tb_parser_model, build_Tok2Vec_model from spacy.schemas import ConfigSchema, ConfigSchemaPretrain +from spacy.training import Example from spacy.util import load_config, load_config_from_str from spacy.util import load_model_from_config, registry @@ -434,6 +435,11 @@ def test_config_overrides_registered_functions(): nlp_re1.config["components"]["attribute_ruler"]["scorer"]["@scorers"] == "spacy.tagger_scorer.v1" ) + + @registry.misc("test_some_other_key") + def misc_some_other_key(): + return "some_other_key" + nlp_re2 = spacy.load( d, config={ @@ -441,7 +447,7 @@ def test_config_overrides_registered_functions(): "attribute_ruler": { "scorer": { "@scorers": "spacy.overlapping_labeled_spans_scorer.v1", - "spans_key": "some_other_key", + "spans_key": {"@misc": "test_spans_key_value"}, } } } @@ -449,8 +455,14 @@ def test_config_overrides_registered_functions(): ) assert ( nlp_re2.config["components"]["attribute_ruler"]["scorer"]["spans_key"] - == "some_other_key" + == {"@misc": "test_some_other_key"} ) + # run dummy evaluation (will return None scores) in order to test that + # the spans_key value in the nested override is working as intended in + # the config + example = Example.from_dict(nlp_re2.make_doc("a b c"), {}) + scores = nlp_re2.evaluate([example]) + assert "spans_some_other_key_f" in scores def test_config_interpolation():