Conversation
| setattr(cls, name, None) | ||
|
|
||
| def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def] | ||
| def __init__(self, global_config: GlobalConfig = global_config, **kwargs: Any): |
There was a problem hiding this comment.
As an alternative to asking subclasses (that need a custom __init__()) to include global_config here, I could move it into the ModuleConfig itself? Then subclasses will just pass kwargs alone.
Greptile SummaryThis PR standardizes module configuration by migrating from dataclasses to Pydantic models and enforcing a fixed Key Changes:
Issues Found:
Impact: Confidence Score: 3/5
Important Files Changed
Class Diagram%%{init: {'theme': 'neutral'}}%%
classDiagram
class BaseConfig {
<<Pydantic BaseModel>>
+model_config: arbitrary_types_allowed
}
class ModuleConfig {
+rpc_transport: RPCSpec
+tf_transport: TFSpec
+frame_id_prefix: str | None
+frame_id: str | None
}
class NativeModuleConfig {
+executable: str
+build_command: str | None
+extra_args: list
+extra_env: dict
+compute_cli_args() list
}
class Configurable~ConfigT~ {
<<Generic>>
+default_config: type[ConfigT]
+config: ConfigT
+__init__(**kwargs)
}
class ModuleBase~ModuleConfigT~ {
+default_config: ModuleConfig
-_rpc: RPCSpec | None
-_tf: TFSpec | None
+__init__(config_args: dict, global_config: GlobalConfig)
}
class Module~ModuleConfigT~ {
+__init__(global_config: GlobalConfig, **kwargs)
+set_ref(ref)
+start()
+stop()
}
class NativeModule~NativeConfig~ {
+default_config: NativeModuleConfig
-_process: Popen | None
+__init__(global_config: GlobalConfig, **kwargs)
}
BaseConfig <|-- ModuleConfig : inherits
ModuleConfig <|-- NativeModuleConfig : inherits
Configurable <|-- ModuleBase : inherits
ModuleBase <|-- Module : inherits
Module <|-- NativeModule : inherits
Configurable --> BaseConfig : uses ConfigT
ModuleBase --> ModuleConfig : uses ModuleConfigT
note for ModuleBase "Fixed __init__ signature:\nconfig_args + global_config"
note for Module "Standardized signature:\nglobal_config + **kwargs"
note for BaseConfig "Runtime validation\nvia Pydantic"
Last reviewed commit: 28a43f7 |
dimos/perception/experimental/temporal_memory/temporal_memory.py
Outdated
Show resolved
Hide resolved
|
The tests are still failing.
|
Problem
Working towards #1082, this helps standardise setting in modules which can then be expanded upon to enable further things such as CLI arguments to be injected. They are also now type checked at runtime via Pydantic.
Solution
Primary change to developers is that the
__init__()method now uses a fixed signature and all configurable options appear in the config. That config is now a pydantic model, so it gets verified when the module is instantiated.A lot of typing fixes were also made by changing incorrect references to Module to ModuleBase and similar adjustments.
Breaking Changes
Subclasses of Module must now match the
__init__()signature of the Module class.