Skip to content

Commit b3e1f74

Browse files
authored
Merge pull request #306 from MODFLOW-ORG/v1.9.2
Release 1.9.2
2 parents 186bc5c + 5588814 commit b3e1f74

9 files changed

Lines changed: 43 additions & 29 deletions

File tree

HISTORY.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
### Version 1.9.2
2+
3+
#### Bug fixes
4+
5+
* [fix(dfns)](https://github.com/MODFLOW-ORG/modflow-devtools/commit/4e8ff9993045b7a4a291f50fb2167d79fce1bd46): Add tagged attribute to field schema (#304). Committed by wpbonelli on 2026-03-09.
6+
* [fix(dfns)](https://github.com/MODFLOW-ORG/modflow-devtools/commit/5ff8d7f17ecbc8ee0c8ddc16b020f7f992b6e69b): Remove fkeys/ref; add DfnSpec.dump/s() (#305). Committed by wpbonelli on 2026-04-20.
7+
18
### Version 1.9.1
29

310
#### Bug fixes

autotest/test_dfns.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ def test_fieldv1_to_fieldv2_conversion():
422422
assert save_flows.type == "keyword"
423423
assert save_flows.block == "options"
424424
assert save_flows.description == "save calculated flows"
425-
assert not hasattr(save_flows, "tagged")
425+
assert hasattr(save_flows, "tagged")
426426
assert not hasattr(save_flows, "in_record")
427427
assert not hasattr(save_flows, "reader")
428428

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
project = "modflow-devtools"
1010
author = "MODFLOW Team"
11-
release = "1.9.1"
11+
release = "1.9.2"
1212

1313
# -- General configuration ---------------------------------------------------
1414
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration

modflow_devtools/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
__author__ = "Joseph D. Hughes"
2-
__date__ = "Mar 05, 2026"
3-
__version__ = "1.9.1"
2+
__date__ = "Apr 20, 2026"
3+
__version__ = "1.9.2"
44
__maintainer__ = "Joseph D. Hughes"
55
__email__ = "jdhughes@usgs.gov"
66
__status__ = "Production"

modflow_devtools/dfns/__init__.py

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
)
3030
from modflow_devtools.dfns.schema.block import Block, Blocks, block_sort_key
3131
from modflow_devtools.dfns.schema.field import Field, Fields
32-
from modflow_devtools.dfns.schema.ref import Ref
3332
from modflow_devtools.dfns.schema.v1 import SCALAR_TYPES as V1_SCALAR_TYPES
3433
from modflow_devtools.dfns.schema.v1 import FieldV1
3534
from modflow_devtools.dfns.schema.v2 import FieldV2
@@ -61,7 +60,6 @@
6160
"FieldV2",
6261
"Fields",
6362
"LocalDfnRegistry",
64-
"Ref",
6563
"RemoteDfnRegistry",
6664
"block_sort_key",
6765
"get_dfn",
@@ -106,9 +104,6 @@ class Dfn:
106104
Whether this is a multi-package.
107105
ftype : str | None
108106
File type identifier.
109-
ref : Ref | None
110-
Metadata if this component is a subpackage (child's perspective).
111-
Populated from DFN comments like: # flopy subpackage <key> <abbr> <param> <val>
112107
blocks : Blocks | None
113108
Block definitions containing field specifications.
114109
children : Dfns | None
@@ -125,7 +120,6 @@ class Dfn:
125120
advanced: bool = False
126121
multi: bool = False
127122
ftype: str | None = None
128-
ref: Ref | None = None
129123
blocks: Blocks | None = None
130124
children: Dfns | None = None
131125
subcomponents: list[str] | None = None
@@ -258,6 +252,23 @@ def __contains__(self, name: object) -> bool:
258252
"""Check if a component exists by name."""
259253
return name in self._flat
260254

255+
def dump(self, f) -> None:
256+
"""Serialize the full spec to a TOML byte stream."""
257+
import tomli_w
258+
259+
doc = {"schema_version": str(self.schema_version)}
260+
for name, dfn in self._flat.items():
261+
doc[name] = _toml_safe(remap(asdict(dfn), visit=drop_none_or_empty))
262+
f.write(tomli_w.dumps(doc).encode())
263+
264+
def dumps(self) -> str:
265+
"""Serialize the full spec to a TOML string."""
266+
import io
267+
268+
buf = io.BytesIO()
269+
self.dump(buf)
270+
return buf.getvalue().decode()
271+
261272
@classmethod
262273
def load(
263274
cls,
@@ -563,13 +574,23 @@ def map(self, dfn: Dfn) -> Dfn:
563574
advanced=dfn.advanced,
564575
multi=dfn.multi,
565576
ftype=dfn.ftype or (dfn.name.split("-", 1)[1].upper() if "-" in dfn.name else None),
566-
ref=dfn.ref,
567577
blocks=MapV1To2.map_blocks(dfn),
568578
schema_version=v2,
569579
parent=dfn.parent,
570580
)
571581

572582

583+
def _toml_safe(obj):
584+
"""Recursively coerce non-TOML-native types to str."""
585+
if isinstance(obj, dict):
586+
return {k: _toml_safe(v) for k, v in obj.items()}
587+
if isinstance(obj, list):
588+
return [_toml_safe(v) for v in obj]
589+
if isinstance(obj, (str, int, float, bool)) or obj is None:
590+
return obj
591+
return str(obj)
592+
593+
573594
def map(
574595
dfn: Dfn,
575596
schema_version: str | Version = "2",
@@ -618,7 +639,6 @@ def load(f, format: str = "dfn", **kwargs) -> Dfn:
618639
"multi": data.pop("multi", False),
619640
"ftype": data.pop("ftype", None)
620641
or (dfn_name.split("-", 1)[1].upper() if dfn_name and "-" in dfn_name else None),
621-
"ref": data.pop("ref", None),
622642
}
623643

624644
if (expected_name := kwargs.pop("name", None)) is not None:

modflow_devtools/dfns/parse.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,16 @@ def parse_mf6_subpackages(meta: list[str]) -> list[str]:
101101
Returns
102102
-------
103103
list[str]
104-
List of uppercase component abbreviations (e.g., ['UTL-NCF']).
104+
List of lowercase component abbreviations (e.g., ['utl-ncf']).
105105
106106
See Also
107107
--------
108108
Dfn.subcomponents : Stores the result (schema-level constraint).
109-
Dfn.fkeys : Field-level foreign keys from flopy subpackage declarations.
110109
"""
111110
result = []
112111
for m in meta:
113112
if m.startswith("mf6-subpackage "):
114-
abbr = m.removeprefix("mf6-subpackage ").strip().upper()
113+
abbr = m.removeprefix("mf6-subpackage ").strip().lower()
115114
result.append(abbr)
116115
return result
117116

modflow_devtools/dfns/schema/field.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ class Field:
1919
shape: str | None = None
2020
valid: tuple[str, ...] | None = None
2121
netcdf: bool = False
22+
tagged: bool = False

modflow_devtools/dfns/schema/ref.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.9.1
1+
1.9.2

0 commit comments

Comments
 (0)