|
1 | 1 | import argparse |
| 2 | +from pathlib import Path |
2 | 3 |
|
3 | 4 | import modflow_devtools.models as models |
4 | 5 |
|
| 6 | +_REPOS_PATH = Path(__file__).parents[2] |
| 7 | +_DEFAULT_REGISTRY_OPTIONS = [ |
| 8 | + { |
| 9 | + "path": _REPOS_PATH / "modflow6-examples" / "examples", |
| 10 | + "url": "https://github.com/MODFLOW-ORG/modflow6-examples/releases/download/current/mf6examples.zip", |
| 11 | + "model-name-prefix": "mf6/example", |
| 12 | + }, |
| 13 | + { |
| 14 | + "path": _REPOS_PATH / "modflow6-testmodels" / "mf6", |
| 15 | + "url": "https://github.com/MODFLOW-ORG/modflow6-testmodels/raw/master/mf6", |
| 16 | + "model-name-prefix": "mf6/test", |
| 17 | + }, |
| 18 | + { |
| 19 | + "path": _REPOS_PATH / "modflow6-largetestmodels", |
| 20 | + "url": "https://github.com/MODFLOW-ORG/modflow6-largetestmodels/raw/master", |
| 21 | + "model-name-prefix": "mf6/large", |
| 22 | + }, |
| 23 | + { |
| 24 | + "path": _REPOS_PATH / "modflow6-testmodels" / "mf5to6", |
| 25 | + "url": "https://github.com/MODFLOW-ORG/modflow6-testmodels/raw/master/mf5to6", |
| 26 | + "model-name-prefix": "mf2005", |
| 27 | + "namefile": "*.nam", |
| 28 | + }, |
| 29 | +] |
| 30 | + |
| 31 | + |
5 | 32 | if __name__ == "__main__": |
6 | 33 | parser = argparse.ArgumentParser(description="Make a registry of models.") |
7 | | - parser.add_argument("path") |
8 | 34 | parser.add_argument( |
9 | | - "--append", |
10 | | - "-a", |
11 | | - action="store_true", |
12 | | - help="Append instead of overwriting.", |
| 35 | + "--path", |
| 36 | + "-p", |
| 37 | + required=False, |
| 38 | + default=None, |
| 39 | + type=str, |
| 40 | + help="Path to the model directory.", |
13 | 41 | ) |
14 | 42 | parser.add_argument( |
15 | 43 | "--model-name-prefix", |
16 | | - "-p", |
17 | 44 | type=str, |
18 | 45 | help="Prefix for model names.", |
19 | 46 | default="", |
|
32 | 59 | help="Namefile pattern to look for in the model directories.", |
33 | 60 | default="mfsim.nam", |
34 | 61 | ) |
| 62 | + parser.add_argument( |
| 63 | + "--verbose", |
| 64 | + "-v", |
| 65 | + action="store_true", |
| 66 | + help="Show verbose output.", |
| 67 | + ) |
35 | 68 | args = parser.parse_args() |
36 | | - if not args.append: |
37 | | - models.DEFAULT_REGISTRY = models.PoochRegistry( |
38 | | - base_url=args.url, env=models._DEFAULT_ENV |
| 69 | + if args.path: |
| 70 | + if args.verbose: |
| 71 | + print(f"Adding {args.path} to the registry.") |
| 72 | + models.DEFAULT_REGISTRY.index( |
| 73 | + path=args.path, |
| 74 | + url=args.url, |
| 75 | + prefix=args.model_name_prefix, |
| 76 | + namefile=args.namefile, |
39 | 77 | ) |
40 | | - models.DEFAULT_REGISTRY.index( |
41 | | - path=args.path, |
42 | | - url=args.url, |
43 | | - prefix=args.model_name_prefix, |
44 | | - namefile=args.namefile, |
45 | | - ) |
| 78 | + else: |
| 79 | + if args.verbose: |
| 80 | + print("No path provided, creating default registry.") |
| 81 | + for options in _DEFAULT_REGISTRY_OPTIONS: |
| 82 | + if args.verbose: |
| 83 | + print(f"Adding {options.path} to the registry.") |
| 84 | + models.DEFAULT_REGISTRY.index( |
| 85 | + path=options["path"], |
| 86 | + url=options["url"], |
| 87 | + prefix=options["model-name-prefix"], |
| 88 | + namefile=options.get("namefile", "mfsim.nam"), |
| 89 | + ) |
0 commit comments