-
Notifications
You must be signed in to change notification settings - Fork 7
Fix/Organize Types for ModuleCoordiator/DimosCluster/WorkerManager/RPCClient/ModuleProxy #1164
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: dev
Are you sure you want to change the base?
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()
|
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.
6 files reviewed, 2 comments
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error message references PureDeployer but class is now named WorkerDeployer
| raise RuntimeError("PureDeployer is closed") | |
| raise RuntimeError("WorkerDeployer is closed") |
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.