Skip to content

Commit 9d5b2df

Browse files
authored
docs(models): improve models docs, rename script param (#218)
1 parent 75e6136 commit 9d5b2df

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

docs/md/models.md

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ All `ModelRegistry` subclasses expose the following properties:
1414
- `models`: a map of model names to model input files
1515
- `examples`: a map of example scenarios to models
1616

17-
An *example* is a set of models which run in a particular order.
17+
An *example* is a set of related models which run in a particular order.
1818

1919
Dictionary keys are consistently strings. Dictionary values may vary depending on the type of registry. For instance, values in `PoochRegistry.files` are dictionaries including a hash and url.
2020

@@ -69,15 +69,13 @@ The remaining parts may reflect the relative location of the model within the so
6969
To copy model input files to a workspace of your choosing, call `copy_to` on the registry.
7070

7171
```python
72-
7372
from tempfile import TemporaryDirectory
73+
from modflow_devtools.models import copy_to
7474

7575
with TemporaryDirectory() as td:
7676
workspace = DEFAULT_REGISTRY.copy_to(td, "example/ex-gwe-ates", verbose=True)
77-
# the module provides a shortcut for this too
78-
# from modflow_devtools.models import copy_to
79-
# workspace = copy_to(td, "example/ex-gwe-ates", verbose=True)
80-
77+
# or, the module provides a shortcut for this too
78+
workspace = copy_to(td, "example/ex-gwe-ates", verbose=True)
8179
```
8280

8381
If the target directory doesn't exist, it will be created.
@@ -95,8 +93,6 @@ registry = LocalRegistry()
9593
registry.index("path/to/models", namefile_pattern="*.nam")
9694
```
9795

98-
The registry may then be used
99-
10096
### Pooch registry
10197

10298
The `make_registry.py` script is responsible for generating a registry text file and a mapping between files and models.
@@ -107,14 +103,16 @@ The script can be executed with `python -m modflow_devtools.make_registry`. It a
107103

108104
- `--append` or `-a`: If specified, the script will append to the existing registry file instead of overwriting it.
109105
- `--url` or `-u`: Specifies the base URL for the registry file. If not provided, the default base URL is used.
106+
- `--model-name-prefix`: Optionally specify a string to prepend to model names. Useful for avoiding collisions.
107+
- `--namefile`: Optionally specify the glob pattern for namefiles. By default, only `mfsim.nam` (MF6) are found.
110108

111109
For example, to create a registry of models in the MF6 examples and test models repositories, assuming each is checked out next to this project:
112110

113111
```shell
114-
python -m modflow_devtools.make_registry ../modflow6-examples/examples --url https://github.com/MODFLOW-ORG/modflow6-examples/releases/download/current/mf6examples.zip --prefix mf6/example
115-
python -m modflow_devtools.make_registry ../modflow6-testmodels/mf6 --append --url https://github.com/MODFLOW-ORG/modflow6-testmodels/raw/master/mf6 --prefix mf6/test
116-
python -m modflow_devtools.make_registry ../modflow6-largetestmodels --append --url https://github.com/MODFLOW-ORG/modflow6-largetestmodels/raw/master --prefix mf6/large
117-
python -m modflow_devtools.make_registry ../modflow6-testmodels/mf5to6 --append --url https://github.com/MODFLOW-ORG/modflow6-testmodels/raw/master/mf5to6 --prefix mf2005 --namefile "*.nam"
112+
python -m modflow_devtools.make_registry ../modflow6-examples/examples --url https://github.com/MODFLOW-ORG/modflow6-examples/releases/download/current/mf6examples.zip --model-name-prefix mf6/example
113+
python -m modflow_devtools.make_registry ../modflow6-testmodels/mf6 --append --url https://github.com/MODFLOW-ORG/modflow6-testmodels/raw/master/mf6 --model-name-prefix mf6/test
114+
python -m modflow_devtools.make_registry ../modflow6-largetestmodels --append --url https://github.com/MODFLOW-ORG/modflow6-largetestmodels/raw/master --model-name-prefix mf6/large
115+
python -m modflow_devtools.make_registry ../modflow6-testmodels/mf5to6 --append --url https://github.com/MODFLOW-ORG/modflow6-testmodels/raw/master/mf5to6 --model-name-prefix mf2005 --namefile "*.nam"
118116
```
119117

120118
Above we adopt a convention of prefixing model names with the model type (i.e. the program used to run it), e.g. "mf6/" or "mf2005/". Relative path parts below the initial prefix reflect the model's relative path within its repository.

modflow_devtools/make_registry.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@
1212
help="Append instead of overwriting.",
1313
)
1414
parser.add_argument(
15-
"--prefix", "-p", type=str, help="Prefix for models.", default=""
15+
"--model-name-prefix",
16+
"-p",
17+
type=str,
18+
help="Prefix for model names.",
19+
default="",
1620
)
1721
parser.add_argument(
1822
"--url",

0 commit comments

Comments
 (0)