Skip to content

model_type parameters are serialized but can be important defaults #41

Open

Description

@benjaminleighton

In the output branch

classes like

class Cf(BedFriction):
    """Dimensionless friction coefficient formulation.

    Uses a constant dimensionless friction coefficient (c_f) to calculate
    bed shear stress. XBeach default bedfriccoef: 0.003 (range: 0.001-0.1).

    """

    model_type: Literal["cf"] = Field(
        default="cf",
        description="Model type discriminator",
    )

define a model_type that should be serialized as bedfriction = cf

I think this might be because exclude_unset is True in model_dump which causes this information to be dropped prior to it being available for flatten_nested_dict to dump correctly. AI suggested a number of fixes including patching flatten_nested_dict to reconstruct the model_type field or to turn off exclude_unset and use exclude_node in model_dump. I'm not confident enough with the implementation to put a pull request in at the moment. Seeking advice @rafa-guedes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions