This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch v3-0-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-0-test by this push:
new 69127093fe5 [v3-0-test] Remove unnecessary noise from CI breeze's
output (#49952) (#49958)
69127093fe5 is described below
commit 69127093fe50b65641485310eeeb7e17445a6975
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Tue Apr 29 16:57:12 2025 +0200
[v3-0-test] Remove unnecessary noise from CI breeze's output (#49952)
(#49958)
CI tests with breeze are running with `--verbose` options in order to
get more diagnostics when things fail. However there were a few
commmands always executed at the end of every command in breeze which
did not add any value for diagnostics and only generated noise:
* id retrievals for users and groups
* fixing ownership
* checking for rootless docker
Those commmands are now silecenced with `quiet=True` of run_command,
and the command nicely handles the case where we also capture output
of such command.
(cherry picked from commit 36766d1f62c4d1047e13a8e41d4d040d26ee1b4b)
Co-authored-by: Jarek Potiuk <[email protected]>
---
dev/breeze/src/airflow_breeze/commands/ci_commands.py | 2 +-
dev/breeze/src/airflow_breeze/commands/developer_commands.py | 2 +-
dev/breeze/src/airflow_breeze/commands/testing_commands.py | 1 +
dev/breeze/src/airflow_breeze/utils/docker_command_utils.py | 7 +++++--
dev/breeze/src/airflow_breeze/utils/host_info_utils.py | 8 ++++++--
dev/breeze/src/airflow_breeze/utils/run_utils.py | 7 ++++++-
6 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/dev/breeze/src/airflow_breeze/commands/ci_commands.py
b/dev/breeze/src/airflow_breeze/commands/ci_commands.py
index 224aeb06fa3..18e76153b95 100644
--- a/dev/breeze/src/airflow_breeze/commands/ci_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/ci_commands.py
@@ -156,7 +156,7 @@ def fix_ownership(use_sudo: bool):
fix_ownership_without_docker()
sys.exit(0)
get_console().print("[info]Fixing ownership using docker.")
- fix_ownership_using_docker()
+ fix_ownership_using_docker(quiet=False)
# Always succeed
sys.exit(0)
diff --git a/dev/breeze/src/airflow_breeze/commands/developer_commands.py
b/dev/breeze/src/airflow_breeze/commands/developer_commands.py
index 67927a27883..a4885ce2657 100644
--- a/dev/breeze/src/airflow_breeze/commands/developer_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/developer_commands.py
@@ -1140,7 +1140,7 @@ def doctor(ctx):
shell_params.print_badge_info()
perform_environment_checks()
- fix_ownership_using_docker()
+ fix_ownership_using_docker(quiet=False)
given_answer = user_confirm("Are you sure with the removal of temporary
Python files and Python cache?")
if not get_dry_run() and given_answer == Answer.YES:
diff --git a/dev/breeze/src/airflow_breeze/commands/testing_commands.py
b/dev/breeze/src/airflow_breeze/commands/testing_commands.py
index 2992f445ca3..3670560d3f0 100644
--- a/dev/breeze/src/airflow_breeze/commands/testing_commands.py
+++ b/dev/breeze/src/airflow_breeze/commands/testing_commands.py
@@ -257,6 +257,7 @@ def _run_test(
check=False,
env=env,
verbose_override=False,
+ quiet=True,
)
remove_docker_networks(networks=[f"{compose_project_name}_default"])
return result.returncode, f"Test: {shell_params.test_type}"
diff --git a/dev/breeze/src/airflow_breeze/utils/docker_command_utils.py
b/dev/breeze/src/airflow_breeze/utils/docker_command_utils.py
index 5e3402931f5..990c5c70f87 100644
--- a/dev/breeze/src/airflow_breeze/utils/docker_command_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/docker_command_utils.py
@@ -561,7 +561,7 @@ OWNERSHIP_CLEANUP_DOCKER_TAG = (
)
-def fix_ownership_using_docker(quiet: bool = False):
+def fix_ownership_using_docker(quiet: bool = True):
if get_host_os() != "linux":
# no need to even attempt fixing ownership on MacOS/Windows
return
@@ -585,7 +585,7 @@ def fix_ownership_using_docker(quiet: bool = False):
OWNERSHIP_CLEANUP_DOCKER_TAG,
"/opt/airflow/scripts/in_container/run_fix_ownership.py",
]
- run_command(cmd, text=True, check=False, capture_output=quiet)
+ run_command(cmd, text=True, check=False, quiet=quiet)
def remove_docker_networks(networks: list[str] | None = None) -> None:
@@ -602,6 +602,7 @@ def remove_docker_networks(networks: list[str] | None =
None) -> None:
["docker", "network", "prune", "-f", "-a", "--filter",
"label=com.docker.compose.project=breeze"],
check=False,
stderr=DEVNULL,
+ quiet=True,
)
else:
for network in networks:
@@ -609,6 +610,7 @@ def remove_docker_networks(networks: list[str] | None =
None) -> None:
["docker", "network", "rm", network],
check=False,
stderr=DEVNULL,
+ quiet=True,
)
@@ -893,6 +895,7 @@ def is_docker_rootless() -> bool:
capture_output=True,
check=False,
text=True,
+ quiet=True,
)
if response.returncode == 0 and "rootless" in response.stdout.strip():
get_console().print("[info]Docker is running in rootless
mode.[/]\n")
diff --git a/dev/breeze/src/airflow_breeze/utils/host_info_utils.py
b/dev/breeze/src/airflow_breeze/utils/host_info_utils.py
index 00349831723..c273a94ab02 100644
--- a/dev/breeze/src/airflow_breeze/utils/host_info_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/host_info_utils.py
@@ -37,7 +37,9 @@ def get_host_user_id() -> str:
host_user_id = ""
os = get_host_os()
if os == "linux" or os == "darwin":
- host_user_id = run_command(cmd=["id", "-ur"], capture_output=True,
text=True).stdout.strip()
+ host_user_id = run_command(
+ cmd=["id", "-ur"], capture_output=True, text=True, quiet=True
+ ).stdout.strip()
return host_user_id
@@ -47,7 +49,9 @@ def get_host_group_id() -> str:
host_group_id = ""
os = get_host_os()
if os == "linux" or os == "darwin":
- host_group_id = run_command(cmd=["id", "-gr"], capture_output=True,
text=True).stdout.strip()
+ host_group_id = run_command(
+ cmd=["id", "-gr"], capture_output=True, text=True, quiet=True
+ ).stdout.strip()
return host_group_id
diff --git a/dev/breeze/src/airflow_breeze/utils/run_utils.py
b/dev/breeze/src/airflow_breeze/utils/run_utils.py
index b87524e9edb..a60b6cf6814 100644
--- a/dev/breeze/src/airflow_breeze/utils/run_utils.py
+++ b/dev/breeze/src/airflow_breeze/utils/run_utils.py
@@ -66,6 +66,7 @@ def run_command(
output_outside_the_group: bool = False,
verbose_override: bool | None = None,
dry_run_override: bool | None = None,
+ quiet: bool = False,
**kwargs,
) -> RunCommandResult:
"""
@@ -91,6 +92,7 @@ def run_command(
outside the "CI folded group" in CI - so that it is immediately
visible without unfolding.
:param verbose_override: override verbose parameter with the one specified
if not None.
:param dry_run_override: override dry_run parameter with the one specified
if not None.
+ :param quiet: if True, suppresses all output (including the command
itself) and runs it in
:param kwargs: kwargs passed to POpen
"""
@@ -136,7 +138,10 @@ def run_command(
kwargs["stderr"] = subprocess.STDOUT
command_to_print = " ".join(shlex.quote(c) for c in cmd) if
isinstance(cmd, list) else cmd
env_to_print = get_environments_to_print(env)
- if not get_verbose(verbose_override) and not get_dry_run(dry_run_override):
+ if not get_verbose(verbose_override) and not get_dry_run(dry_run_override)
or quiet:
+ if quiet and not kwargs.get("capture_output"):
+ kwargs["stdout"] = subprocess.DEVNULL
+ kwargs["stderr"] = subprocess.DEVNULL
return subprocess.run(cmd, input=input, check=check, env=cmd_env,
cwd=workdir, **kwargs)
with ci_group(title=f"Running command: {title}", message_type=None):
get_console(output=output).print(f"\n[info]Working directory
{workdir}\n")