You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/md/dfns.md
+50-31Lines changed: 50 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
MODFLOW 6 specifies input components and their variables in configuration files with a custom format. Such files are called definition (DFN) files and conventionally have suffix `.dfn`.
4
4
5
-
The `modflow_devtools.dfns` module provides a structured API for working with MODFLOW 6 input specifications, including typed Python objects representing each component and field type, tools for acquiring, loading and managing specification versions, and a utility to convert `.dfn` files to a revised v2 schema and standard file formats.
5
+
The `modflow_devtools.dfns` module provides a structured API for working with MODFLOW 6 input specifications, including typed Python objects representing each component and field type, tools for acquiring, loading and managing specification versions, and a utility to convert `.dfn` files to a revised schema and standard file formats.
6
6
7
7
The `modflow_devtools.dfn` module provides a limited subset of the same functionality, but is now deprecated. This module will be removed with `modflow-devtools` version 2.x. The `modflow_devtools.dfns` module should in most cases be used instead, however it remains experimental and may change without notice until version 2.x.
The migration tool may be used on directories or individual files.
52
56
53
-
Supported schema versions are currently "1.1", "1.2", and "2". Note that schema version 2 is under active development, and may change without warning. Versions 1.1 and 1.2 were early prototypes.
57
+
Supported schema versions are currently `"2.0.0.dev0"`, `"2.0.0.dev1"`, and `"2.0.0.dev2"` (`CURRENT_SCHEMA_VERSION`). Note that `2.0.0.dev2` is under active development and may change without warning.
54
58
55
59
The default serialization format is YAML. Use `--format` / `-f` to select `yaml` (default), `toml`, or `json`.
56
60
57
-
####Configuration
61
+
### Configuration
58
62
59
63
The `modflow-devtools` package ships with a built-in configuration specifying default DFN release versions to support:
60
64
@@ -74,7 +78,7 @@ You can extend or override the default registry configuration by creating an ove
74
78
75
79
Entries in this file are merged with (and take precedence over) the defaults. The file uses the same format as the bundled configuration file. For instance, to point to DFN releases on your own fork, substitute your GitHub username for "MODFLOW-ORG".
76
80
77
-
#### Caching
81
+
###Cache layout
78
82
79
83
DFN file sets are cached under:
80
84
@@ -95,29 +99,42 @@ The cache is organized by repository and release tag:
95
99
└── ...
96
100
```
97
101
98
-
###Python API
102
+
## Python API
99
103
100
-
#### Downloading DFNs
104
+
###Schema version
101
105
102
-
```python
103
-
from modflow_devtools.dfns import fetch_dfns
106
+
The current schema version is exposed as a constant:
**Note**: Calling `Dfns.load()` on a directory of `.dfn` files will convert to the v2 schema automatically.
135
-
136
151
Each entry in `spec.components` is one of three component types, discriminated by a `type` field:
137
152
138
153
-`Simulation` — the root component (`sim-nam`)
@@ -185,15 +200,15 @@ See [DFN specification](dfnspec.md) for full attribute documentation.
185
200
186
201
### Managing DFNs
187
202
188
-
A registry system handles caching and accessing DFN files from MODFLOW 6 releases.
203
+
A registry system handles caching and accessing DFN files from MODFLOW 6 releases.`DfnRegistry` is the abstract base class; `LocalDfnRegistry` and `RemoteDfnRegistry` are the two concrete implementations.
189
204
190
205
For working with DFN files on the local filesystem, there is `LocalDfnRegistry`.
191
206
192
207
```python
193
208
from modflow_devtools.dfns import LocalDfnRegistry
tag = registry.latest_tag() # resolve "latest" to actual tag
212
227
tag = registry.cached_tag() # return cached tag
213
228
```
214
229
215
-
The `release_id` takes the form `"owner/repo@tag"`, where `tag` may be a specific version or "latest".
230
+
The `release_id` takes the form `"owner/repo@tag"`, where `tag` may be a specific version or `"latest"`.
216
231
217
232
For `@latest`, `latest_tag()` queries the GitHub API once and caches the result.
218
233
@@ -237,12 +252,16 @@ To get the base cache path programmatically:
237
252
RemoteDfnRegistry.base_cache_path()
238
253
```
239
254
240
-
To check the cache contents:
255
+
To check whether a release is cached:
241
256
242
257
```python
243
258
from modflow_devtools.dfns.registry import is_cached
244
259
245
260
is_cached("MODFLOW-ORG/modflow6@6.6.0")
246
261
```
247
262
248
-
When `MODFLOW_DEVTOOLS_AUTO_SYNC=1` is set, `RemoteDfnRegistry.from_ids()` will automatically call `sync()` for any release ID that has no cached files yet.
263
+
### Environment variables
264
+
265
+
| Variable | Values | Effect |
266
+
|---|---|---|
267
+
|`MODFLOW_DEVTOOLS_AUTO_SYNC`|`1`, `true`, `yes`|`RemoteDfnRegistry.from_ids()` automatically calls `sync()` for any release ID with no cached files yet. |
0 commit comments