Replies: 1 comment
-
There is no option to configure this for now, but you can use the following "hack" (from mentioned issue): from typing import Optional
import typer
typer.main.get_command_name = lambda name: name # Override the name conversion function
def main(local_rank: Optional[int] = 0):
print(f"local_rank: {local_rank}")
# do fancy neural network stuff
if __name__ == "__main__":
typer.run(main) Note, it will also change naming convention for commands! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
First Check
Commit to Help
Example Code
Description
Hello everyone,
I'm currently using Typer for a project with neural networks. I'd like to start my main script using torch.distributed.launch, which passes the argument "local_rank" to the main script.
python main.py --local_rank=0
However, when doing so Typer complains that this option is unknown. That is due to the standardized conversion of "_" to "-". How can I make my script accept the CLI option "local_rank"?
There is an related issue #341 , however, this deals with command names. In this case, it is about argument names AND I can't influence the way they are passed to my script.
Operating System
Linux
Operating System Details
No response
Typer Version
0.12.5
Python Version
3.10.14
Additional Context
No response
Beta Was this translation helpful? Give feedback.
All reactions