Skip to content

Comments

feat(dfns): improve DFNs API#271

Draft
wpbonelli wants to merge 30 commits intoMODFLOW-ORG:developfrom
wpbonelli:dfn
Draft

feat(dfns): improve DFNs API#271
wpbonelli wants to merge 30 commits intoMODFLOW-ORG:developfrom
wpbonelli:dfn

Conversation

@wpbonelli
Copy link
Member

@wpbonelli wpbonelli commented Jan 20, 2026

breaking rewrite on hold for v2 preview available in experimental dfns module. to be released, and old dfn module removed, in v2

wpbonelli and others added 28 commits February 23, 2026 07:42
much in the same way that we structured dfns internally (flat to tree), this organizes the components into a tree which represents valid mf6 simulation structure. tentative, may be subject to change
In the new TOML definition file format, define period block variables (arrays) in terms of the grid and time discretization shape, rather than in the sparse/list-based input form with shape maxbound, the latter being an MF6 input file format detail. Towards structure-scoped TOML definition files i.e. connections/contents of simulation components, whereas normal DFN files are also about input formatting.

Dimension info previously encoded in iper and cellid is now signified as with other arrays with shape = "(nper, nnodes)". These variables and the intermediate recarray variable are dropped, as they specified formatting details more than intrinsically necessary information about the data model.

Also, unrelatedly

- use key "children" for composite Field children, previously "items", "choices", "fields" were used for list, union, record respectively
- promote some utility functions to public naming (no leading underscore)
- add a few block-related aliases and utilities
Get a flat dict of top-level fields. Convenient when you don't need to care about block structure.
The foreign key system was to support flopy3's concept of "subpackage" but that should be a flopy concern rather than of the specification, though this leaves the Ref typed dict for now
generalize the column separation in MODFLOW-ORG#229 from period block recarrays to all recarrays. deal only with arrays in the v2 schema.
…-ORG#235)

multi attribute generalizes concept of multi-package to any component whose parent can have not just one but multiple
…RG#236)

This variable is accessed externally (here), which means it should be a public variable, not private.

Keep a private _SCALAR_TYPES copy for now.
Up to now we conflated the format of definition files (DFN vs TOML) with the data schema we expect their contents to follow. Separate these concerns. Add a schema conversion layer for v1 -> v2 transformations. Refactoring/usability-wise, make Dfn a dataclass instead of a frankenstein typed dict. Miscellaneous other tidying. And drop the renaming of simulation and model components without "-nam". We can do that later, for now stay consistent.
…-ORG#240)

Any changes like this should happen in the v1 -> v2 schema map instead of in the DFN parser
Allows using Dfn/Field spec objects explicitly by passing a dictionary to __init__ via double star syntax, or via from_dict which handles field structuring automatically, and with strict=False ignores unrecognized keys (like pydantic's extra="ignore"), if strict=True unrecognized keys cause an error (like pydantic's extra="forbid")
…ORG#244)

and move v1 FieldType and Reader to the v1 schema module where they belong
…DFLOW-ORG#257)

* rename validate -> is_valid and move to dfn module
* trigger ci
* fix field type conversion, add tests
* tests for hairier parts of conversion
recarray -> list, keystring -> union
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

Successfully merging this pull request may close these issues.

3 participants