Repository: apache/airflow

Issue:
Fix asset compilation in start-airflow
The recent change #29080 introduced missing black import in the pre-commit that run the compilation. The compilation happened in the background thread and it's ouptut was only visible in the asset_compilation output file

This PR fixes the black import problem by removing unnecessary import, but it will also stop start-airflow and exit with error as well as surface the output of asset compilation to the console.

<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.

Feel free to ping committers for the review!

In case of an existing issue, reference it using one of the following:

closes: #ISSUE
related: #ISSUE

How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->

---
**^ Add meaningful description above**

Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/CONTRIBUTING.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).



Discussion:
After this one is merged, errors in asset compilation in start-airflow will be visible like that:

<img width="949" alt="Screenshot 2023-01-26 at 22 10 21" src="https://user-images.githubusercontent.com/595491/214952206-8a590d0f-f6f9-449e-8f75-a0073e4aa51a.png">

Resolving patch:
diff --git a/dev/breeze/src/airflow_breeze/utils/path_utils.py b/dev/breeze/src/airflow_breeze/utils/path_utils.py
--- a/dev/breeze/src/airflow_breeze/utils/path_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/path_utils.py
@@ -266,6 +266,7 @@ def find_airflow_sources_root_to_operate_on() -> Path:
 WWW_CACHE_DIR = BUILD_CACHE_DIR / "www"
 WWW_ASSET_COMPILE_LOCK = WWW_CACHE_DIR / ".asset_compile.lock"
 WWW_ASSET_OUT_FILE = WWW_CACHE_DIR / "asset_compile.out"
+WWW_ASSET_OUT_DEV_MODE_FILE = WWW_CACHE_DIR / "asset_compile_dev_mode.out"
 DAGS_DIR = AIRFLOW_SOURCES_ROOT / "dags"
 FILES_DIR = AIRFLOW_SOURCES_ROOT / "files"
 HOOKS_DIR = AIRFLOW_SOURCES_ROOT / "hooks"
diff --git a/dev/breeze/src/airflow_breeze/utils/run_utils.py b/dev/breeze/src/airflow_breeze/utils/run_utils.py
--- a/dev/breeze/src/airflow_breeze/utils/run_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/run_utils.py
@@ -36,7 +36,12 @@
 from airflow_breeze.global_constants import APACHE_AIRFLOW_GITHUB_REPOSITORY
 from airflow_breeze.utils.ci_group import ci_group
 from airflow_breeze.utils.console import Output, get_console
-from airflow_breeze.utils.path_utils import AIRFLOW_SOURCES_ROOT, WWW_ASSET_COMPILE_LOCK, WWW_ASSET_OUT_FILE
+from airflow_breeze.utils.path_utils import (
+    AIRFLOW_SOURCES_ROOT,
+    WWW_ASSET_COMPILE_LOCK,
+    WWW_ASSET_OUT_DEV_MODE_FILE,
+    WWW_ASSET_OUT_FILE,
+)
 from airflow_breeze.utils.shared_options import get_dry_run, get_verbose
 
 RunCommandResult = Union[subprocess.CompletedProcess, subprocess.CalledProcessError]
@@ -460,7 +465,10 @@ def run_compile_www_assets(
         "--all-files",
         "--verbose",
     ]
-    get_console().print(f"[info] The output of the asset compilation is stored in: [/]{WWW_ASSET_OUT_FILE}\n")
+    get_console().print(
+        "[info]The output of the asset compilation is stored in: [/]"
+        f"{WWW_ASSET_OUT_DEV_MODE_FILE if dev else WWW_ASSET_OUT_FILE}\n"
+    )
     if run_in_background:
         thread = Thread(daemon=True, target=_run_compile_internally, args=(command_to_execute, dev))
         thread.start()
diff --git a/scripts/ci/pre_commit/pre_commit_compile_www_assets_dev.py b/scripts/ci/pre_commit/pre_commit_compile_www_assets_dev.py
--- a/scripts/ci/pre_commit/pre_commit_compile_www_assets_dev.py
+++ b/scripts/ci/pre_commit/pre_commit_compile_www_assets_dev.py
@@ -31,6 +31,7 @@
 WWW_CACHE_DIR = AIRFLOW_SOURCES_PATH / ".build" / "www"
 WWW_HASH_FILE = WWW_CACHE_DIR / "hash.txt"
 WWW_ASSET_OUT_FILE = WWW_CACHE_DIR / "asset_compile.out"
+WWW_ASSET_OUT_DEV_MODE_FILE = WWW_CACHE_DIR / "asset_compile_dev_mode.out"
 
 if __name__ == "__main__":
     www_directory = AIRFLOW_SOURCES_PATH / "airflow" / "www"
@@ -39,7 +40,11 @@
         WWW_HASH_FILE.unlink()
     env = os.environ.copy()
     env["FORCE_COLOR"] = "true"
-    with open(WWW_ASSET_OUT_FILE, "w") as f:
+    try:
+        WWW_ASSET_OUT_FILE.unlink()
+    except FileNotFoundError:
+        pass
+    with open(WWW_ASSET_OUT_DEV_MODE_FILE, "w") as f:
         subprocess.run(
             ["yarn", "install", "--frozen-lockfile"],
             cwd=os.fspath(www_directory),


Test patch: