Skip to content
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

feat: add support for external plugin config dataclasses #807

Merged
merged 6 commits into from
Mar 10, 2025

Conversation

bsprenger
Copy link
Contributor

What this does (✨ Feature)

Currently, the ChoiceRegistry-based config dataclasses only register config subclasses when they are imported. This means that to use an external environment or policy, you have to modify LeRobot’s repository—either by adding a new config class directly or by importing the external module in the training script. Such modifications limit the use of LeRobot as a library or framework.

This PR adds runtime support for loading external plugins/packages through the CLI. Now, by simply passing a CLI argument to load external plugins at runtime, the system automatically imports the plugin and registers its config classes. This decouples external extensions from LeRobot’s internal code, making it much easier to use LeRobot with our own environments or policies without modifying the training scripts! 🚀

How it was tested

See the test_plugin_loading.py tests added.

How to checkout & try? (for the reviewer)

Checkout this branch and run:

pytest -sx tests/configs/test_plugin_loading.py

The existing `ChoiceRegistry`-based config classes are limited by
requiring that all subclasses be imported in order to be registered.
This means that in order to use the LeRobot training scripts, any
external library that defines its own configs MUST be imported,
which requires modifications of this repos files.

In order to make the training scripts usable without modification,
this commit introduces CLI argument parsing to load external plugins
at runtime. This will import plugins and trigger registration of
externally defined config dataclasses with the base choice registry.
@imstevenpmwork imstevenpmwork added enhancement Suggestions for new features or improvements configuration Problems with configuration files or settings labels Mar 4, 2025
@aliberts aliberts mentioned this pull request Mar 8, 2025
Copy link
Collaborator

@aliberts aliberts left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@aliberts aliberts merged commit 05b5473 into huggingface:main Mar 10, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
configuration Problems with configuration files or settings enhancement Suggestions for new features or improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants