-
Notifications
You must be signed in to change notification settings - Fork 728
fix(config): merge nested module overrides #2829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,14 +14,16 @@ | |
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from pydantic import Field | ||
| import pytest | ||
|
|
||
| from dimos.core.coordination.worker_manager_python import WorkerManagerPython | ||
| from dimos.core.coordination.worker_manager_python import WorkerManagerPython, _merge_config_kwargs | ||
| from dimos.core.core import rpc | ||
| from dimos.core.global_config import GlobalConfig, global_config | ||
| from dimos.core.module import Module | ||
| from dimos.core.module import Module, ModuleConfig | ||
| from dimos.core.stream import In, Out | ||
| from dimos.msgs.geometry_msgs.Vector3 import Vector3 | ||
| from dimos.protocol.service.spec import BaseConfig | ||
|
|
||
| if TYPE_CHECKING: | ||
| from dimos.core.resource_monitor.stats import WorkerStats | ||
|
|
@@ -81,6 +83,15 @@ def get_multiplier(self) -> int: | |
| return self.multiplier | ||
|
|
||
|
|
||
| class NestedConfig(BaseConfig): | ||
| a: int = 0 | ||
| b: int = 2 | ||
|
|
||
|
|
||
| class ModuleWithNestedConfig(ModuleConfig): | ||
| sub: NestedConfig = Field(default_factory=lambda: NestedConfig(a=10, b=20)) | ||
|
|
||
|
|
||
| class HeavyModule(Module): | ||
| dedicated_worker = True | ||
|
|
||
|
|
@@ -189,6 +200,17 @@ def test_worker_manager_parallel_deployment(create_worker_manager): | |
| module3.stop() | ||
|
|
||
|
|
||
| def test_nested_blueprint_config_defaults_survive_cli_override(): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Existing blueprint tests are in test_dimos.py, can you move the test there and follow the format there (which means classes defined inside the test).
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I'm not too clear on this test. The test uses _merge_config_kwargs() directly, which doesn't really test that the user flow will work correctly.. |
||
| blueprint_kwargs = {"sub": NestedConfig(a=10, b=20)} | ||
| cli_kwargs = {"sub": {"a": "1"}} | ||
|
|
||
| merged = _merge_config_kwargs(blueprint_kwargs, cli_kwargs) | ||
| config = ModuleWithNestedConfig(**merged) | ||
|
|
||
| assert config.sub.a == 1 | ||
| assert config.sub.b == 20 | ||
|
|
||
|
|
||
| @pytest.mark.skipif_macos_bug | ||
| def test_collect_stats(create_worker_manager): | ||
| from dimos.core.resource_monitor.monitor import StatsMonitor | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear if it makes sense to have a lambda here. Why have defaults on the config, and then replace them with different defaults?