Skip to content

Commit f383362

Browse files
committed
small changes. fixed test (no LCM in CI)
1 parent 04252a2 commit f383362

File tree

4 files changed

+26
-27
lines changed

4 files changed

+26
-27
lines changed

dimos/core/__init__.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import multiprocessing as mp
2+
13
import pytest
24
from dask.distributed import Client, LocalCluster
35

@@ -17,7 +19,7 @@ def deploy(actor_class, *args, **kwargs):
1719
).result()
1820

1921
actor.set_ref(actor).result()
20-
print(f"\033[32msubsystem deployed: [{actor}]\033[0m")
22+
print(colors.green(f"Subsystem deployed: {actor}"))
2123
return actor
2224

2325
dask_client.deploy = deploy
@@ -27,15 +29,19 @@ def deploy(actor_class, *args, **kwargs):
2729
@pytest.fixture
2830
def dimos():
2931
process_count = 3 # we chill
30-
cluster = LocalCluster(n_workers=process_count, threads_per_worker=3)
31-
client = Client(cluster)
32-
yield patchdask(client)
33-
client.close()
34-
cluster.close()
32+
client = start(process_count)
33+
yield client
34+
stop(client)
3535

3636

3737
def start(n):
38-
cluster = LocalCluster(n_workers=n, threads_per_worker=3)
38+
if not n:
39+
n = mp.cpu_count()
40+
print(colors.green(f"Initializing dimos local cluster with {n} workers"))
41+
cluster = LocalCluster(
42+
n_workers=n,
43+
threads_per_worker=3,
44+
)
3945
client = Client(cluster)
4046
return patchdask(client)
4147

dimos/core/core.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,12 @@ class In(Stream[T]):
206206
connection: Optional[RemoteOut[T]] = None
207207

208208
def __str__(self):
209-
return super().__str__() + ("" if not self.connection else f" <- {self.connection}")
209+
mystr = super().__str__()
210+
211+
if not self.connection:
212+
return mystr
213+
214+
return (mystr + " ◀─").ljust(60, "─") + f" {self.connection}"
210215

211216
def __reduce__(self): # noqa: D401
212217
if self.owner is None or not hasattr(self.owner, "ref"):

dimos/core/module_dask.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,10 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import inspect
1615
from typing import (
1716
Any,
1817
Callable,
19-
Dict,
20-
Generic,
2118
List,
22-
Protocol,
23-
TypeVar,
2419
get_args,
2520
get_origin,
2621
get_type_hints,
@@ -99,11 +94,7 @@ def inputs(self) -> dict[str, In]:
9994

10095
@property
10196
def rpcs(self) -> List[Callable]:
102-
return [
103-
getattr(self, name)
104-
for name in dir(self)
105-
if callable(getattr(self, name)) and hasattr(getattr(self, name), "__rpc__")
106-
]
97+
return [name for name in dir(self) if hasattr(getattr(self, name), "__rpc__")]
10798

10899
def io(self) -> str:
109100
def _box(name: str) -> str:
@@ -114,9 +105,9 @@ def _box(name: str) -> str:
114105
]
115106

116107
ret = [
117-
*(f" ├─ {name:<16} {stream}" for name, stream in self.inputs.items()),
108+
*(f" ├─ {stream}" for stream in self.inputs.values()),
118109
*_box(self.__class__.__name__),
119-
*(f" ├─ {name:<16} {stream}" for name, stream in self.outputs.items()),
110+
*(f" ├─ {stream}" for stream in self.outputs.values()),
120111
]
121112

122113
return "\n".join(ret)

dimos/core/test_core.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,10 @@ def test_deployment(dimos):
129129
nav = dimos.deploy(Navigation)
130130

131131
# this one encodes proper LCM messages
132-
robot.lidar.transport = LCMTransport("/lidar", LidarMessage)
133-
134-
# odometry using just a pickle over LCM
135-
robot.odometry.transport = pLCMTransport("/odom")
136-
137-
# this one uses default dask transport
138-
nav.mov.transport = pLCMTransport("/mov")
132+
# robot.lidar.transport = LCMTransport("/lidar", LidarMessage)
133+
# odometry & mov using just a pickle over LCM
134+
# robot.odometry.transport = pLCMTransport("/odom")
135+
# nav.mov.transport = pLCMTransport("/mov")
139136

140137
nav.lidar.connect(robot.lidar)
141138
nav.odometry.connect(robot.odometry)

0 commit comments

Comments
 (0)