Skip to content

Commit

Permalink
Do not attempt to represent models due to non-serializable errors (#438)
Browse files Browse the repository at this point in the history
### What kind of change does this PR introduce?

* Removes the `pydantic`-defined models from the public API of
`emulators`.

### Does this PR introduce a breaking change?

No. Usage still works, but documentation should be different.

### Other information:

The issue appears to be brought on because the `ListCommand` class can't
serialize what `root` is when generating the documentation:

```python
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.
  • Loading branch information
Zeitsperre authored Jan 15, 2025
2 parents 6bc470a + 3b9dde4 commit df2ffed
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/ravenpy/config/emulators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,18 @@
from ravenpy.config.emulators.sacsma import SACSMA

__all__ = [
"GR4JCN",
"HBVEC",
"HMETS",
"HYPR",
"SACSMA",
"BasicRoute",
"Blended",
"CanadianShield",
"Mohyse",
"get_model",
]


def get_model(name):
"""Return the corresponding Raven emulator configuration class.
"""
Return the corresponding Raven emulator configuration class.
Parameters
----------
name : str
Model class name or model identifier.
Model class name or model identifier.
Returns
-------
Expand Down

0 comments on commit df2ffed

Please sign in to comment.