Fix/Organize Types for ModuleCoordiator/DimosCluster/WorkerManager/RPCClient/ModuleProxy#1164
Fix/Organize Types for ModuleCoordiator/DimosCluster/WorkerManager/RPCClient/ModuleProxy#1164jeff-hykin wants to merge 88 commits intodevfrom
Conversation
…lueprint to be consistent with docs
Greptile OverviewGreptile SummaryThis PR improves typing throughout the core module system by introducing a Major Changes:
The changes significantly improve type safety and enable better architectural patterns through interface-based module dependencies. Confidence Score: 4.5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Blueprint
participant ModuleCoordinator
participant DeployerProtocol
participant WorkerDeployer
participant DaskDeployer
participant ModuleProxy
participant Module
Note over Blueprint,ModuleCoordinator: Refactor: ModuleBlueprintSet → Blueprint
User->>Blueprint: create via Module.blueprint()
Note over Blueprint: Now includes Spec support via ModuleRef
User->>Blueprint: autoconnect(blueprints)
Blueprint->>Blueprint: Resolve stream connections
Blueprint->>Blueprint: Resolve module refs via Spec matching
User->>Blueprint: build()
Blueprint->>ModuleCoordinator: new ModuleCoordinator()
ModuleCoordinator->>ModuleCoordinator: start()
alt Using Dask
Note over ModuleCoordinator,DaskDeployer: Refactor: DimosCluster → DaskDeployer
ModuleCoordinator->>DaskDeployer: core.start()
Note over DaskDeployer: Implements DeployerProtocol
else Using Workers
Note over ModuleCoordinator,WorkerDeployer: Refactor: WorkerManager → WorkerDeployer
ModuleCoordinator->>WorkerDeployer: new WorkerDeployer()
Note over WorkerDeployer: Implements DeployerProtocol
end
ModuleCoordinator->>DeployerProtocol: deploy(module_class, args, kwargs)
DeployerProtocol-->>ModuleCoordinator: ModuleProxy
Note over ModuleProxy: New type: RPCClient + Module for better typing
Blueprint->>ModuleCoordinator: _connect_streams()
Blueprint->>ModuleCoordinator: _connect_rpc_methods()
Blueprint->>ModuleCoordinator: _connect_module_refs()
Note over Blueprint,Module: New: Connects modules via Spec protocol matching
ModuleCoordinator->>ModuleProxy: set_module_ref(name, target)
ModuleProxy->>Module: setattr(name, target)
ModuleCoordinator->>ModuleProxy: start()
ModuleProxy->>Module: start()
|
| def deploy(self, module_class: type[ModuleT], *args: Any, **kwargs: Any) -> ModuleProxy: | ||
| if self._closed: | ||
| raise RuntimeError("WorkerManager is closed") | ||
| raise RuntimeError("PureDeployer is closed") |
There was a problem hiding this comment.
Error message references PureDeployer but class is now named WorkerDeployer
| raise RuntimeError("PureDeployer is closed") | |
| raise RuntimeError("WorkerDeployer is closed") |
| ) -> list[ModuleProxy]: | ||
| if self._closed: | ||
| raise RuntimeError("WorkerManager is closed") | ||
| raise RuntimeError("PureDeployer is closed") |
There was a problem hiding this comment.
Error message references PureDeployer but class is now named WorkerDeployer
| raise RuntimeError("PureDeployer is closed") | |
| raise RuntimeError("WorkerDeployer is closed") |
|
@jeff-hykin Can you please rebase this off of dev again? There are some conflicts and I'm not sure what the new changes are. |
NOTE: only merge this after the RPC rework merge
DimosCluster is basically untyped cause its a dynamic hack of the dask Client
This PR basically adds proper typing to DimosCluster, enforcing that both DimosCluster and WorkerManager follow a
DeployerProtocol, which fixes a lot of the mypy ignores in ModuleCoordiator.After adding the protocol, I think it made sense to use consistent names:
WorkerManager => WorkerDeployerandDimosCluster => DaskDeployer(and we would eventually have aDockerDeployer) so those renames are in this PR.