Skip to content

Implement lazy loading #1519

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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

lukicdarkoo
Copy link

@lukicdarkoo lukicdarkoo commented Jul 16, 2025

What this does

Implements lazy loading for robots, cameras, and teleoperators, a feature proposed in #1367.

How it was tested

Installed lerobot-xarm and lerobot-teleop packages in editable mode (they are not published yet to pypi) and then:

python -m lerobot.teleoperate \
    --robot.type=lerobot_xarm \
    --robot.id=black \
    --teleop.type=lerobot_teleop \
    --fps=90

Note

Draccus doesn't really support lazy loading, so I had to be a little creative. If you have any way to make the implementation cleaner, please let me know.

UPDATE: In 6e40ce5 I changed how the device registration works. Now it will scan all packages that start with lerobot_ and try to register them. The advantages are:

  • A list of available devices will be shown in the CLI help (draccus will recognize all available devices)
  • A device doesn't need to be specified in arguments, it will be recognized even if specified in YAML
  • Simpler, fewer changes

@lukicdarkoo lukicdarkoo changed the title Implement lazzy loading Implement lazy loading Jul 16, 2025
@lukicdarkoo lukicdarkoo marked this pull request as ready for review July 16, 2025 13:35
@Copilot Copilot AI review requested due to automatic review settings July 16, 2025 13:35
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements lazy loading functionality for robots, cameras, and teleoperators to allow dynamic loading of external modules at runtime. The implementation addresses the limitation that Draccus doesn't natively support lazy loading by parsing command-line arguments and dynamically importing modules when their full module paths are specified.

Key changes:

  • Added dynamic module importing capability for robot, camera, and teleoperator configurations
  • Modified factory functions to handle full module path types with dynamic instantiation
  • Extended config classes to pre-import modules based on command-line arguments

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
src/lerobot/robots/config.py Added get_known_choices method to parse command-line args and import robot modules
src/lerobot/robots/utils.py Extended factory function to handle dynamic module path imports for robots
src/lerobot/cameras/configs.py Added get_known_choices method to parse command-line args and import camera modules
src/lerobot/cameras/utils.py Extended factory function to handle dynamic module path imports for cameras
src/lerobot/teleoperators/config.py Added get_known_choices method to parse command-line args and import teleoperator modules
src/lerobot/teleoperators/utils.py Extended factory function to handle dynamic module path imports for teleoperators
src/lerobot/teleoperate.py Minor import addition and removed debug print statements

lukicdarkoo and others added 7 commits July 17, 2025 10:37
@CarolinePascal CarolinePascal added enhancement Suggestions for new features or improvements robots Issues concerning robots HW interfaces teleoperators Everything related to teleoperators sensors Everything related to sensors labels Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Suggestions for new features or improvements robots Issues concerning robots HW interfaces sensors Everything related to sensors teleoperators Everything related to teleoperators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants