From 84ce1860cc84e0254f807ba83bdc7923d602b281 Mon Sep 17 00:00:00 2001 From: Lohith M <152604836+Lohith625@users.noreply.github.com> Date: Sat, 15 Nov 2025 13:57:58 +0530 Subject: [PATCH] [v3-1-test] Breeze: Automatically set CHOKIDAR_USEPOLLING for WSL users in --dev-mode (#57846) (#58080) * Docs: Add note for WSL users about CHOKIDAR_USEPOLLING for UI hot reloading (#57846) * Breeze: Automatically set CHOKIDAR_USEPOLLING for WSL users in --dev-mode (#57846) * Breeze: Automatically set CHOKIDAR_USEPOLLING for WSL users in --dev-mode (#57846) * Update dev/breeze/src/airflow_breeze/commands/developer_commands.py Co-authored-by: LIU ZHE YOU <68415893+jason810496@users.noreply.github.com> --------- (cherry picked from commit e2f31e9835130175dc9e6e488224fcc153685c75) Co-authored-by: Lohith M <152604836+Lohith625@users.noreply.github.com> Co-authored-by: LIU ZHE YOU <68415893+jason810496@users.noreply.github.com> --- dev/breeze/doc/images/output_build-docs.svg | 2 +- dev/breeze/doc/images/output_build-docs.txt | 2 +- .../doc/images/output_start-airflow.svg | 24 +++++++++----- .../doc/images/output_start-airflow.txt | 2 +- .../commands/developer_commands.py | 33 +++++++++++++++++-- .../commands/developer_commands_config.py | 4 +-- 6 files changed, 51 insertions(+), 16 deletions(-) diff --git a/dev/breeze/doc/images/output_build-docs.svg b/dev/breeze/doc/images/output_build-docs.svg index c441908dd962e..ee242c749039a 100644 --- a/dev/breeze/doc/images/output_build-docs.svg +++ b/dev/breeze/doc/images/output_build-docs.svg @@ -262,7 +262,7 @@ --github-repository-gGitHub repository used to pull, push run images.(TEXT)[default: apache/airflow] --builderBuildx builder used to perform `docker buildx build` commands.(TEXT) [default: autodetect]                                          ---distributions-listOptional, contains comma-separated list of package ids that are processed for              +--distributions-listOptional, contains space separated list of package ids that are processed for              documentation building, and document publishing. It is an easier alternative to adding     individual packages as arguments to every command. This overrides the packages passed as   arguments.                                                                                 diff --git a/dev/breeze/doc/images/output_build-docs.txt b/dev/breeze/doc/images/output_build-docs.txt index e05839d9dffda..7c465674b0f06 100644 --- a/dev/breeze/doc/images/output_build-docs.txt +++ b/dev/breeze/doc/images/output_build-docs.txt @@ -1 +1 @@ -e0f17f59eae9cb8c4a5a66762a9ba990 +e85cc9911cbd648287a9b2b6e4291edd diff --git a/dev/breeze/doc/images/output_start-airflow.svg b/dev/breeze/doc/images/output_start-airflow.svg index a7550f0bd01dd..0ae41ac2a1e2e 100644 --- a/dev/breeze/doc/images/output_start-airflow.svg +++ b/dev/breeze/doc/images/output_start-airflow.svg @@ -1,4 +1,4 @@ - + --debuggerDebugger to use for debugging Airflow components.(debugpy | pydevd-pycharm)[default: debugpy] ╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─ Common options ─────────────────────────────────────────────────────────────────────────────────────────────────────╮ ---answer-aForce answer to questions.(y | n | q | yes | no | quit) ---dry-run-DIf dry-run is set, commands are only printed, not executed. ---verbose-vPrint verbose information about performed steps. ---help-hShow this message and exit. -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +--create-all-rolesCreates all user roles for testing with FabAuthManager (viewer, user, op, admin).            +SimpleAuthManager always has all roles available.                                            +--answer-aForce answer to questions.(y | n | q | yes | no | quit) +--dry-run-DIf dry-run is set, commands are only printed, not executed. +--verbose-vPrint verbose information about performed steps. +--help-hShow this message and exit. +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ diff --git a/dev/breeze/doc/images/output_start-airflow.txt b/dev/breeze/doc/images/output_start-airflow.txt index 2714baae8ce18..f3298f2b35752 100644 --- a/dev/breeze/doc/images/output_start-airflow.txt +++ b/dev/breeze/doc/images/output_start-airflow.txt @@ -1 +1 @@ -8f41f727793efa5a6fad7382632b47e9 +a28b9a18b9364f00ca72c9906a1acf6b diff --git a/dev/breeze/src/airflow_breeze/commands/developer_commands.py b/dev/breeze/src/airflow_breeze/commands/developer_commands.py index dd7ab42c529bd..d248f95e6f2db 100644 --- a/dev/breeze/src/airflow_breeze/commands/developer_commands.py +++ b/dev/breeze/src/airflow_breeze/commands/developer_commands.py @@ -17,6 +17,7 @@ from __future__ import annotations import os +import platform import re import shlex import shutil @@ -129,6 +130,18 @@ CELERY_INTEGRATION = "celery" +def is_wsl() -> bool: + """Detect if we are running inside WSL.""" + if platform.system().lower() != "linux": + return False + try: + with open("/proc/version") as f: + version_info = f.read().lower() + return "microsoft" in version_info or "wsl" in version_info + except FileNotFoundError: + return False + + def _determine_constraint_branch_used(airflow_constraints_reference: str, use_airflow_version: str | None): """ Determine which constraints reference to use. @@ -503,6 +516,12 @@ def shell( "(mutually exclusive with --skip-assets-compilation).", is_flag=True, ) +@click.option( + "--create-all-roles", + help="Creates all user roles for testing with FabAuthManager (viewer, user, op, admin). " + "SimpleAuthManager always has all roles available.", + is_flag=True, +) @click.argument("extra-args", nargs=-1, type=click.UNPROCESSED) @option_airflow_constraints_location @option_airflow_constraints_mode_ci @@ -565,6 +584,7 @@ def start_airflow( debug_components: tuple[str, ...], debugger: str, dev_mode: bool, + create_all_roles: bool, docker_host: str | None, executor: str | None, extra_args: tuple, @@ -603,6 +623,14 @@ def start_airflow( "[warning]You cannot skip asset compilation in dev mode! Assets will be compiled!" ) skip_assets_compilation = True + + # Automatically enable file polling for hot reloading under WSL + if dev_mode and is_wsl(): + os.environ["CHOKIDAR_USEPOLLING"] = "true" + get_console().print( + "[info]Detected WSL environment. Automatically enabled CHOKIDAR_USEPOLLING for hot reloading." + ) + if use_airflow_version is None and not skip_assets_compilation: # Now with the /ui project, lets only do a static build of /www and focus on the /ui run_compile_ui_assets(dev=dev_mode, run_in_background=True, force_clean=False) @@ -637,6 +665,7 @@ def start_airflow( debugger=debugger, db_reset=db_reset, dev_mode=dev_mode, + create_all_roles=create_all_roles, docker_host=docker_host, executor=executor, extra_args=extra_args, @@ -718,7 +747,7 @@ def start_airflow( "--distributions-list", envvar="DISTRIBUTIONS_LIST", type=str, - help="Optional, contains comma-separated list of package ids that are processed for documentation " + help="Optional, contains space separated list of package ids that are processed for documentation " "building, and document publishing. It is an easier alternative to adding individual packages as" " arguments to every command. This overrides the packages passed as arguments.", ) @@ -777,7 +806,7 @@ def build_docs( f"\n[info]Populating provider list from DISTRIBUTIONS_LIST env as {distributions_list}" ) # Override doc_packages with values from DISTRIBUTIONS_LIST - docs_list_as_tuple = tuple(distributions_list.split(",")) + docs_list_as_tuple = tuple(distributions_list.split(" ")) if doc_packages and docs_list_as_tuple: get_console().print( f"[warning]Both package arguments and --distributions-list / DISTRIBUTIONS_LIST passed. " diff --git a/dev/breeze/src/airflow_breeze/commands/developer_commands_config.py b/dev/breeze/src/airflow_breeze/commands/developer_commands_config.py index 67ed4a81504dc..20696a4a76005 100644 --- a/dev/breeze/src/airflow_breeze/commands/developer_commands_config.py +++ b/dev/breeze/src/airflow_breeze/commands/developer_commands_config.py @@ -285,9 +285,7 @@ }, { "name": "Other options", - "options": [ - "--forward-credentials", - ], + "options": ["--forward-credentials", "--create-all-roles"], }, { "name": "Debugging options",