This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new c231f1174d Fix asset compilation in start-airflow (#29185)
c231f1174d is described below
commit c231f1174d67d05384832b75f6ca7c02f5fda73c
Author: Jarek Potiuk <[email protected]>
AuthorDate: Thu Jan 26 23:40:56 2023 +0100
Fix asset compilation in start-airflow (#29185)
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.
---
Dockerfile.ci | 9 +++++++++
dev/breeze/src/airflow_breeze/utils/run_utils.py | 12 +++++++++---
scripts/ci/pre_commit/pre_commit_compile_www_assets.py | 1 -
scripts/docker/entrypoint_ci.sh | 9 +++++++++
4 files changed, 27 insertions(+), 4 deletions(-)
diff --git a/Dockerfile.ci b/Dockerfile.ci
index 48f1c5e864..6511d8f776 100644
--- a/Dockerfile.ci
+++ b/Dockerfile.ci
@@ -623,6 +623,15 @@ If it does not complete soon, you might want to stop it
and remove file lock:
fi
done
fi
+ if [ -f "${AIRFLOW_SOURCES}/.build/www/asset_compile.out" ]; then
+ echo
+ echo "${COLOR_RED}The asset compilation failed. Exiting.${COLOR_RESET}"
+ echo
+ cat "${AIRFLOW_SOURCES}/.build/www/asset_compile.out"
+ rm "${AIRFLOW_SOURCES}/.build/www/asset_compile.out"
+ echo
+ exit 1
+ fi
}
if [[ ${SKIP_ENVIRONMENT_INITIALIZATION=} != "true" ]]; then
diff --git a/dev/breeze/src/airflow_breeze/utils/run_utils.py
b/dev/breeze/src/airflow_breeze/utils/run_utils.py
index 70cf89687e..a0af6c92ed 100644
--- a/dev/breeze/src/airflow_breeze/utils/run_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/run_utils.py
@@ -413,16 +413,22 @@ def _run_compile_internally(command_to_execute:
list[str], dev: bool) -> RunComm
pass
try:
with SoftFileLock(WWW_ASSET_COMPILE_LOCK, timeout=5):
- with open(WWW_ASSET_OUT_FILE, "w") as f:
- return run_command(
+ with open(WWW_ASSET_OUT_FILE, "w") as output_file:
+ result = run_command(
command_to_execute,
check=False,
no_output_dump_on_exception=True,
text=True,
env=env,
stderr=subprocess.STDOUT,
- stdout=f,
+ stdout=output_file,
)
+ if result.returncode == 0:
+ try:
+ WWW_ASSET_OUT_FILE.unlink()
+ except FileNotFoundError:
+ pass
+ return result
except Timeout:
get_console().print("[error]Another asset compilation is running.
Exiting[/]\n")
get_console().print("[warning]If you are sure there is no other
compilation,[/]")
diff --git a/scripts/ci/pre_commit/pre_commit_compile_www_assets.py
b/scripts/ci/pre_commit/pre_commit_compile_www_assets.py
index 4733a1460b..8c43f72fd2 100755
--- a/scripts/ci/pre_commit/pre_commit_compile_www_assets.py
+++ b/scripts/ci/pre_commit/pre_commit_compile_www_assets.py
@@ -24,7 +24,6 @@ from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.resolve())) # make sure
common_precommit_utils is imported
from common_precommit_utils import get_directory_hash # isort: skip # noqa
E402
-from common_precommit_black_utils import black_format # isort: skip # noqa
E402
AIRFLOW_SOURCES_PATH = Path(__file__).parents[3].resolve()
WWW_HASH_FILE = AIRFLOW_SOURCES_PATH / ".build" / "www" / "hash.txt"
diff --git a/scripts/docker/entrypoint_ci.sh b/scripts/docker/entrypoint_ci.sh
index 1d51a3a0b5..2e06d1d4ef 100755
--- a/scripts/docker/entrypoint_ci.sh
+++ b/scripts/docker/entrypoint_ci.sh
@@ -72,6 +72,15 @@ If it does not complete soon, you might want to stop it and
remove file lock:
fi
done
fi
+ if [ -f "${AIRFLOW_SOURCES}/.build/www/asset_compile.out" ]; then
+ echo
+ echo "${COLOR_RED}The asset compilation failed. Exiting.${COLOR_RESET}"
+ echo
+ cat "${AIRFLOW_SOURCES}/.build/www/asset_compile.out"
+ rm "${AIRFLOW_SOURCES}/.build/www/asset_compile.out"
+ echo
+ exit 1
+ fi
}
if [[ ${SKIP_ENVIRONMENT_INITIALIZATION=} != "true" ]]; then