|
13 | 13 | QWidget,
|
14 | 14 | )
|
15 | 15 |
|
16 |
| -from ultrack import MainConfig |
| 16 | +from ultrack.config import CFG_ALIAS_TO_ATTR, MainConfig |
17 | 17 | from ultrack.widgets.ultrackwidget.components.blankable_number_edit import (
|
18 | 18 | BlankableNumberEdit,
|
19 | 19 | )
|
@@ -114,9 +114,12 @@ def load_config(self, config: MainConfig) -> None:
|
114 | 114 | config : MainConfig
|
115 | 115 | The main configuration to load.
|
116 | 116 | """
|
117 |
| - self._config = config.model_dump(by_alias=True) |
118 |
| - for id_form, id_field, widget, getter, setter in self._bindings: |
119 |
| - value = self._config[id_form][id_field] |
| 117 | + self._config = config |
| 118 | + for id_form, id_field, widget, _, setter in self._bindings: |
| 119 | + # Get the actual config field name from the alias mapping |
| 120 | + field_name = CFG_ALIAS_TO_ATTR.get(id_form, id_form) |
| 121 | + # In Pydantic v2, we can still use getattr for nested access |
| 122 | + value = getattr(getattr(self._config, field_name), id_field) |
120 | 123 | getattr(widget, setter)(value)
|
121 | 124 |
|
122 | 125 | def _create_form(self, id_form: str, metadata: Dict[str, Any]) -> None:
|
@@ -372,10 +375,14 @@ def get_config(self) -> MainConfig:
|
372 | 375 | MainConfig
|
373 | 376 | The main configuration object.
|
374 | 377 | """
|
375 |
| - for id_form, id_field, widget, getter, setter in self._bindings: |
| 378 | + for id_form, id_field, widget, getter, _ in self._bindings: |
376 | 379 | value = getattr(widget, getter)()
|
377 |
| - self._config[id_form][id_field] = value |
378 |
| - return MainConfig.parse_obj(self._config) |
| 380 | + # Get the actual config field name from the alias mapping |
| 381 | + field_name = CFG_ALIAS_TO_ATTR.get(id_form, id_form) |
| 382 | + sub_config = getattr(self._config, field_name) |
| 383 | + # In Pydantic v2, we can still use setattr for direct updates |
| 384 | + setattr(sub_config, id_field, value) |
| 385 | + return self._config |
379 | 386 |
|
380 | 387 | def setup_additional_options(self, workflow_choice: WorkflowChoice) -> None:
|
381 | 388 | """
|
|
0 commit comments