I want to use Databricks asset bundles - I'd like to use `typer` as a CLI tool, but I have only been able to set it up with `argparse`. Argparse seems to be able to retrieve the arguments from the databricks task, but not typer.
I specified two entrypoints in my pyproject.toml
[tool.poetry.scripts]
mypackage_ep_typer = "my_package.entrypoint_typer:main"
mypackage_ep_argparse = "my_package.entrypoint_argparse:entrypoint_generic"
I'm able to use the asset bundles with an entrypoint to my ELTL applications with argparse as follows in the entrypoint_argparse.py:
def entrypoint_generic():
"""Execute the application."""
logger.info("Executing 'argparse' entrypoint...")
parser = argparse.ArgumentParser(description="My module.")
parser.add_argument(
"--applicationname",
help="The name of the application to execute.",
type=str,
required=True,
dest="applicationname",
)
args = parser.parse_args()
logger.info(f"{args.applicationname=}")
This one deploys and runs without any issues in the asset bundle's workflow task.
However, if I try the same with typer in entrypoint_typer.py, I cannot get it to work:
def main(
applicationname: Annotated[str, typer.Option(help="Application to execute.")]
):
"""Execute the application."""
logger.info("Executing 'typer' entrypoint...")
logger.info(f"{applicationname=}")
I can run typer locally:
> poetry run python -m typer .\entrypoint_typer.py run --applicationname MYAPPNAME
2024-11-06 xx:xx:xx - root - INFO - Executing 'typer' entrypoint...
2024-11-06 xx:xx:xx - root - INFO - applicationname='MYAPPNAME'
But when I try to deploy and run my asset bundle, I get this error when the workflow task tries to start:
TypeError: main() missing 1 required positional argument: 'applicationname'
But I can see the parameter in the UI...