Skip to content

Commit 602b56f

Browse files
committed
update plan/progress
1 parent 1a4a309 commit 602b56f

File tree

1 file changed

+63
-30
lines changed

1 file changed

+63
-30
lines changed

docs/md/dev/models.md

Lines changed: 63 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Model repository developers can use the `modflow-devtools` registry-creation fac
7878

7979
## Architecture
8080

81-
This will involve a few new components (e.g., bootstrap file, `MergedRegistry` class) as well as modifications to some existing components (e.g., existing registry files, `PoochRegistry`). It should be possible for the `ModelRegistry` contract to remain unchanged.
81+
This involves several new components (bootstrap file, user config overlay) and a consolidated registry class hierarchy. The previous `ModelRegistry` ABC has been replaced with a Pydantic-based `Registry` base class that both `LocalRegistry` and `PoochRegistry` inherit from.
8282

8383
### Bootstrap file
8484

@@ -121,6 +121,24 @@ refs = [
121121

122122
Note: The bootstrap refs list indicates default refs to sync at install time. Users can request synchronization to any valid git ref (branch, tag, or commit hash) via the CLI or API.
123123

124+
#### User config overlay
125+
126+
Users can customize or extend the bundled bootstrap configuration by creating a user config file at:
127+
- Linux/macOS: `~/.config/modflow-devtools/bootstrap.toml` (respects `$XDG_CONFIG_HOME`)
128+
- Windows: `%APPDATA%/modflow-devtools/bootstrap.toml`
129+
130+
The user config follows the same format as the bundled bootstrap file. Sources defined in the user config will override or extend those in the bundled config:
131+
- Sources with the same key will be completely replaced by the user version
132+
- New sources will be added to the available sources
133+
134+
This allows users to:
135+
- Add private or custom model repositories
136+
- Point to forks of existing repositories
137+
- Override default refs for existing sources
138+
- Temporarily disable sources (by overriding with empty refs list)
139+
140+
The user config is automatically loaded and merged when using the default bootstrap location. For testing, a custom user config path can be specified via the `user_config_path` parameter to `load_bootstrap()`.
141+
124142
### Registry files
125143

126144
There are currently three separate registry files:
@@ -352,35 +370,34 @@ Benefits of this approach:
352370

353371
### Registry classes
354372

355-
`PoochRegistry` is currently associated with a single state of a single repository. This can continue. Introduce a few properties to (e.g. `source` and `ref`) to make the model source and version explicit.
356-
357-
`PoochRegistry` should be immutable — to synchronize to a new model source state, create a new one.
358-
359-
Introduce a `MergedRegistry` compositor to merge multiple `PoochRegistry` instances under the same `ModelRegistry` API. The initializer can simply accept a list of pre-constructed `PoochRegistry` instances, and expose a list or dictionary of the registries of which it consists. Properties inherited from `ModelRegistry` (`files`, `models`, `examples`) can return merged views.
360-
361-
Handle synchronization, `MergedRegistry` construction, and similar concerns at the module (i.e. higher) level. Registries don't need to concern themselves with this sort of thing.
362-
363-
Some tentative usage examples:
364-
365-
```python
366-
# Create individual registries
367-
examples_v1 = PoochRegistry("modflow6-examples", "v1.2.3")
368-
testmodels = PoochRegistry("modflow6-testmodels", "develop")
369-
370-
# Merge them
371-
merged = MergedRegistry([examples_v1, testmodels])
372-
373-
# Later: update to new ref
374-
examples_v2 = PoochRegistry("modflow6-examples", "v2.0.0")
375-
merged = MergedRegistry([examples_v2, testmodels])
376-
377-
# Mix multiple refs of same source
378-
examples_stable = PoochRegistry("modflow6-examples", "v1.2.3")
379-
examples_dev = PoochRegistry("modflow6-examples", "develop")
380-
merged = MergedRegistry([examples_stable, examples_dev, testmodels])
381-
```
382-
383-
`LocalRegistry` is unaffected by all this, as it suits a different use case largely aimed at developers. Consider renaming it e.g. to `DeveloperRegistry`.
373+
The registry class hierarchy has been consolidated onto a Pydantic-based `Registry` base class (defined in `schema.py`):
374+
375+
**`Registry` (base class)**:
376+
- Pydantic model with `files`, `models`, `examples` fields
377+
- Optional `meta` field for registry metadata (present when loaded from TOML, None for local registries)
378+
- `FileEntry` model supports both local (`path`) and remote (`url`) files
379+
- Base `copy_to()` raises `NotImplementedError` - subclasses override
380+
- Can be instantiated directly for data-only use (e.g., loading/parsing TOML files)
381+
382+
**`LocalRegistry`**:
383+
- Inherits from `Registry`
384+
- Scans local filesystem directories for models
385+
- Creates `FileEntry` objects with `path` field
386+
- Implements `copy_to()` for local file copying
387+
- No `meta` field (remains None)
388+
389+
**`PoochRegistry`**:
390+
- Inherits from `Registry`
391+
- Loads from cached or bundled registry files
392+
- Creates `FileEntry` objects with both `url` (source) and `path` (cache location)
393+
- Implements `copy_to()` for remote fetching + copying
394+
- Populates `meta` from registry file if available
395+
396+
**Key changes from original design**:
397+
- Removed `ModelRegistry` ABC - consolidated onto Pydantic `Registry`
398+
- `FileEntry` supports both local and remote files via optional `url`/`path` fields
399+
- `MergedRegistry` not yet implemented - registries are merged during cache loading in `PoochRegistry`
400+
- `LocalRegistry` kept its name (not renamed to `DeveloperRegistry`)
384401

385402
### Module-Level API
386403

@@ -447,6 +464,22 @@ Use `python -m modflow_devtools.models sync` to download the latest registry.
447464
3. ⬜ Document new workflow in `models.md`
448465
4. ⬜ Add migration guide for v2.x
449466

467+
#### Phase 4.5: Architecture Improvements (v1.x) - ✅ COMPLETE
468+
469+
1. ✅ User config overlay support
470+
- Added `get_user_config_path()` for platform-appropriate config location
471+
- Added `merge_bootstrap()` to merge user + bundled configs
472+
- Updated `load_bootstrap()` with optional `user_config_path` parameter
473+
- User config automatically loaded and merged when using default bootstrap
474+
- Comprehensive tests in `test_models_v2.py::TestBootstrap`
475+
476+
2. ✅ Registry class consolidation
477+
- Removed `ModelRegistry` ABC
478+
- Made `Registry` (Pydantic) the base class for all registries
479+
- Updated `FileEntry` to support both local (`path`) and remote (`url`) files
480+
- Updated `LocalRegistry` and `PoochRegistry` to inherit from `Registry`
481+
- All 26 tests passing in `test_models_v2.py`
482+
450483
#### Phase 5: v2.x Release - ⬜ NOT STARTED
451484

452485
1. ⬜ Remove bundled registry files (keep bootstrap.toml)

0 commit comments

Comments
 (0)