Created
December 23, 2022 22:09
-
-
Save rnrbarbosa/bb0dc7e35575aeb53dba826aeb028b2c to your computer and use it in GitHub Desktop.
Hydra and Typer together
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hydra | |
import typer | |
@hydra.main(config_path='config.yaml') | |
def my_cli(config): | |
# Use Typer to define the individual commands and subcommands that your application accepts | |
@typer.command() | |
def command1(arg1: str, arg2: int): | |
# Do something with the arg1 and arg2 arguments | |
print(arg1, arg2) | |
@typer.command() | |
def command2(): | |
# Do something without any arguments | |
print("Doing something") | |
@command2.command() | |
def subcommand1(arg3: str): | |
# Do something with the arg3 argument | |
print(arg3) | |
@command2.command() | |
def subcommand2(arg4: int): | |
# Do something with the arg4 argument | |
print(arg4) | |
if __name__ == '__main__': | |
my_cli() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment