Replies: 4 comments 5 replies
-
The format above has been implemented in devtools:
I'm presently working it into modflowpy/flopy#2333. I'm having second thoughts about the "implicit" nesting. Looking elsewhere for precedent, the convention in pyproject.toml files is to name collections explicitly. E.g. E.g. It seems better to have a fixed top-level schema with a Explicitness also seems preferable in toml in general because nested structures are not obvious to the eye, as they would be in yaml or json. Issue 781 on the toml repo is an interesting discussion of toml's approach to nested data. |
Beta Was this translation helpful? Give feedback.
-
@deltamarnix we recently had a chat on how to represent subpackages where we arrived at the following:
I thought about this some more. An MF6 simulation is a tree. Likewise the MF6 input specification is a tree too. A simulation is a "materialization" of some subset of the specification. Most components must have one particular parent, e.g. tdis must be attached to the simulation, npf to a gwf model. Some components may relax this requirement (to a set of potential parents, or a set of parent types) or remove it entirely. These are what we have been calling "subpackages". We might consider making the tree explicit, instead of inferring it from the DFN names? Components might have a top-level And it generalizes the concept of "subpackage". Flopy could treat anything with one particular parent as normal, binding by path as specified in the parent's namefile, and for anything with no specified (or multiple) parent(s), it could do what it does for subpackages currently, bind by init parameter (i.e. swap it into the consuming class for the identifying "foreign key" filepath variable). |
Beta Was this translation helpful? Give feedback.
-
Consider changing the |
Beta Was this translation helpful? Give feedback.
-
Consider distinguishing abstract vs concrete DFNs? Currently namefile definitions contain record representations of their abstract subcomponents, e.g. Binding is a problem that MF6 and flopy solve independently. The abstract relationship is what matters — a simulation "has" a model which "has" a package — how to express that most easily depends whether one is writing input files by hand or using python/flopy. It seems like a code-generation concern how to "interpret" DFNs for a given program. DFNs could abstractly represent the input spec, with mf6 and flopy tooling parsing that into the appropriate paradigms. E.g. flopy's object-oriented interface, where the user might not know the ASCII input files expected until they call |
Beta Was this translation helpful? Give feedback.
-
We have arrived at TOML as the target format for definition files. TOML is visually similar to existing definition files, while allowing a structured representation of the block/variable tree.
As @deltamarnix has suggested DFN files should be versioned. We can consider legacy DFNs version 1. The TOML format can be 2(.0.0), then whenever we make a change to the format (e.g. adding/removing an attribute) we bump the version number, so consumers can explicitly decide whether they support a given DFN file without having to try and parse it all.
After chatting on an initial draft in modflowpy/flopy#2333 (comment) it sounds like we want blocks at the top level, rather than variables, and to omit explicit child attributes in favor of attaching children directly to the parent. So the example would become
Period block specifications could look like
This has not been implemented yet in the referenced PR or here. It could maybe be prototyped here, moved to flopy3 when ready, and then moved to devtools once we're confident in it.
Beta Was this translation helpful? Give feedback.
All reactions