Skip to content

Conversation

@paul-nechifor
Copy link
Contributor

@paul-nechifor paul-nechifor commented Jan 23, 2026

  • Automatically updates dimos/robot/all_blueprints.py when you run pytest dimos/robot/test_all_blueprints_generation.py.
  • Locally, it writes the file and you have to git add to confirm. The test fails until you commit the changes.
  • In CI, it always fails if there are any differences.

@greptile-apps
Copy link

greptile-apps bot commented Jan 23, 2026

Greptile Overview

Greptile Summary

Implemented auto-generation of blueprint registry from codebase scanning. The PR introduces an AST-based scanner that discovers all blueprint definitions across the codebase and automatically generates the all_blueprints.py file, eliminating manual maintenance.

Key Changes:

  • Created test_all_blueprints_generation.py with AST parsing logic to scan for autoconnect() calls and blueprint methods
  • Converted all_blueprints.py to an auto-generated file with sorted blueprint/module dictionaries
  • Moved helper functions (get_blueprint_by_name, get_module_by_name) to new get_all_blueprints.py file
  • Renamed all blueprint variables to follow consistent naming convention (e.g., unitree_g1_*, unitree_go2_*, demo_*)
  • Made internal/intermediate blueprint variables private by prefixing with underscore
  • Cleaned up unused imports in several files

The auto-generation system scans Python files, identifies top-level variables assigned to autoconnect() calls or blueprint methods (excluding _ prefixed variables), and generates the registry. In CI, it validates the file is up-to-date; locally, it regenerates the file.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Well-structured refactoring that improves maintainability. The auto-generation logic is clean, uses AST parsing appropriately, handles edge cases, and includes proper CI validation. All variable renames follow a consistent pattern and the separation of concerns (data vs. functions) is appropriate.
  • No files require special attention

Important Files Changed

Filename Overview
dimos/robot/all_blueprints.py Converted to auto-generated file with sorted blueprint/module dictionaries, removed helper functions (moved to get_all_blueprints.py)
dimos/robot/get_all_blueprints.py New file containing helper functions for loading blueprints and modules by name
dimos/robot/test_all_blueprints_generation.py New test file that auto-generates all_blueprints.py by scanning codebase for blueprint variables using AST parsing
dimos/robot/unitree_webrtc/unitree_g1_blueprints.py Renamed all blueprint variables to use consistent unitree_g1_* prefix for auto-discovery, made internal variables private with _ prefix
dimos/robot/unitree_webrtc/unitree_go2_blueprints.py Renamed all blueprint variables to use consistent unitree_go2_* prefix for auto-discovery, made internal variables private with _ prefix

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant BP as Blueprint Files
    participant Test as test_all_blueprints_generation.py
    participant Gen as AST Scanner
    participant AB as all_blueprints.py
    participant CLI as dimos CLI
    participant Get as get_all_blueprints.py
    
    Note over Dev,AB: Auto-generation System
    Dev->>BP: Define blueprint variables<br/>(e.g., unitree_g1, demo_gps_nav)
    Dev->>Test: Run pytest
    Test->>Gen: Scan codebase with AST parsing
    Gen->>BP: Parse Python files
    Gen->>Gen: Find autoconnect() calls<br/>and blueprint methods
    Gen->>Gen: Extract variable names<br/>(skip _ prefixed)
    Gen->>Test: Return discovered blueprints
    Test->>AB: Generate/Update all_blueprints.py
    Test->>Test: Check for uncommitted changes
    
    Note over CLI,Get: Runtime Blueprint Loading
    CLI->>AB: Import all_blueprints dict
    CLI->>Get: Call get_blueprint_by_name(name)
    Get->>AB: Lookup blueprint path
    Get->>Get: Parse "module:attr" string
    Get->>BP: Dynamic import module
    Get->>CLI: Return ModuleBlueprintSet instance
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

No files reviewed, no comments

Edit Code Review Agent Settings | Greptile


try:
source = file_path.read_text(encoding="utf-8")
tree = ast.parse(source, filename=str(file_path))
Copy link
Member

@jeff-hykin jeff-hykin Jan 24, 2026

Choose a reason for hiding this comment

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

To me parsing and traversing the AST feels too far (e.g. over-engineered). On the receiving end "my blueprint isn't being included, but idk why?" would be some painful debugging of this black-magic. I think a KISS approach would be like pytest's naming scheme: if the file ends in "_blueprint.py" and, when imported, has a .blueprints list, use that. No AST autoconnect-detecting node-traversal.

Copy link
Member

@jeff-hykin jeff-hykin Jan 24, 2026

Choose a reason for hiding this comment

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

and instead of committing auto-generated code, and adding build step thats run on-commit, the simple "find _bluprints.py" could be done at runtime.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think a KISS approach would be like pytest's naming scheme: if the file ends in "_blueprint.py"

Yeah, that sounds great for locating the files. 👍

when imported, has a .blueprints list, use that. No AST autoconnect-detecting node-traversal.

The issue with doing it that way is that you have to import it, which imports all the modules. This would make test slower. But it could be acceptable because we probably have already imported everything when running the test suite. The only other issue would be that all blueprints would have to be importable in all situations, even when dependencies are missing...

and instead of committing auto-generated code, and adding build step thats run on-commit, the simple "find _bluprints.py" could be done at runtime.

Disagree with this because this then forces all modules to be imported on every run. The list of blueprints is intentionally listed as strings to be imported instead of actual imports because it's better to only import the blueprint you want to use.

Copy link
Member

@jeff-hykin jeff-hykin Jan 24, 2026

Choose a reason for hiding this comment

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

But it could be acceptable because we probably have already imported everything when running the test suite

We basically import everything just running dimos --help lol. Not that that is a good thing

Disagree with this because this then forces all modules to be imported on every run.

Ah that is a good point. I think I'll have a clean solution (prototype of lazy imports is tested and works) that avoid this but that probably won't be done for another week.
So in the meantime, AST it is I suppose.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We basically import everything just running dimos --help lol.

We import a lot when running --help. But there's so much more! :)

when imported, has a .blueprints list, use that. No AST autoconnect-detecting node-traversal.

Tried it, but it doesn't work for the RealSenseCamera module because it imports pyrealsense2 which is a system installed package. :(

@paul-nechifor paul-nechifor force-pushed the pauln-autogenerate-list-of-blueprints branch from 8aad8dc to 8543d7f Compare January 25, 2026 03:56
Copy link
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.

clear improvement imo, without viable alternative proposals? can collect wishlist for this long term

@paul-nechifor paul-nechifor merged commit 6b781a5 into dev Jan 25, 2026
14 checks passed
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.

4 participants