-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Setup Information
- ravenpy version: 0.16.1
- Python version: Any
- Operating System: openSUSE Tumbleweed x86_64
Description
This problem occurs when exposing the Emulator models in the generated documentation. The issue appears to be brought on because the ListCommand class can't serialize what root is when generating the documentation:
lass ListCommand(RootModel, _Command):
"""Use so that commands with __root__: Sequence[Command] behave like a list."""
root: Sequence[Any]
def __iter__(self):
return iter(self.root)
def __getitem__(self, item):
return self.root[item]
def __len__(self):
return len(self.root)
model_config = ConfigDict(arbitrary_types_allowed=True, populate_by_name=True)This means that any emulated models built using it are raising errors when trying to parse the documentation. I'm not familiar enough with pydantic to understand how to fix this, so I'm removing them from the docs to see if that fixes things.
The warnings summary:
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.commands.SeasonalRelativeHeight' because the following pydantic fields can't be serialized properly: ['root'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.commands.SeasonalRelativeLAI' because the following pydantic fields can't be serialized properly: ['root'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.rvs.Config' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.rvs.RVP' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.BasicRoute' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.Blended' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.CanadianShield' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.GR4JCN' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.HBVEC' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.HMETS' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.HYPR' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.Mohyse' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.SACSMA' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.blended.Blended' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.canadianshield.CanadianShield' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.gr4jcn.GR4JCN' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.hbvec.HBVEC' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.hmets.HMETS' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.hypr.HYPR' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.mohyse.Mohyse' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.routing.BasicRoute' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
/home/tjs/git/RavenPy/docs/autodoc_pydantic.rst: WARNING: JSON schema can't be generated for 'ravenpy.config.emulators.sacsma.SACSMA' because the following pydantic fields can't be serialized properly: ['seasonal_relative_lai', 'seasonal_relative_height'].
Steps To Reproduce
- Install
autodoc-pydantic; - Enable the
sphinxcontrib-autodoc-pydanticextension indocs/conf.py; - Add the imported models found in
src/ravenpy/config/emulators/__init__.pyto the__all__listing; - Run
$ make docs.
Additional context
It could be the case that the magic methods for the underlying classes aren't written to support the data they might be initialized with (Sequence[Any] could be a lot of things)? I'm not sure.
Relevant resources:
- JSON Schema generation for custom-serialized types pydantic/pydantic#7510
- https://stackoverflow.com/questions/78550600/how-to-fix-pydantic-default-value-is-not-json-serializable-warning-when-using
Contribution
- I would be willing/able to open a Pull Request to address this bug.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working