You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by po...@apache.org on 2021/05/20 13:41:33 UTC
[airflow] branch master updated: Produce less output from breeze
when VERBOSE_COMMANDS is set (#15970)
This is an automated email from the ASF dual-hosted git repository.
potiuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/master by this push:
new a51a100 Produce less output from breeze when VERBOSE_COMMANDS is set (#15970)
a51a100 is described below
commit a51a1001cb3b07dad81a7d794eee3b4d16a5120f
Author: Ash Berlin-Taylor <as...@firemirror.com>
AuthorDate: Thu May 20 14:41:12 2021 +0100
Produce less output from breeze when VERBOSE_COMMANDS is set (#15970)
The prepare_usage command was being called and setting variables to
produce the full usage text for all commands at start up -- and while
this isn't a problem for speed, it makes the output when running with `bash
-x`/`VERBOSE_COMMANDS` a **lot** longer.
This change delays creating the usage variables and formatted versions
until they are needed.
Net result when running this command:
```
bash -c 'exec 5>breeze-trace.log; export BASH_XTRACEFD=5; VERBOSE_COMMANDS=true VERBOSE=true ./breeze -n shell -- -c "true"'
```
Before 4500 lines, 204K of "trace" logs
```
❯ wc -lc breeze-trace.log
4528 204088 breeze-trace.log
```
After is 1/4 as much output:
```
❯ wc -lc breeze-trace-with-change.log
1402 68167 breeze-trace-with-change.log
```
---
breeze | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/breeze b/breeze
index 69dbf29..036c7ae 100755
--- a/breeze
+++ b/breeze
@@ -1523,6 +1523,12 @@ function breeze::parse_arguments() {
#
#######################################################################################################
function breeze::prepare_formatted_versions() {
+ if [[ -n "${_breeze_formatted_versions_prepared:-}" ]]; then
+ return
+ fi
+
+ _breeze_formatted_versions_prepared=1
+
local indent=15
local list_prefix
list_prefix=$(printf "%-${indent}s" " ")
@@ -1628,6 +1634,14 @@ function breeze::prepare_formatted_versions() {
# shellcheck disable=SC2034,SC2090,SC2089,SC2155
function breeze::prepare_usage() {
+ if [[ -n "${_breeze_usage_prepared:-}" ]]; then
+ return
+ fi
+
+ _breeze_usage_prepared=1
+
+ breeze::prepare_formatted_versions
+
# Note that MacOS uses Bash 3.* and we cannot use associative arrays
export USAGE_SHELL="[Default] Enters interactive shell in the container"
readonly USAGE_SHELL
@@ -2129,6 +2143,7 @@ function breeze::get_variable_from_lowercase_name() {
# usage information for the command.
#######################################################################################################
function breeze::get_usage() {
+ breeze::prepare_usage
breeze::get_variable_from_lowercase_name "USAGE" "${1}"
}
@@ -2141,6 +2156,7 @@ function breeze::get_usage() {
# Detailed usage information for the command.
#######################################################################################################
function breeze::get_detailed_usage() {
+ breeze::prepare_usage
breeze::get_variable_from_lowercase_name "DETAILED_USAGE" "${1}"
}
@@ -2158,6 +2174,7 @@ function breeze::get_detailed_usage() {
# General usage information for all commands.
#######################################################################################################
function breeze::usage() {
+ breeze::prepare_usage
echo "
usage: ${CMDNAME} [FLAGS] [COMMAND] -- <EXTRA_ARGS>
@@ -2892,6 +2909,8 @@ ${FORMATTED_TEST_TYPES}
# Flag information.
#######################################################################################################
function breeze::flags() {
+ breeze::prepare_formatted_versions
+
echo "
$(breeze::print_line)
@@ -3632,10 +3651,6 @@ start_end::script_start
traps::add_trap start_end::script_end EXIT
-breeze::prepare_formatted_versions
-
-breeze::prepare_usage
-
set +u
breeze::parse_arguments "${@}"