diff --git a/spacy/cli/debug_data.py b/spacy/cli/debug_data.py index f0e76be2b..c4d1069c0 100644 --- a/spacy/cli/debug_data.py +++ b/spacy/cli/debug_data.py @@ -97,7 +97,9 @@ def debug_data( with show_validation_error(config_path): cfg = util.load_config(config_path, overrides=config_overrides) nlp = util.load_model_from_config(cfg) - T = registry.resolve(nlp.config["training"], schema=ConfigSchemaTraining) + T = registry.resolve( + nlp.config.interpolate()["training"], schema=ConfigSchemaTraining + ) # Use original config here, not resolved version sourced_components = get_sourced_components(cfg) frozen_components = T["frozen_components"] diff --git a/spacy/cli/debug_model.py b/spacy/cli/debug_model.py index f8fc687fa..0b4db70b6 100644 --- a/spacy/cli/debug_model.py +++ b/spacy/cli/debug_model.py @@ -63,7 +63,9 @@ def debug_model_cli( set_gpu_allocator(allocator) with show_validation_error(config_path): nlp = util.load_model_from_config(raw_config) - T = registry.resolve(nlp.config["training"], schema=ConfigSchemaTraining) + T = registry.resolve( + nlp.config.interpolate()["training"], schema=ConfigSchemaTraining + ) seed = T["seed"] if seed is not None: msg.info(f"Fixing random seed: {seed}") diff --git a/spacy/tests/training/test_readers.py b/spacy/tests/training/test_readers.py index 7d94d5ddc..5c02aca36 100644 --- a/spacy/tests/training/test_readers.py +++ b/spacy/tests/training/test_readers.py @@ -42,7 +42,9 @@ def test_readers(): dot_names = ["training.train_corpus", "training.dev_corpus"] train_corpus, dev_corpus = resolve_dot_names(nlp.config, dot_names) assert isinstance(train_corpus, Callable) - T = registry.resolve(nlp.config["training"], schema=ConfigSchemaTraining) + T = registry.resolve( + nlp.config.interpolate()["training"], schema=ConfigSchemaTraining + ) optimizer = T["optimizer"] # simulate a training loop nlp.begin_training(lambda: train_corpus(nlp), sgd=optimizer) @@ -53,7 +55,8 @@ def test_readers(): # ensure the pipeline runs doc = nlp("Quick test") assert doc.cats - extra_corpus = registry.resolve(nlp.config["corpora"])["extra"] + corpora = {"corpora": nlp.config.interpolate()["corpora"]} + extra_corpus = registry.resolve(corpora)["corpora"]["extra"] assert isinstance(extra_corpus, Callable) @@ -91,7 +94,9 @@ def test_cat_readers(reader, additional_config): nlp = load_model_from_config(config, auto_fill=True) dot_names = ["training.train_corpus", "training.dev_corpus"] train_corpus, dev_corpus = resolve_dot_names(nlp.config, dot_names) - T = registry.resolve(nlp.config["training"], schema=ConfigSchemaTraining) + T = registry.resolve( + nlp.config["training"].interpolate(), schema=ConfigSchemaTraining + ) optimizer = T["optimizer"] # simulate a training loop nlp.begin_training(lambda: train_corpus(nlp), sgd=optimizer) diff --git a/spacy/training/pretrain.py b/spacy/training/pretrain.py index 1e0f055ee..e8dd9df30 100644 --- a/spacy/training/pretrain.py +++ b/spacy/training/pretrain.py @@ -33,8 +33,9 @@ def pretrain( if use_gpu >= 0 and allocator: set_gpu_allocator(allocator) nlp = load_model_from_config(config) - T = registry.resolve(nlp.config["training"], schema=ConfigSchemaTraining) - P = registry.resolve(nlp.config["pretraining"], schema=ConfigSchemaPretrain) + _config = nlp.config.interpolate() + T = registry.resolve(_config["training"], schema=ConfigSchemaTraining) + P = registry.resolve(_config["pretraining"], schema=ConfigSchemaPretrain) corpus = dot_to_object(T, P["corpus"]) batcher = P["batcher"] model = create_pretraining_model(nlp, P) diff --git a/spacy/util.py b/spacy/util.py index f9d9e6495..67c577927 100644 --- a/spacy/util.py +++ b/spacy/util.py @@ -413,7 +413,12 @@ def resolve_dot_names(config: Config, dot_names: List[Optional[str]]) -> Tuple[A section = ref.split(".")[0] # We want to avoid resolving the same thing twice if section not in resolved: - resolved[section] = registry.resolve(config[section]) + if registry.is_promise(config[section]): + # Otherwise we can't resolve [corpus] if it's a promise + result = registry.resolve({"config": config[section]})["config"] + else: + result = registry.resolve(config[section]) + resolved[section] = result try: objects.append(dot_to_object(resolved, ref)) except KeyError: