Skip to content

refactor(core): memory2 for dtop#2004

Merged
aclauer merged 8 commits intodevfrom
andrew/refactor/memory2-for-dtop
May 8, 2026
Merged

refactor(core): memory2 for dtop#2004
aclauer merged 8 commits intodevfrom
andrew/refactor/memory2-for-dtop

Conversation

@aclauer
Copy link
Copy Markdown
Collaborator

@aclauer aclauer commented May 7, 2026

Problem

We want to plot metrics from dtop. Previously I saved the metrics to jsonl files and made a stand alone cli tool for the plotting, but a much better way is to just use memory2.

Closes DIM-XXX

Solution

Add streams for the metrics tracked by dtop and add them to a memory2 Sqlite store. By default, running dtop will not save the metrics. Pass dtop --log to save. It will create a default db at dtop_<date and time>.ignore.db. Then use that as you would normally with memory2.

Minor change: move legend for memory2 plots off of axis so data isn't covered.

Breaking Changes

dtop-plot no longer exists.

How to Test

terminal 1
dimos --replay --dtop run unitree-go2

terminal 2
dtop --log

from dimos.memory2.store.sqlite import SqliteStore
from dimos.memory2.vis.plot.plot import Plot

store = SqliteStore(path="dtop_20260507_122933.ignore.db")
Plot().add(store.stream("GO2Connection_pss"), label="GO2Connection").to_svg("memory.svg")
dtop_20260507_150323 ignore_cpu_percent Produces some nice plots, like this cpu usage on the Orin Nano memory As you can see, the memory usage of Go2 connection in replay has an issue.

Contributor License Agreement

  • I have read and approved the CLA.

@aclauer aclauer changed the title Andrew/refactor/memory2 for dtop refactor(core): memory2 for dtop May 7, 2026
@aclauer aclauer marked this pull request as ready for review May 7, 2026 22:59
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 7, 2026

Greptile Summary

Replaces the standalone dtop-plot JSONL-based tool with a memory2 SqliteStore integration inside dtop itself. Running dtop --log now creates a timestamped .ignore.db and records per-role, per-metric streams that can be visualised with the standard Plot API.

  • dtop.py: Swaps log_path/JSON writing for db_path/SqliteStore; streams are keyed by worker_{worker_id}_{metric} and coordinator_{metric}, avoiding the module-name collision issue from the previous JSONL path.
  • dtop_plot.py: Deleted; its [project.scripts] entry has been removed from pyproject.toml as well.
  • svg.py: Legend is moved to bbox_to_anchor=(1.02, 0.5) (outside the axes), and bbox_inches="tight" is added to savefig so the legend is captured in the saved SVG.

Confidence Score: 5/5

Safe to merge. The deleted dtop-plot entry point has been cleanly removed from pyproject.toml, stream naming uses worker_id as the unique key, and the legend/SVG changes are straightforward layout fixes.

All previously flagged issues (stale dtop-plot entry point in pyproject.toml, stream name collision) have been addressed in this revision. The new logging path is well-scoped and only activated with --log, leaving the default TUI behaviour unchanged.

No files require special attention.

Important Files Changed

Filename Overview
dimos/utils/cli/dtop.py Replaces JSONL file logging with memory2 SqliteStore; uses worker_id-keyed stream names and per-metric streams under a LOGGED_METRICS tuple.
dimos/memory2/vis/plot/svg.py Moves legend outside the axes and adds bbox_inches="tight" to savefig so the external legend is captured; no logic errors found.
dimos/utils/cli/dtop_plot.py File deleted; the standalone JSONL plotting tool is replaced by the general-purpose memory2 Plot API.
pyproject.toml Removes the dtop-plot entry point that pointed to the now-deleted module; no stale references remain.

Sequence Diagram

sequenceDiagram
    participant LCM as PickleLCM (bg thread)
    participant App as ResourceSpyApp
    participant Store as SqliteStore
    participant Stream as Stream[float]

    Note over App: dtop --log
    App->>Store: "SqliteStore(path=db_path)"
    App->>Store: start()
    LCM-->>App: _on_msg(msg)
    App->>App: _log_role("coordinator", coord, ts, None)
    App->>App: "_log_role("worker_{id}", worker, ts, modules)"
    loop each metric in LOGGED_METRICS
        App->>Store: stream(name, float)  [once per name]
        Store-->>App: Stream[float]
        App->>Stream: "append(val, ts=ts, tags=tags)"
    end
    Note over App: on_unmount
    App->>Store: stop()
Loading

Reviews (4): Last reviewed commit: "Fix mypy" | Re-trigger Greptile

Comment thread dimos/utils/cli/dtop.py Outdated
Comment thread dimos/utils/cli/dtop.py Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@aclauer aclauer marked this pull request as draft May 7, 2026 23:53
@aclauer aclauer marked this pull request as ready for review May 8, 2026 00:29
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 8, 2026

Want your agent to iterate on Greptile's feedback? Try greploops.

Copy link
Copy Markdown
Contributor

@leshy leshy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is great, question is how do we analize this data, we have this hacky jupyter notebook thing

md-babel-py run yourfile.md

executes code blocks, produces

https://github.com/dimensionalOS/dimos/blob/dev/docs/capabilities/memory/plot.md

so you can build an analysis, agents are pretty good at this. idk if we should have a template file that people can run, or docs, or realtime rendererr for rerun. memory2 has structures for realtime rerun rendering in place, just didn't write it yet

on where we store,

need to merge #1996
dimos run unitree-go2-memory runs go2 that auto-records all sensors

so it would make sense for dtop also to record into the same db? can see later how

@aclauer aclauer merged commit 28733c3 into dev May 8, 2026
5 checks passed
@aclauer aclauer deleted the andrew/refactor/memory2-for-dtop branch May 8, 2026 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants