Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a32358a
Prep for rewriting the Airflow CLI with Click
blag Apr 1, 2022
5d27b03
Convert db subcommand to use Click
blag Apr 1, 2022
ead0fcb
Convert webserver commands to use click
blag Mar 31, 2022
3119bff
Convert standalone commands to use click
blag Apr 1, 2022
f320d01
Convert scheduler commands to use click
blag Apr 2, 2022
a8a5be7
Convert triggerer commands to use click
blag Apr 2, 2022
7994c45
Convert sync-perm command to click and make tests compatible.
tirkarthi Apr 3, 2022
3dabb71
Match doc with original command.
tirkarthi Apr 3, 2022
0392107
Use local imports instead of toplevel imports to optimise startup time.
tirkarthi Apr 3, 2022
129c46e
Use local import instead of toplevel imports to optimise startup time.
tirkarthi Apr 3, 2022
10f29fa
Merge pull request #1486 from tirkarthi/fix-imports
blag Apr 5, 2022
8e87a07
Merge branch 'main' into convert-to-click-cli
blag Apr 5, 2022
71356ea
Use rich.print.
tirkarthi Apr 7, 2022
39cd62e
Add cheat_sheet module
hankehly Apr 12, 2022
b29cfb9
De-nest display_commands_index function
hankehly Apr 14, 2022
4bcaa30
Add click-compatible celery command
hankehly Apr 15, 2022
908a05a
Add click-compatible cheat-sheet command unit test (amended 2022-04-1…
hankehly Apr 14, 2022
dc319ab
Mark cli path existence as optional
hankehly Apr 17, 2022
d9b4c86
Add click compatible celery command unit test module
hankehly Apr 17, 2022
d5403f0
Merge pull request #1494 from hankehly/convert-cheat-sheet-to-click-cli
blag Apr 19, 2022
6b45a1a
Merge branch 'convert-to-click-cli' into convert-celery-to-click-cli
hankehly Apr 20, 2022
232bcb3
Apply suggestions from code review
hankehly Apr 26, 2022
487fe3a
Inline celery cli command click option definitions
hankehly Apr 27, 2022
7897723
Set click option metavars
hankehly Apr 29, 2022
13749d0
Port info command and unit tests to click
hankehly May 2, 2022
005131c
Merge pull request #1495 from hankehly/convert-celery-to-click-cli
blag Jun 1, 2022
a52d134
Merge pull request #1496 from hankehly/convert-info-to-click-cli
blag Jun 1, 2022
e989c58
Merge branch 'main' into convert-to-click-cli
blag Jun 2, 2022
eb0dd52
Merge remote-tracking branch 'origin/main' into convert-to-click-cli
blag Jun 6, 2022
3fdbfce
Fix a few more things
blag Jun 7, 2022
ba9078d
Add tests for new db subcommand
blag Jun 7, 2022
950bd16
Merge pull request #1485 from tirkarthi/cli-roles
blag Jun 7, 2022
f927b94
Convert version command to use click
blag Jun 7, 2022
8ea28a4
A few more fixups
blag Jun 7, 2022
62a84a3
Add tests for scheduler subcommand
blag Jun 7, 2022
bfe86e0
Add tests for triggerer subcommand
blag Jun 7, 2022
cd05719
Fixup the webserver command
blag Jun 8, 2022
c646748
Add tests for webserver subcommand
blag Jun 8, 2022
7512ec8
Merge remote-tracking branch 'origin/main' into convert-to-click-cli
blag Jun 8, 2022
dc98b37
Convert users command to use click
blag Jun 8, 2022
771262b
Add rich-click to dependencies
blag Jun 8, 2022
98fb365
Merge branch 'main' into convert-to-click-cli
blag Jun 8, 2022
62e7b11
Port jobs command and unit tests to click
hankehly Jun 13, 2022
572ffec
Add jobs group command epilog to help text
hankehly Jun 14, 2022
4d2502b
Move jobs-check epilog text to appropriate function
hankehly Jun 14, 2022
d39ec4e
Merge pull request #1498 from hankehly/convert-jobs-to-click-cli
blag Jun 15, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 105 additions & 0 deletions airflow/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,108 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
import os

import rich_click as click

from airflow import settings
from airflow.utils.cli import ColorMode
from airflow.utils.timezone import parse as parsedate

BUILD_DOCS = "BUILDING_AIRFLOW_DOCS" in os.environ

click_color = click.option(
'--color',
type=click.Choice({ColorMode.ON, ColorMode.OFF, ColorMode.AUTO}),
default=ColorMode.AUTO,
help="Do emit colored output (default: auto)",
)
click_conf = click.option(
'-c', '--conf', help="JSON string that gets pickled into the DagRun's conf attribute"
)
click_daemon = click.option(
"-D", "--daemon", 'daemon_', is_flag=True, help="Daemonize instead of running in the foreground"
)
click_dag_id = click.argument("dag_id", help="The id of the dag")
click_dag_id_opt = click.option("-d", "--dag-id", help="The id of the dag")
click_debug = click.option(
"-d", "--debug", is_flag=True, help="Use the server that ships with Flask in debug mode"
)
click_dry_run = click.option(
'-n',
'--dry-run',
is_flag=True,
default=False,
help="Perform a dry run for each task. Only renders Template Fields for each task, nothing else",
)
click_end_date = click.option(
"-e",
"--end-date",
type=parsedate,
help="Override end_date YYYY-MM-DD",
)
click_execution_date = click.argument("execution_date", help="The execution date of the DAG", type=parsedate)
click_execution_date_or_run_id = click.argument(
"execution_date_or_run_id", help="The execution_date of the DAG or run_id of the DAGRun"
)
click_log_file = click.option(
"-l",
"--log-file",
metavar="LOG_FILE",
type=click.Path(exists=False, dir_okay=False, writable=True),
help="Location of the log file",
)
click_output = click.option(
"-o",
"--output",
type=click.Choice(["table", "json", "yaml", "plain"]),
default="table",
help="Output format.",
)
click_pid = click.option("--pid", metavar="PID", type=click.Path(exists=False), help="PID file location")
click_start_date = click.option(
"-s",
"--start-date",
type=parsedate,
help="Override start_date YYYY-MM-DD",
)
click_stderr = click.option(
"--stderr",
metavar="STDERR",
type=click.Path(exists=False, dir_okay=False, writable=True),
help="Redirect stderr to this file",
)
click_stdout = click.option(
"--stdout",
metavar="STDOUT",
type=click.Path(exists=False, dir_okay=False, writable=True),
help="Redirect stdout to this file",
)
click_subdir = click.option(
"-S",
"--subdir",
default='[AIRFLOW_HOME]/dags' if BUILD_DOCS else settings.DAGS_FOLDER,
type=click.Path(),
help=(
"File location or directory from which to look for the dag. "
"Defaults to '[AIRFLOW_HOME]/dags' where [AIRFLOW_HOME] is the "
"value you set for 'AIRFLOW_HOME' config you set in 'airflow.cfg' "
),
)
click_task_id = click.argument("task_id", help="The id of the task")
click_task_regex = click.option(
"-t", "--task-regex", help="The regex to filter specific task_ids to backfill (optional)"
)
click_verbose = click.option(
'-v', '--verbose', is_flag=True, default=False, help="Make logging output more verbose"
)
click_yes = click.option(
'-y', '--yes', is_flag=True, default=False, help="Do not prompt to confirm. Use with care!"
)


# https://click.palletsprojects.com/en/8.1.x/documentation/#help-parameter-customization
@click.group(context_settings={'help_option_names': ['-h', '--help']})
@click.pass_context
def airflow_cmd(ctx):
pass
35 changes: 35 additions & 0 deletions airflow/cli/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

from airflow.cli import airflow_cmd
from airflow.cli.commands import celery # noqa: F401
from airflow.cli.commands import cheat_sheet # noqa: F401
from airflow.cli.commands import db # noqa: F401
from airflow.cli.commands import info # noqa: F401
from airflow.cli.commands import jobs # noqa: F401
from airflow.cli.commands import scheduler # noqa: F401
from airflow.cli.commands import standalone # noqa: F401
from airflow.cli.commands import sync_perm # noqa: F401
from airflow.cli.commands import triggerer # noqa: F401
from airflow.cli.commands import users # noqa: F401
from airflow.cli.commands import version # noqa: F401
from airflow.cli.commands import webserver # noqa: F401

if __name__ == '__main__':
airflow_cmd(obj={})
Loading