import importlib import typer import sys from typing import List, Optional from typing_extensions import Annotated app = typer.Typer() def _load_recipe(dotted_path: str): sys.path.append(".") path, name = dotted_path.rsplit(".", 1) mod = importlib.import_module(path) return getattr(mod, name) @app.command() def reset(recipe: Annotated[str, typer.Option(...)]): mod = _load_recipe(recipe) mod.reset() @app.command() def show(recipe: Annotated[str, typer.Option(...)]): mod = _load_recipe(recipe) mod.show() @app.command() def run( recipe: Annotated[str, typer.Option(...)], input: Annotated[Optional[List[str]], typer.Option(...)] = None, ): mod = _load_recipe(recipe) for input_str in input: beaker, filename = input_str.split("=") mod.csv_to_beaker(filename, beaker) mod.run_once() if __name__ == "__main__": app()