-
Notifications
You must be signed in to change notification settings - Fork 16.3k
Description
Description
I'm not sure how big this is, but I imagine this is small enough to not require an AIP.
Example of what this could look like:
from airflow.plugins_manager import AirflowPlugin
from airflow.cli.cli_config import (
ActionCommand,
GroupCommand,
)
def function():
print("Hello, world!")
class ExamplePlugin(AirflowPlugin):
name = "example"
cli_commands = [
GroupCommand(
name="example",
help="Example command from plugin",
description=(
"This runs all example commands"
),
subcommands=[
ActionCommand(
name="subcommand",
help="Run a subcommand",
func=function,
)
],
),
]Use case/motivation
The main motivation that comes to mind is Cosmos: https://github.com/astronomer/astronomer-cosmos Cosmos is a library that runs dbt in Airflow. dbt is a command-line tool that orchestrates, manages, and runs SQL queries. It would be a big quality-of-life upgrade if Cosmos were able to execute dbt commands with something like: airflow cosmos --project foo dbt run --select bar.
Right now many users struggle to execute dbt via the command line when it's configured for Airflow. I personally use a weird setup to execute one-off runs of dbt models that I expect many users would not know how to do themselves.
Some advantages for Cosmos, and more generally:
- Would hook easily into config configured in the user's Airflow instance.
- Could be used to execute one-off commands. This is a popular use case for dbt; many more savvy users already have an unscheduled parameterized DAG devoted to executing manual dbt commands. There are, however, many other commands that users might want to run directly from the CLI. E.g. imagine if something like the maintenance DAGs repo had a CLI.
Related issues
No response
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct