Skip to content

feat(dfns): declare dynamic keywords explicitly - #396

Merged
wpbonelli merged 4 commits into
MODFLOW-ORG:developfrom
wpbonelli:sim-nam-model-keys
Oct 21, 2026
Merged

wpbonelli merged 4 commits into
MODFLOW-ORG:developfrom
wpbonelli:sim-nam-model-keys

Conversation

@wpbonelli

Copy link
Copy Markdown
Member

Declare dynamic keywords (strings whose value is dictated by another field's value) explicitly rather than inferring them from fk. The primary/foreign key attributes indicate a relation between fields, not whether a dynamic value (i.e. a string field) acts as a keyword.

Add a dynamic attribute to the string field type:

  • requires tagged = false, fk, and no fk_ref
  • only a record's first field may be dynamic

The only usage right now is auxname in the array-based packages: gwf-rcha, gwf-evta, gwf-chdg, gwf-drng, gwf-ghbg, gwf-rivg, gwf-welg.

Also mark model-name pk/fk relations in SIM-NAM and UTL-HPC

Field Annotation
sim-nam.models.mname pk = true
sim-nam.exchanges.exgmnamea, exgmnameb fk = "models.mname"
sim-nam.solutiongroup.slnmnames fk = "models.mname"
utl-hpc.partitions.mname fk = "sim-nam.models.mname"

wpbonelli and others added 4 commits October 21, 2026 03:27
Mark sim-nam's models.mname as pk, and exchanges' exgmnamea/exgmnameb and
solutiongroup's slnmnames as fk "models.mname". MF6 rejects duplicate model
names and fails on an exchange or solution naming an unknown model.

slnmnames is a string array, so allow fk on string arrays, each entry a
key. An array's fk must now be a hierarchical path, as the spec already
said.

utl-hpc's partitions.mname is left unannotated for now: it leads its row,
so a hierarchical fk would make it a dynamic keyword.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A leading untagged String with a hierarchical fk was taken for a dynamic
keyword, making its list tagged. But fk only says what a value references,
not its role in the input grammar: utl-hpc's partitions rows begin with a
model name, a key into sim-nam's models, yet are an untagged table.

Add String.dynamic to declare a dynamic keyword. It requires tagged=False
and a hierarchical-path fk without fk_ref, and only a record's first field
may have it. A dynamic key's fk is now checked like any String's, so its
keywords may come from a list's pk as well as a string array.

Mark the array-based packages' auxname dynamic, and annotate utl-hpc's
partitions.mname with fk "sim-nam.models.mname" (MF6 rejects an undefined
model name there; not a pk, since a repeat isn't rejected).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A dynamic keyword's keywords must be known before its line is read, so its
fk can't use fk_ref, which resolves from a sibling later on that line. That
is the real constraint; also requiring a hierarchical path was a leftover of
inferring dynamic keys from the "." in fk. Drop it, so a bare block name
without fk_ref is accepted like any static fk.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The validator already accepts one, looking up the block's pk in the same
component, and dynamic keywords now rely on it. Say so in the spec instead
of requiring fk_ref.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wpbonelli wpbonelli added this to the 1.10.0 milestone Oct 21, 2026
@wpbonelli wpbonelli added the enhancement New feature or request label Oct 21, 2026
@wpbonelli
wpbonelli marked this pull request as ready for review October 21, 2026 15:46
@wpbonelli
wpbonelli merged commit b7c4356 into MODFLOW-ORG:develop Oct 21, 2026
15 checks passed
@wpbonelli
wpbonelli deleted the sim-nam-model-keys branch October 21, 2026 15:46
wpbonelli added a commit to modflowpy/pyphoenix-project that referenced this pull request Oct 21, 2026
Followup to #499, instead of declaring component references by hand, derive them from the DFNs. Uses MODFLOW-ORG/modflow-devtools#396. Some stuff here will be cleaned up soon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant