-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
base: main
Are you sure you want to change the base?
Implement lazy loading #1519
Conversation
There was a problem hiding this 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 |
Co-authored-by: Copilot <[email protected]> Signed-off-by: Darko Lukić <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: Darko Lukić <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: Darko Lukić <[email protected]>
Co-authored-by: Copilot <[email protected]> Signed-off-by: Darko Lukić <[email protected]>
Signed-off-by: Darko Lukić <[email protected]>
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:
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: