[Feature request] Parsing train's arguments from a list of strings
See original GitHub issueNow that rl-baselines3-zoo is a package and the train
function can be imported, I’d like to introduce the following feature
Current workflow
The learning is performed by calling a standalone python process such as:
python train.py <arguments>
Desired workflow
In an interactive programming environment such as jupyter notebooks I’d like it to behave as:
from rl_zoo3.train import train
argument_list: List[str] = [...]
train(argument_list)
This is possible because ArgumentParser’s method parse_args
accepts a list of strings as input for parsing.
Changes to be introduced
A simple change on the behaviour of the train
function should be enough, that is:
Option A:
rl_zoo3/train.py
import sys
def train(arguments_list: List[str] = sys.argv[1:]):
...
args = parser.parse_args(arguments_list)
Option B:
rl_zoo3/train.py:
def train(arguments_list: List[str]):
...
args = parser.parse_args(arguments_list)
train.py:
import sys
from rl_zoo3.train import train
if __name__ == "__main__": # noqa: C901
train(sys.argv[1:])
I’m more inclined to option B because it is much cleaner and straightforward to interpret what the program is doing.
Change purpose
When using jupyter notebook and the program raises an exception, the magic line %debug
is used to inspect the stack frame, executing python train.py <args>
forces us to use another method to live debug.
Final comments
All comments on why/why not the change should be done are always welcome. Also comments on how to improve my current workflow are welcome. Let me know if I can proceed with the PR.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (5 by maintainers)
Top GitHub Comments
Hello, you have actually a simple (slightly hacky solution), which allows you to do what you want:
so, different things: the zoo is not meant to be used from an interactive session (or only when debugging), if you need a more pythonic interface, you have the experiment manager and other utils available, or even SB3 api. Making the rl zoo a package was mainly to give access to the wrappers/callbacks/utils, and to be able to call the train/enjoy scripts from anywhere. I agree it’s not pretty but that’s only for debugging.