Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate python code for schemas directly from Julia #1096

Merged
merged 19 commits into from
Feb 9, 2024

Conversation

deltamarnix
Copy link
Contributor

@deltamarnix deltamarnix commented Feb 7, 2024

Remove intermittent json generation and dependency on the data model code generator

Fixes #904
Fixes #1077
Fixes #887

@deltamarnix deltamarnix marked this pull request as draft February 7, 2024 15:34
@deltamarnix deltamarnix force-pushed the feat/generate-python-from-julia branch from 3407f62 to ce4b863 Compare February 8, 2024 11:57
@deltamarnix deltamarnix force-pushed the feat/generate-python-from-julia branch from ce4b863 to aebcbf0 Compare February 8, 2024 16:34
@deltamarnix deltamarnix marked this pull request as ready for review February 8, 2024 16:34
utils/gen_python.jl Outdated Show resolved Hide resolved
utils/templates/model.py.jinja Outdated Show resolved Hide resolved
python/ribasim/ribasim/schemas.py Outdated Show resolved Hide resolved
python/ribasim/tests/test_io.py Show resolved Hide resolved
Copy link
Member

@visr visr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good improvement, thanks!
The error message from #904 has gotten a lot better, pointing at the actual problem:

>>> import ribasim
>>> import pandas as pd
>>> ribasim.Terminal(static=pd.DataFrame(data={"no_id":[1]}))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Ribasim\.pixi\env\Lib\site-packages\pydantic\main.py", line 171, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
pydantic_core._pydantic_core.ValidationError: 1 validation error for Terminal
static.df
  Value error, column 'node_id' in DataFrameSchema {'node_id': <Schema Column(name=node_id, type=DataType(int64))>} requires a default value when non-nullable add_missing_columns is enabled [type=value_error, input_value=   no_id
0      1, input_type=DataFrame]
    For further information visit https://errors.pydantic.dev/2.6/v/value_error

Still I wonder how many users will understand "requires a default value when non-nullable add_missing_columns is enabled", instead of something simply stating that a required column is missing.

@Hofer-Julian Hofer-Julian merged commit 936ec87 into main Feb 9, 2024
21 checks passed
@Hofer-Julian Hofer-Julian deleted the feat/generate-python-from-julia branch February 9, 2024 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants