explosion / explosion/spaCy

Pipeline component `ConfigValidationError` regression in `3.8.13`

Open
#13,944 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Python
Stars
33.9k
Forks
4.7k
Avg merge
3m
Merged PRs (30d)
1

Description

## How to reproduce the behaviour

I got a component that worked on `3.8.11` but raised `ConfigValidationError` now
```python
from pathlib import Path

import spacy
from spacy.lang.en import English
from spacy.language import Language
from spacy.tokens import Doc
from thinc.api import Config


class MyComponent:
def __init__(self, nlp, name, path_: Path, set_: set[str]) -> None:
self.path_= path_
self.set_ = set_

def __call__(self, doc: Doc) -> Doc:
...

@Language.factory(
"my_component",
default_config={"path_": "./model", "set_": set(["a", "b"])},
)
def create_path_component(nlp, name, path_: Path, set_: set[str]) -> MyComponent:
return MyComponent(nlp=nlp, name=name, path_=path_, set_=set_)

CONFIG = """
[nlp]
lang = "en"
pipeline = ["my_component"]

[components]

[components.my_component]
factory = "my_component"
path_ = "./model
set_ = ["a", "b"]
"""

cfg = Config().from_str(CONFIG)
nlp = English.from_config(cfg)

component = nlp.get_pipe("my_component")
print("component.path_ is Path:", isinstance(component.path_, Path))
print("component.set_ is set:", isinstance(component.set_, set))
```

`3.8.11` this worked OK, but now I got
```python
---------------------------------------------------------------------------
ConfigValidationError Traceback (most recent call last)
[/tmp/ipykernel_21433/1043605428.py](https://localhost:8080/#) in ()
37
38 cfg = Config().from_str(CONFIG)
---> 39 nlp = English.from_config(cfg)
40
41 component = nlp.get_pipe("my_component")

8 frames
[/usr/local/lib/python3.12/dist-packages/confection/_registry.py](https://localhost:8080/#) in _validate_promise_args(filled, schema, func_name, parent)
343 )
344 if errors:
--> 345 raise ConfigValidationError(
346 config=filled,
347 errors=errors,

ConfigValidationError:

Config error for 'my_component'
my_component -> set_ at root: ['a', 'b'] is not set[str]
{'nlp': , 'name': 'my_component', 'path_': '"./model', 'set_': ['a', 'b'], '@factories': 'my_component'}
```

## Your Environment

- **spaCy version:** 3.8.13
- **Platform:** Linux-6.6.113+-x86_64-with-glibc2.35
- **Python version:** 3.12.13
- **Pipelines:** en_core_web_sm (3.8.0)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.