Skip to content

Instantly share code, notes, and snippets.

@rnrbarbosa
Created December 23, 2022 22:09
Show Gist options
  • Save rnrbarbosa/bb0dc7e35575aeb53dba826aeb028b2c to your computer and use it in GitHub Desktop.
Save rnrbarbosa/bb0dc7e35575aeb53dba826aeb028b2c to your computer and use it in GitHub Desktop.
Hydra and Typer together
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