brentyi / tyro

CLI interfaces & config objects, from types
https://brentyi.github.io/tyro
MIT License
467 stars 23 forks source link

Mimic comand line interface on the script #144

Closed PoyrazTahan closed 3 months ago

PoyrazTahan commented 3 months ago

Hey Team, Great work!

Is there a way to provide fixed input to tyro client. I am trying to debug in jupyter environment but could't get tyro working with subprocess.

Any suggestions on how can I provide manual input from the code for debug purposes?

brentyi commented 3 months ago

Hi Poyraz, thanks for the nice words!

Since tyro.cli() just takes normal Python objects as input, it seems like you can just import these and call them directly?

For this example: https://github.com/brentyi/tyro/blob/main/examples/01_basics/01_functions.py you could run

from 01_functions import main
main(...)

directly from a notebook.

PoyrazTahan commented 3 months ago

Hey @brentyi super fast response so thank you.

But what I was looking for was actually this

config = tyro.cli(
        BaseConfig,
        args=['arg1','arg1'],
    )

equivalent to argparse.ArgumentParser.parse_args(['arg1','arg2'])

which I found from your perfect documentation. Noting it down for future request and closing the issue