-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
🕹️ CLI refactor #2380
base: main
Are you sure you want to change the base?
🕹️ CLI refactor #2380
Conversation
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
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.
If I understand correctly, we will need to move all example scripts from examples/scripts
to trl/scripts
right? I am wondering if this causes some downstream issues if people have linked their websites to examples/scripts
and whether it will be harder for people to find the scripts now since it's somewhat uncommon to include such objects in the package directly.
I agree that in general we want to have a robust CLI that isn't afflicted by all the symlink issues you've noted, but let's also see what @lvwerra thinks since him and Younes were the architects of that feature
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.
Yes, that's the main question. Sorry I didn't have time to go into detail about my thoughts in the original post (still under construction).
downstream issues if people have linked their websites
Right. The links wouldn't be dead in all cases, as files like https://github.com/huggingface/trl/blob/adac644f7fe1a5a37f9cca10044ed81b594eae32/examples/scripts/dpo.py would allow redirection.
As far as this point is concerned, I think refraining to move these files is a case of the snake biting its own tail, because the number of link will grow.
harder for people to find the scripts
Probably slightly harder yes.
I'd say these are the two main drawbacks (link issues and harder to find) to weigh in the balance.
uncommon to include such objects in the package directly
True, examples aren't included in the package. But I think here, it's more scripts that can be used as examples, rather than true examples. I think this mostly because:
- we have full argparsing support,
- they are used in the CLI.
What does this PR do?
Historically
The example scripts were initially placed outside the package directory (
.examples/scripts
) because they were not intended for runtime use. However, with the introduction of the TRL CLI in #1419, these scripts became executable at runtime through the CLI. Unfortunately, the scripts could not be directly imported from the package. To address this, we implemented a workaround insetuptools
by creating a symbolic link fromtrl/trl/commands
toexamples/scripts
.Motivations for this refactor
Recurrent issues with the simlink not properly created: trl CLI doesn't work #1716, Not find sft.py #1829 Fix dev install #2369 (comment)
Populating the CLI with new command isn't flexible [CLI] Extend training support to all trainers #2101 populate SUPPORTED_COMMANDS cli #2157
We implement our own parser based on
sys.argv
to have our own subparsing logic, whileargparse
have everything we need for subparsingWe don't have the usual parsing associated features like the help etc:
Building the package will soon not be possible because of the simlink to the examples, see Fix dev install #2369 (review)
Alternatives
Solution
Reference structure for the new CLI: https://github.com/qgallouedec/turbo-spoon
Why this solution?
From the setuptools user guide
Consequently, if we want to have access to the example with the CLI (at runtime then)
Before submitting
Pull Request section?
to it if that's the case.
documentation guidelines.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.