Skip to content

Commit 1c9dc49

Browse files
feat(changelog): add new features for component properties and taxonomy 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.
1 parent d5f866f commit 1c9dc49

6 files changed

Lines changed: 40 additions & 9 deletions

File tree

docs/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to GemsPy are documented here.
44

5+
## [Unreleased]
6+
7+
### Added
8+
9+
- **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 keys raise a `ValueError`).
10+
- **Model schema: `taxonomy-category`** - introduces optional `taxonomy-category` on models in library YAML files, exposed as `ModelSchema.taxonomy_category`.
11+
512
## [0.1.0] - 2026-04-30
613

714
### Study folder structure

docs/getting-started.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ library:
2929

3030
- id: generator
3131
description: A basic generator model
32+
taxonomy-category: production
3233
parameters:
3334
- id: marginal_cost
3435
time-dependent: false
@@ -92,6 +93,9 @@ system:
9293
components:
9394
- id: G1
9495
model: basic.generator
96+
properties:
97+
- key: technology
98+
value: nuclear
9599
parameters:
96100
- id: marginal_cost
97101
time-dependent: false

docs/user-guide/inputs.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,28 @@ from `input/data-series/modeler-scenariobuilder.dat` (if present).
3939
Use the lower-level functions when you want to load files individually or build
4040
parts of the study from in-memory data.
4141

42+
---
43+
44+
## System YAML: optional component `properties`
45+
46+
In `system.yml`, each component may define an optional `properties` section as a
47+
list of key/value pairs:
48+
49+
~~~ yaml
50+
system:
51+
components:
52+
- id: nuclear_1
53+
model: basic.generator
54+
properties:
55+
- id: technology
56+
value: nuclear
57+
- id: company
58+
value: rhonepower
59+
~~~
60+
61+
At resolution time (`resolve_system` / `load_study`), this list is normalized into
62+
a `dict[str, str]` stored on the resolved `Component`. Duplicate keys are rejected.
63+
4264
### Loading the library and the system
4365

4466
~~~ python

src/gems/study/parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class ComponentParameterSchema(ModifiedBaseModel):
5656

5757

5858
class ComponentPropertySchema(ModifiedBaseModel):
59-
key: str
59+
id: str
6060
value: str
6161

6262

src/gems/study/resolve_components.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
from pathlib import Path
1313
from typing import Dict, List, Optional, Tuple, Union
1414

15-
import pandas as pd
16-
1715
from gems.model import Model
1816
from gems.model.library import Library
1917
from gems.study import (
@@ -50,10 +48,10 @@ def _resolve_properties_raw_to_dict(
5048
return {}
5149
properties: Dict[str, str] = {}
5250
for item in raw:
53-
k = item.key
51+
k = item.id
5452
if k in properties:
5553
raise ValueError(
56-
f"Component {component_id!r}: duplicate properties key {k!r}"
54+
f"Component {component_id!r}: duplicate properties id {k!r}"
5755
)
5856
properties[k] = item.value
5957
return properties

tests/unittests/system_parsing/test_components_parsing.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ def test_consistency_check_ko(
110110
- id: nuclear_1
111111
model: basic.generator
112112
properties:
113-
- key: technology
113+
- id: technology
114114
value: nuclear
115-
- key: company
115+
- id: company
116116
value: rhonepower
117117
"""
118118

@@ -162,9 +162,9 @@ def test_parse_yaml_components_properties_missing_key_raises() -> None:
162162
- id: A
163163
model: basic.node
164164
properties:
165-
- key: technology
165+
- id: technology
166166
value: nuclear
167-
- key: technology
167+
- id: technology
168168
value: gas
169169
"""
170170

0 commit comments

Comments
 (0)