feat(dfns): improve DFNs API#271
Draft
wpbonelli wants to merge 30 commits intoMODFLOW-ORG:developfrom
Draft
Conversation
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
…RG#249) longname is already an attribute on the base field
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
breaking rewrite
on hold for v2preview available in experimentaldfnsmodule. to be released, and olddfnmodule removed, in v2