Skip to content

Commit 4a69c6f

Browse files
Claudeilaflott
andcommitted
Update documentation to clarify YAML loader design
Per feedback: YAML consolidation not required, fremor config format is sufficient. - Update README to emphasize single-file YAML generated by fremor config - Update cmor_yaml_consolidator docstrings to remove multi-file references - Update YAML_SCHEMA_VALIDATION.md to clarify design intent - Update code comments to reflect backward compatibility focus - Remove references to multi-file consolidation as a feature Agent-Logs-Url: https://github.com/ilaflott/fremorizer/sessions/70ef490b-d026-4828-ae72-ea094bf80d11 Co-authored-by: ilaflott <6273252+ilaflott@users.noreply.github.com>
1 parent a69de21 commit 4a69c6f

File tree

4 files changed

+41
-45
lines changed

4 files changed

+41
-45
lines changed

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,13 @@ command now:
125125

126126
- Uses native YAML loading and validation by default
127127
- Validates YAML configurations against a JSON schema
128+
- Works with the YAML format generated by `fremor config`
128129
- Automatically falls back to `fre-cli`'s `yamltools.consolidate_yamls` if available
129-
(for advanced features like multi-file consolidation and platform/target overrides)
130+
(for backward compatibility with legacy workflows)
130131

131-
To use the advanced features provided by `fre-cli`, install it separately:
132-
```bash
133-
pip install fre-cli
134-
```
135-
136-
**Note:** The native YAML loader provides a simplified version suitable for most
137-
use cases. For complex multi-file YAML consolidation with platform/target/experiment
138-
overrides, the `fre-cli` package is still recommended.
132+
The native YAML loader is designed to work with YAML files generated by
133+
`fremor config`, which produces self-contained configuration files that don't
134+
require multi-file consolidation or platform/target overrides.
139135

140136
## License
141137

YAML_SCHEMA_VALIDATION.md

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,10 @@ Provides native YAML loading and validation functionality.
4343
- Optional output file generation
4444
- Compatibility parameters for fre-cli signature
4545

46-
**Limitations compared to fre-cli:**
47-
- Does not support multi-file YAML consolidation
48-
- Does not support platform/target/experiment-specific overrides
49-
- No variable substitution beyond environment variables
46+
**Design:**
47+
This module is designed to work with YAML files generated by `fremor config`,
48+
which produces self-contained configuration files. No multi-file consolidation
49+
or platform/target/experiment overrides are supported or needed.
5050

5151
### Modified Modules
5252

@@ -56,7 +56,7 @@ Updated to use native YAML loading by default, with automatic fallback to fre-cl
5656
**Changes:**
5757
- Lines 27: Added import for `load_and_validate_yaml`
5858
- Lines 96-111: Replaced hard dependency with conditional logic:
59-
- If `fre-cli` is available: Use `consolidate_yamls` (advanced features)
59+
- If `fre-cli` is available: Use `consolidate_yamls` (for backward compatibility)
6060
- If `fre-cli` is NOT available: Use native `load_and_validate_yaml`
6161
- No more ImportError - both paths work
6262

@@ -111,19 +111,24 @@ Comprehensive test suite covering:
111111

112112
The implementation maintains 100% backward compatibility:
113113

114-
1. **With fre-cli installed:** Uses `consolidate_yamls` (no change in behavior)
115-
2. **Without fre-cli installed:** Uses native loader (new functionality)
114+
1. **With fre-cli installed:** Uses `consolidate_yamls` (for backward compatibility)
115+
2. **Without fre-cli installed:** Uses native loader (standard approach)
116116
3. **Existing tests:** Continue to work with mocked `consolidate_yamls`
117117
4. **Configuration format:** Exactly the same structure expected
118+
5. **Generated YAML:** Works with output from `fremor config`
118119

119120
## Usage Examples
120121

121122
### Basic usage (native loader):
122123
```bash
123-
fremor yaml model.yaml --exp test --platform ncrc4 --target prod
124+
# Generate a YAML configuration from a PP directory
125+
fremor config --pp-dir /path/to/pp --mip-era CMIP6 --output config.yaml ...
126+
127+
# Use the generated YAML configuration
128+
fremor yaml config.yaml --exp test --platform ncrc4 --target prod
124129
```
125130

126-
### With advanced features (requires fre-cli):
131+
### With fre-cli (for backward compatibility):
127132
```bash
128133
pip install fre-cli
129134
fremor yaml model.yaml --exp test --platform ncrc4 --target prod
@@ -140,25 +145,23 @@ config = load_and_validate_yaml('model.yaml')
140145
## Migration Path
141146

142147
For users currently using fre-cli:
143-
1. No changes required - fre-cli continues to work
144-
2. Optional: Remove fre-cli dependency for simpler workflows
145-
3. Optional: Update YAML files to be standalone (no multi-file inheritance)
148+
1. No changes required - fre-cli continues to work for backward compatibility
149+
2. Optional: Switch to `fremor config` to generate YAML files
150+
3. Optional: Remove fre-cli dependency if not needed for other workflows
146151

147152
For new users:
148153
1. Install fremorizer: `pip install fremorizer`
149-
2. Create YAML config using `example_cmor_config.yaml` as template
150-
3. Run: `fremor yaml your_config.yaml`
154+
2. Generate YAML config: `fremor config --pp-dir /path/to/pp ...`
155+
3. Run CMORization: `fremor yaml config.yaml`
151156
4. No fre-cli installation needed
152157

153158
## Future Enhancements
154159

155160
Potential improvements:
156-
1. Multi-file YAML consolidation in native loader
157-
2. Platform/target/experiment override support
158-
3. Enhanced variable substitution (beyond environment variables)
159-
4. YAML schema auto-generation from Python types
160-
5. Additional validation rules (path existence, value ranges)
161-
6. Schema versioning for CMIP6 vs CMIP7 differences
161+
1. Enhanced variable substitution (beyond environment variables)
162+
2. Additional validation rules (path existence, value ranges)
163+
3. Schema versioning for CMIP6 vs CMIP7 differences
164+
4. Support for YAML anchors/references in generated configs
162165

163166
## Testing Notes
164167

fremorizer/cmor_yaml_consolidator.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
"""
2-
Native YAML Consolidation for CMOR Configuration
3-
================================================
2+
Native YAML Loader for CMOR Configuration
3+
==========================================
44
5-
This module provides native YAML consolidation functionality to replace
5+
This module provides native YAML loading functionality to replace
66
the dependency on fre-cli's yamltools.consolidate_yamls function.
77
88
Functions
99
---------
1010
- ``load_and_validate_yaml(...)`` - Load and validate a CMOR YAML configuration file
1111
12-
.. note:: This module eliminates the dependency on fre-cli for YAML processing
12+
.. note:: This module eliminates the dependency on fre-cli for YAML processing.
13+
It is designed to work with YAML files generated by fremor config.
1314
"""
1415

1516
import os
@@ -38,8 +39,11 @@ def load_and_validate_yaml(
3839
Load and validate a CMOR YAML configuration file.
3940
4041
This function loads a YAML file, validates its structure against the CMOR schema,
41-
and returns the configuration dictionary. This is a simplified replacement for
42-
fre-cli's consolidate_yamls function that doesn't require external dependencies.
42+
and returns the configuration dictionary. This is a replacement for fre-cli's
43+
consolidate_yamls function that doesn't require external dependencies.
44+
45+
Designed to work with YAML files generated by 'fremor config', which produces
46+
self-contained configuration files.
4347
4448
:param yamlfile: Path to the YAML configuration file
4549
:type yamlfile: str
@@ -51,7 +55,7 @@ def load_and_validate_yaml(
5155
:type target: str, optional
5256
:param use: Configuration section to use (default: 'cmor')
5357
:type use: str
54-
:param output: Optional output filename (for compatibility, currently unused)
58+
:param output: Optional output filename to write validated config
5559
:type output: str, optional
5660
:raises FileNotFoundError: If the YAML file does not exist
5761
:raises ValueError: If the YAML structure is invalid
@@ -63,13 +67,6 @@ def load_and_validate_yaml(
6367
>>> config = load_and_validate_yaml('model.yaml')
6468
>>> print(config['cmor']['mip_era'])
6569
CMIP6
66-
67-
.. note:: This function provides a simplified version of YAML consolidation.
68-
It does not support:
69-
- Multi-file YAML consolidation
70-
- Platform/target/experiment-specific overrides
71-
- Variable substitution
72-
For these features, install fre-cli and use its consolidate_yamls function.
7370
"""
7471
# Expand environment variables in path
7572
yamlfile = os.path.expandvars(yamlfile)

fremorizer/cmor_yamler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def cmor_yaml_subtool( yamlfile: str = None,
9191
# ---------------------------------------------------
9292
# parsing the target model yaml ---------------------
9393
# ---------------------------------------------------
94-
# Use native YAML consolidation by default, with optional fre-cli fallback
95-
# for advanced features (multi-file consolidation, platform/target overrides)
94+
# Use native YAML loader by default, with optional fre-cli fallback
95+
# for backward compatibility with legacy workflows
9696
if consolidate_yamls is not None:
9797
fre_logger.info('using fre-cli consolidate_yamls for YAML processing')
9898
cmor_yaml_dict = consolidate_yamls(yamlfile=yamlfile,

0 commit comments

Comments
 (0)