Skip to content

Commit 355ceca

Browse files
Michał Fąferekmfaferek93
authored andcommitted
fix(mosaico_integration): address Mosaico review feedback
- Replace git-clone+pin SDK install with mosaicolabs>=0.4.0 from PyPI. Release 0.4.0 (2026-04-21) is the first wheel shipping the futures subpackage correctly; the earlier packaging gap that forced the pin is resolved upstream. Bridge image drops ~100 MB. - Store captured_at_seconds (float) alongside captured_at_iso so the timestamp is range-queryable via QuerySequence().with_user_metadata("captured_at_seconds", gt=X). Mosaico metadata filters only support numeric types for range predicates; the ISO string stays for human-readable listing. - Update README SDK section and troubleshooting tip accordingly.
1 parent 2db4c97 commit 355ceca

4 files changed

Lines changed: 11 additions & 25 deletions

File tree

demos/mosaico_integration/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,9 @@ License-safe: mosaicod runs as the unmodified upstream Docker image. The bridge
6363
- 24/7 recording of the same four topics: ~6 GB/robot/day.
6464
- At ~5 confirmed faults/robot/day the catalog holds ~10 MB/robot/day.
6565

66-
## Mosaico SDK pin
66+
## Mosaico SDK
6767

68-
PR #368 (ROS adapters for the `futures` ontology) merged on 2026-04-13 as commit `b3867be`. We validated end-to-end against the PR while it was in draft; post-merge no demo-side change was required. The subsequent `mosaicolabs==0.3.2` PyPI wheel is missing the `futures` subpackage from the distributed artifact, so the bridge `Dockerfile` installs directly from the repo at `b3867be` until a packaging-fixed release ships. The notebook still needs `import mosaicolabs.models.futures.laser` at the top to register the ontology on the read side.
68+
The bridge and notebook both use `mosaicolabs>=0.4.0` from PyPI. Release 0.4.0 (2026-04-21) is the first wheel that includes the `futures` subpackage (`LaserScan` ontology) required by this demo. The notebook still needs `import mosaicolabs.models.futures.laser` at the top to register the ontology on the read side; Mosaico team is looking into whether a shorter top-level import will suffice in a future SDK release.
6969

7070
## Integration notes
7171

@@ -76,7 +76,7 @@ PR #368 (ROS adapters for the `futures` ontology) merged on 2026-04-13 as commit
7676

7777
## Troubleshooting
7878

79-
- `docker compose build bridge` fails the LaserScan sanity import → the pinned Mosaico commit is no longer fetchable or the source layout has moved. Update `MOSAICO_PIN` in `bridge/Dockerfile` to a current `main` commit that still contains `mosaicolabs/models/futures/laser.py`.
79+
- `docker compose build bridge` fails the LaserScan sanity import → the installed `mosaicolabs` wheel no longer ships the `futures.laser` module. Check the version constraint in `bridge/requirements.txt` and pin back to a known-good release.
8080
- Bridge logs `No entity owns bulk-data for fault X (probed N candidates)` → the post-fault timer has not fired yet. Wait a few seconds and re-trigger.
8181
- Notebook raises `No ontology registered with tag 'laser_scan'` → the ontology import cell was skipped; re-run it.
8282
- `docker compose pull mosaicod` is slow on first run → the upstream image is ~110 MB, distroless.

demos/mosaico_integration/bridge/Dockerfile

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,18 @@
77
# License-safe pattern: bridge is a separate Python process that talks
88
# the public Apache Arrow Flight protocol to an unmodified mosaicod
99
# Docker image. We do not link or modify mosaicod or its Rust crates.
10-
#
11-
# SDK pinning: PR #368 (ROS adapters for futures ontology, including
12-
# LaserScan) merged on 2026-04-13 as commit b3867be. The subsequent
13-
# mosaicolabs==0.3.2 PyPI wheel (2026-04-15) ships with the
14-
# `futures` subpackage missing from the wheel despite being in source
15-
# on main, so `pip install mosaicolabs==0.3.2` cannot import LaserScan.
16-
# We therefore install from the upstream repo at the PR #368 merge
17-
# commit until a PyPI release with correct packaging ships.
1810

1911
FROM python:3.11-slim
2012

2113
ENV PYTHONUNBUFFERED=1
2214
ENV PIP_NO_CACHE_DIR=1
2315
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
2416

25-
RUN apt-get update \
26-
&& apt-get install -y --no-install-recommends git ca-certificates \
27-
&& rm -rf /var/lib/apt/lists/*
28-
29-
ARG MOSAICO_REPO=https://github.com/mosaico-labs/mosaico.git
30-
ARG MOSAICO_PIN=b3867be
31-
RUN git clone "${MOSAICO_REPO}" /opt/mosaico \
32-
&& cd /opt/mosaico \
33-
&& git checkout "${MOSAICO_PIN}" \
34-
&& git rev-parse HEAD > /opt/mosaico/.pinned_sha
35-
3617
COPY requirements.txt /tmp/requirements.txt
37-
RUN pip install -r /tmp/requirements.txt \
38-
&& pip install /opt/mosaico/mosaico-sdk-py
18+
RUN pip install -r /tmp/requirements.txt
3919

4020
# Sanity check at build time: import the SDK and the LaserScan ontology
41-
# so we fail fast if a future pin regresses on what we need.
21+
# so we fail fast if the published wheel regresses on what we need.
4222
RUN python -c "from mosaicolabs import MosaicoClient; from mosaicolabs.ros_bridge import RosbagInjector, ROSInjectionConfig; from mosaicolabs.models.futures.laser import LaserScan; print('mosaicolabs SDK + LaserScan ontology import OK')"
4323

4424
WORKDIR /app

demos/mosaico_integration/bridge/bridge.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ def ingest_to_mosaico(bag_path: Path, fault: FaultEvent) -> Optional[str]:
337337
f"{SOURCE_DEMO}_{ROBOT_ID}_{fault.fault_code}"
338338
f"_{int(fault.timestamp_sec)}_{fault.event_id}"
339339
)
340+
# captured_at_seconds is stored as float so it can be used in Mosaico
341+
# QuerySequence().with_user_metadata(key, gt=X, lt=Y) range filters.
342+
# captured_at_iso is kept alongside it for human-readable inspection
343+
# in list_sequences() output.
340344
metadata = {
341345
"robot_id": ROBOT_ID,
342346
"fault_code": fault.fault_code,
@@ -345,6 +349,7 @@ def ingest_to_mosaico(bag_path: Path, fault: FaultEvent) -> Optional[str]:
345349
"fault_description": fault.description or "",
346350
"fault_status": fault.status,
347351
"reporting_sources": ",".join(fault.reporting_sources),
352+
"captured_at_seconds": float(fault.timestamp_sec),
348353
"captured_at_iso": datetime.fromtimestamp(
349354
fault.timestamp_sec, tz=timezone.utc
350355
).isoformat(),
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
httpx>=0.27,<0.30
2+
mosaicolabs>=0.4.0,<0.5

0 commit comments

Comments
 (0)