feat(library <-> taxonomy check)#214
Conversation
… implement corresponding unit test for YAML parsing
… taxonomy_category field
…my category - Introduced optional `properties` for components in `system.yml`, allowing key/value pairs that are normalized into a dictionary. - Added optional `taxonomy-category` field for models in library YAML files, accessible via `ModelSchema.taxonomy_category`. - Updated documentation to reflect these changes and provided examples in the user guide.
- Updated documentation to replace "key" with "id" in the context of component properties in `system.yml`. - Adjusted test assertions to reflect the change from "key" to "id" for consistency with the updated documentation. - Ensured that error messages for duplicate properties also refer to "id" instead of "key".
- Added a new `Study` dataclass that combines `System` and `DataBase`, centralizing consistency checks. - Updated `build_problem()` and `build_decomposed_problems()` to accept `Study` directly. - Refactored related functions and tests to utilize the new `Study` structure, ensuring seamless integration. - Removed redundant parameters and streamlined the API for better clarity and usability.
Open questions:
|
|
There was a problem hiding this comment.
- You need to do more complete checks between the taxonomy and models (variables, parameters, constraints, properties, extra-outputs)
- The models should declare a list of properties such as :
model: thermal
properties:
- id: carrier
- id: technologyWe need to check that each model declares the required properties from the taxonomy (but it could declare additional ones)
- If a model defines a property, it should be defined for each component of this model within the system file. We need to add a check for this. A component in the system may define additional properties that are not required by the model
I think we should keep this PR on the checks model <-> taxonomy for everything but the properties and handle the work on the properties (which may modify the models, systems and tests) in another PR (check taxonomy <-> library and library <-> system)
|
|
||
| --- | ||
|
|
||
| ## System YAML: optional component `properties` |
There was a problem hiding this comment.
| ## System YAML: optional component `properties` | |
| ## System YAML: optional field `properties` for components |
| At resolution time (`resolve_system` / `load_study`), this list is normalized into | ||
| a `dict[str, str]` stored on the resolved `Component`. Duplicate ids are rejected. |
There was a problem hiding this comment.
Do we need these technical details here ? Only mentioning that duplicated ids are forbidden is sufficient ?
|
|
||
| --- | ||
|
|
||
| ## System YAML: optional component `properties` |
There was a problem hiding this comment.
Should the model declare the list of possible properties ?
| --- | ||
| - **System components: `properties`** - introduces optional `properties` on components in `system.yml` (a list of `id`/`value` pairs). These are normalized into a `dict[str, str]` on the resolved `Component` (duplicate ids raise a `ValueError`). | ||
| - **Model schema: `taxonomy-category`** - introduces optional `taxonomy-category` on models in library YAML files, exposed as `ModelSchema.taxonomy_category`. | ||
| - **Taxonomy check** - new `gems.model.taxonomy` module with `load_taxonomy(path)` and `check_library_against_taxonomy(library, taxonomy)`. Validates that every model declaring a `taxonomy-category` references a category that exists in the taxonomy file, and exposes all port IDs required by that category. Taxonomy classes (`TaxonomyItem`, `TaxonomyCategory`, `Taxonomy`) mirror the structure defined in GEMS-ViewsBuilder. |
There was a problem hiding this comment.
I don't think the last sentence is relevant as we do not want to mention GEMSViewsBuilder within GemsPy
| --- | ||
| - **System components: `properties`** - introduces optional `properties` on components in `system.yml` (a list of `id`/`value` pairs). These are normalized into a `dict[str, str]` on the resolved `Component` (duplicate ids raise a `ValueError`). | ||
| - **Model schema: `taxonomy-category`** - introduces optional `taxonomy-category` on models in library YAML files, exposed as `ModelSchema.taxonomy_category`. | ||
| - **Taxonomy check** - new `gems.model.taxonomy` module with `load_taxonomy(path)` and `check_library_against_taxonomy(library, taxonomy)`. Validates that every model declaring a `taxonomy-category` references a category that exists in the taxonomy file, and exposes all port IDs required by that category. Taxonomy classes (`TaxonomyItem`, `TaxonomyCategory`, `Taxonomy`) mirror the structure defined in GEMS-ViewsBuilder. |
There was a problem hiding this comment.
| - **Taxonomy check** - new `gems.model.taxonomy` module with `load_taxonomy(path)` and `check_library_against_taxonomy(library, taxonomy)`. Validates that every model declaring a `taxonomy-category` references a category that exists in the taxonomy file, and exposes all port IDs required by that category. Taxonomy classes (`TaxonomyItem`, `TaxonomyCategory`, `Taxonomy`) mirror the structure defined in GEMS-ViewsBuilder. | |
| - **Taxonomy check** - new `gems.model.taxonomy` module with `load_taxonomy(path)` and `check_library_against_taxonomy(library, taxonomy)`. Validates that every model declaring a `taxonomy-category` references a category that exists in the taxonomy file, and exposes all variables, parameters, constraints, ports, extra-outputs and properties required by that category. Taxonomy classes (`TaxonomyItem`, `TaxonomyCategory`, `Taxonomy`) mirror the structure defined in GEMS-ViewsBuilder. |
| """ | ||
| Validates that every model declaring a taxonomy_category: | ||
| 1. References a category that exists in the taxonomy. | ||
| 2. Exposes all port IDs listed in that taxonomy category. |
There was a problem hiding this comment.
| 2. Exposes all port IDs listed in that taxonomy category. | |
| 2. Exposes all variables, parameters, constraints, ports, extra-outputs and properties listed in that taxonomy category. |
| ) | ||
|
|
||
| category = categories[cat_id] | ||
| model_port_ids = {p.id for p in model_schema.ports} |
There was a problem hiding this comment.
You need to check more than just the ports, see above comment
There was a problem hiding this comment.
These tests seem redundant (and less complete) than the one in test_components_parsing.py. Should we remove them ?
No description provided.