-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return model predictions as dataclasses instead of pydantic models (#47)
The `Prediction` and `PredictionList` objects were made based on `pydantic`, anticipating this will make it easier to e.g. expose a model through an API using a framework such as FastAPI. However, this meant introducing `pydantic` into the core of the library in order to facilitate a feature that most users may not care about. On the other hand, FastAPI can deal with non-`pydantic` classes too (`pydantic` is only needed for some extras like validation). Thus, once we want to integrate the server code properly, we should do it in such a way that `pydantic` (and further dependencies like `fastapi`) remain optional extras rather than part of the core of the library. For now, in this PR I make the core prediction objects plain dataclasses, and drop `pydantic` from dependencies. This required a few changes (e.g. dropping special handling of prediction classes in `dictify`, using `default_factory` for the dict-valued fields), as well as fixing some of the tests, which did not provide all fields needed to construct the prediction objects (which for some reason is still accepted by `pydantic`).
- Loading branch information
Showing
6 changed files
with
32 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters