spraakbanken / karp-backend

Karp backend
MIT License
3 stars 2 forks source link

Pydantic model for resource config #248

Closed nick8325 closed 5 months ago

nick8325 commented 6 months ago

Currently, resource configs are just stored as a dict. This makes it kind of annoying to work with them (e.g., raw dictionary lookups everywhere like config["fields"][field_name]["type"], no IDE help for knowing which keys should exist). But also, if you forget a key in the resource config, you get pretty unhelpful error messages (some random function deep inside karp fails with a KeyError or similar).

Maybe we could make a Pydantic class for the resource config. That way we can validate the config, get better type information and also have helper methods for doing common tasks with the resource config.