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

GEOLib output cannot be read in D-Stability #207

Open
Peter-van-Tol opened this issue Nov 29, 2024 · 0 comments
Open

GEOLib output cannot be read in D-Stability #207

Peter-van-Tol opened this issue Nov 29, 2024 · 0 comments

Comments

@Peter-van-Tol
Copy link
Contributor

Trying to duplicate a stage in a calculation, which leads to an unreadable file in D-Stability. The error in this case are the waternetcreatorsettings. The created file is:

{
    "AdjustForUplift": false,
    "AquiferInsideAquitardLayerId": null,
    "AquiferLayerId": null,
    "AquiferLayerInsideAquitardLeakageLengthInwards": null,
    "AquiferLayerInsideAquitardLeakageLengthOutwards": null,
    "AquitardHeadLandSide": null,
    "AquitardHeadWaterSide": null,
    "ContentVersion": "2",
    "DitchCharacteristics": {
        "DitchBottomEmbankmentSide": "NaN",
        "DitchBottomLandSide": "NaN",
        "DitchEmbankmentSide": "NaN",
        "DitchLandSide": "NaN"
    },
    "DrainageConstruction": {
        "X": "NaN",
        "Z": "NaN"
...
    "WaterLevelHinterland": null
}

While it should be:

{
    "AdjustForUplift": false,
    "AquiferInsideAquitardLayerId": null,
    "AquiferLayerId": null,
    "AquiferLayerInsideAquitardLeakageLengthInwards": NaN,
    "AquiferLayerInsideAquitardLeakageLengthOutwards": NaN,
    "AquitardHeadLandSide": NaN,
    "AquitardHeadWaterSide": NaN,
    "ContentVersion": "2",
    "DitchCharacteristics": {
        "DitchBottomEmbankmentSide": "NaN",
        "DitchBottomLandSide": "NaN",
        "DitchEmbankmentSide": "NaN",
        "DitchLandSide": "NaN"
    },
    "DrainageConstruction": {
        "X": "NaN",
        "Z": "NaN"
...
    "WaterLevelHinterland": NaN
}

This error occurs when using GEOLib with pydantic version 2.8, The error is due to this issue: pydantic/pydantic#10037

Because D-Stability cannot read None values, it is recommends to add ser_json_inf_nan='constants' to BaseDataClass. This will keep the constants such as "NaN" in the files, ensuring it can be read by D-Stability. The complete settings in the BaseDataClass will thus become:

class BaseDataClass(BaseModel):
    """Base class for *all* pydantic classes in GEOLib."""

    model_config = ConfigDict(
        validate_assignment=True,
        arbitrary_types_allowed=True,
        validate_default=True,
        ser_json_inf_nan='constants',
        extra=settings.extra_fields,
    )
This was referenced Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant