-
Notifications
You must be signed in to change notification settings - Fork 10
Import Fix & Optimize: G1 without ROS, lazy imports, Fix bad dir naming #1221
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
Changes from all commits
e08a311
4f38e8f
d1e5de4
9618a01
2129157
8136806
05287b2
dbfb6d6
0d28205
829412b
c10a81c
e992482
0d8dd3f
9f76c6c
1a530a1
a1f5352
5845f8d
a4e8a45
e0aba66
290253a
ba6e29a
36c69bb
28271c1
fe5b6a1
3614dca
72a9542
40f03ba
364ad8f
e9891f8
49e174b
52da9c7
f11ab9b
6d43c42
1e8930e
c733587
5e653a8
9bf224d
d5575c0
44ba48b
dbe419d
565b8a7
1f685dc
300e6d5
beb93f1
dd552d0
925e4aa
1dd7961
302877c
7488427
adffef3
406bf99
1833026
bf1e3cb
694d1b3
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 |
|---|---|---|
| @@ -1,18 +1,12 @@ | ||
| from dimos.agents.agent import Agent, deploy | ||
| from dimos.agents.spec import AgentSpec | ||
| from dimos.agents.vlm_agent import VLMAgent | ||
| from dimos.agents.vlm_stream_tester import VlmStreamTester | ||
| from dimos.protocol.skill.skill import skill | ||
| from dimos.protocol.skill.type import Output, Reducer, Stream | ||
| import lazy_loader as lazy | ||
|
|
||
| __all__ = [ | ||
| "Agent", | ||
| "AgentSpec", | ||
| "Output", | ||
| "Reducer", | ||
| "Stream", | ||
| "VLMAgent", | ||
| "VlmStreamTester", | ||
| "deploy", | ||
| "skill", | ||
| ] | ||
| __getattr__, __dir__, __all__ = lazy.attach( | ||
| __name__, | ||
| submod_attrs={ | ||
| "agent": ["Agent", "deploy"], | ||
| "spec": ["AgentSpec"], | ||
| "vlm_agent": ["VLMAgent"], | ||
| "vlm_stream_tester": ["VlmStreamTester"], | ||
| "_skill_exports": ["skill", "Output", "Reducer", "Stream"], | ||
| }, | ||
| ) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
|
Member
Author
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. This file exists so that an |
||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from dimos.protocol.skill.skill import skill | ||
| from dimos.protocol.skill.type import Output, Reducer, Stream | ||
|
|
||
| __all__ = ["Output", "Reducer", "Stream", "skill"] | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,60 +5,41 @@ | |
| import time | ||
| from typing import TYPE_CHECKING, cast | ||
|
|
||
| from dask.distributed import Client, LocalCluster | ||
| from rich.console import Console | ||
|
|
||
| import dimos.core.colors as colors | ||
| from dimos.core.core import rpc | ||
| from dimos.core.module import Module, ModuleBase, ModuleConfig, ModuleConfigT | ||
| from dimos.core.rpc_client import RPCClient | ||
| from dimos.core.stream import In, Out, RemoteIn, RemoteOut, Transport | ||
| from dimos.core.transport import ( | ||
| LCMTransport, | ||
|
Member
Author
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. we can lazy re-export most of this |
||
| SHMTransport, | ||
| ZenohTransport, | ||
| pLCMTransport, | ||
| pSHMTransport, | ||
| ) | ||
| from dimos.protocol.rpc import LCMRPC | ||
| from dimos.protocol.rpc.spec import RPCSpec | ||
| from dimos.protocol.tf import LCMTF, TF, PubSubTF, TFConfig, TFSpec | ||
| from dimos.utils.actor_registry import ActorRegistry | ||
| from dimos.utils.logging_config import setup_logger | ||
| import lazy_loader as lazy | ||
|
|
||
| if TYPE_CHECKING: | ||
| # Avoid runtime import to prevent circular import; ruff's TC001 would otherwise move it. | ||
| from dask.distributed import LocalCluster | ||
|
|
||
| from dimos.core._dask_exports import DimosCluster | ||
| from dimos.core.module import Module | ||
| from dimos.core.rpc_client import ModuleProxy | ||
|
|
||
| logger = setup_logger() | ||
|
|
||
| __all__ = [ | ||
| "LCMRPC", | ||
| "LCMTF", | ||
| "TF", | ||
| "DimosCluster", | ||
| "In", | ||
| "LCMTransport", | ||
| "Module", | ||
| "ModuleBase", | ||
| "ModuleConfig", | ||
| "ModuleConfigT", | ||
| "Out", | ||
| "PubSubTF", | ||
| "RPCSpec", | ||
| "RemoteIn", | ||
| "RemoteOut", | ||
| "SHMTransport", | ||
| "TFConfig", | ||
| "TFSpec", | ||
| "Transport", | ||
| "ZenohTransport", | ||
| "colors", | ||
| "pLCMTransport", | ||
| "pSHMTransport", | ||
| "rpc", | ||
| "start", | ||
| ] | ||
| __getattr__, __dir__, __all__ = lazy.attach( | ||
| __name__, | ||
| submodules=["colors"], | ||
| submod_attrs={ | ||
| "blueprints": ["autoconnect", "Blueprint"], | ||
| "_dask_exports": ["DimosCluster"], | ||
| "_protocol_exports": ["LCMRPC", "RPCSpec", "LCMTF", "TF", "PubSubTF", "TFConfig", "TFSpec"], | ||
| "module": ["Module", "ModuleBase", "ModuleConfig", "ModuleConfigT"], | ||
| "stream": ["In", "Out", "RemoteIn", "RemoteOut", "Transport"], | ||
| "transport": [ | ||
| "LCMTransport", | ||
| "SHMTransport", | ||
| "ZenohTransport", | ||
| "pLCMTransport", | ||
| "pSHMTransport", | ||
| ], | ||
| }, | ||
| ) | ||
| __all__ += ["DimosCluster", "Module", "rpc", "start", "wait_exit"] | ||
|
|
||
|
|
||
| class CudaCleanupPlugin: | ||
|
|
@@ -91,10 +72,10 @@ def teardown(self, worker) -> None: # type: ignore[no-untyped-def] | |
| def patch_actor(actor, cls) -> None: ... # type: ignore[no-untyped-def] | ||
|
|
||
|
|
||
| DimosCluster = Client | ||
|
Member
Author
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. in order to make dask lazy loaded, this needed to be done not-toplevel in an |
||
| def patchdask(dask_client: DimosCluster, local_cluster: LocalCluster) -> DimosCluster: | ||
| from dimos.core.rpc_client import RPCClient | ||
| from dimos.utils.actor_registry import ActorRegistry | ||
|
|
||
|
|
||
| def patchdask(dask_client: Client, local_cluster: LocalCluster) -> DimosCluster: | ||
| def deploy( # type: ignore[no-untyped-def] | ||
| actor_class: type[Module], | ||
| *args, | ||
|
|
@@ -129,6 +110,7 @@ def deploy( # type: ignore[no-untyped-def] | |
| def check_worker_memory() -> None: | ||
| """Check memory usage of all workers.""" | ||
| info = dask_client.scheduler_info() | ||
|
|
||
| console = Console() | ||
| total_workers = len(info.get("workers", {})) | ||
| total_memory_used = 0 | ||
|
|
@@ -263,6 +245,8 @@ def start(n: int | None = None, memory_limit: str = "auto") -> DimosCluster: | |
| DimosCluster: A patched Dask client with deploy(), check_worker_memory(), stop(), and close_all() methods | ||
| """ | ||
|
|
||
| from dask.distributed import Client, LocalCluster | ||
|
|
||
| console = Console() | ||
| if not n: | ||
| n = mp.cpu_count() | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Copyright 2026 Dimensional Inc. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| from dask.distributed import Client as DimosCluster | ||
|
|
||
| __all__ = ["DimosCluster"] |
Uh oh!
There was an error while loading. Please reload this page.
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.
without this change, the example code does not work!! (its broken on dev!)