From 7c283a54a0892f5659e96a07bb7acff160d8a212 Mon Sep 17 00:00:00 2001 From: Jarek Potiuk Date: Sun, 5 Jun 2022 11:06:09 +0200 Subject: [PATCH] Add command to regenerate breeze command output images --- .gitignore | 4 + BREEZE.rst | 11 + .../configuration_and_maintenance_commands.py | 27 +- images/breeze/output-commands-hash.txt | 2 +- images/breeze/output-commands.svg | 364 +++++++++--------- .../output-regenerate-command-images.svg | 99 +++++ 6 files changed, 327 insertions(+), 180 deletions(-) create mode 100644 images/breeze/output-regenerate-command-images.svg diff --git a/.gitignore b/.gitignore index 9a00d53fa3bda..fe3d74aa2344a 100644 --- a/.gitignore +++ b/.gitignore @@ -225,3 +225,7 @@ licenses/LICENSES-ui.txt # Packaged breeze on Windows /breeze.exe + +# Generated out dir + +/out diff --git a/BREEZE.rst b/BREEZE.rst index b80db9c45356d..83d9ab0053690 100644 --- a/BREEZE.rst +++ b/BREEZE.rst @@ -435,6 +435,17 @@ of help of the commands only when they change. :width: 100% :alt: Breeze command-hash-export +Regenerating images for documentation +===================================== + +This documentation contains exported images with "help" of their commands and parameters. You can +regenerate all those images (which might be needed in case new version of rich is used) via +``regenerate-breeze-images`` command. + +.. image:: ./images/breeze/output-regenerate-command-images.svg + :width: 100% + :alt: Breeze regenerate-command-images + Starting complete Airflow installation ====================================== diff --git a/dev/breeze/src/airflow_breeze/commands/configuration_and_maintenance_commands.py b/dev/breeze/src/airflow_breeze/commands/configuration_and_maintenance_commands.py index 818ba49ee8b83..d4ca3bcf466ca 100644 --- a/dev/breeze/src/airflow_breeze/commands/configuration_and_maintenance_commands.py +++ b/dev/breeze/src/airflow_breeze/commands/configuration_and_maintenance_commands.py @@ -62,7 +62,7 @@ ) from airflow_breeze.utils.recording import output_file_for_recording from airflow_breeze.utils.reinstall import ask_to_reinstall_breeze, reinstall_breeze, warn_non_editable -from airflow_breeze.utils.run_utils import run_command +from airflow_breeze.utils.run_utils import assert_pre_commit_installed, run_command from airflow_breeze.utils.visuals import ASCIIART, ASCIIART_STYLE CONFIGURATION_AND_MAINTENANCE_COMMANDS = { @@ -75,6 +75,7 @@ "resource-check", "free-space", "fix-ownership", + "regenerate-command-images", "command-hash-export", "version", ], @@ -533,3 +534,27 @@ def remove_autogenerated_code(script_path: str): def backup(script_path_file: Path): shutil.copy(str(script_path_file), str(script_path_file) + ".bak") + + +@main.command(name="regenerate-command-images", help="Regenerate breeze command images.") +@option_verbose +@option_dry_run +def regenerate_command_images(verbose: bool, dry_run: bool): + assert_pre_commit_installed(verbose=verbose) + perform_environment_checks(verbose=verbose) + try: + (AIRFLOW_SOURCES_ROOT / "images" / "breeze" / "output-commands-hash.txt").unlink() + except FileNotFoundError: + # when we go to Python 3.8+ we can add missing_ok = True instead of try/except + pass + command_to_execute = [sys.executable, "-m", "pre_commit", 'run', 'update-breeze-file', '--all-files'] + env = os.environ.copy() + run_command( + command_to_execute, + verbose=verbose, + dry_run=dry_run, + check=False, + no_output_dump_on_exception=True, + text=True, + env=env, + ) diff --git a/images/breeze/output-commands-hash.txt b/images/breeze/output-commands-hash.txt index 4b5a2913c32d6..49639d7ffc29f 100644 --- a/images/breeze/output-commands-hash.txt +++ b/images/breeze/output-commands-hash.txt @@ -1 +1 @@ -5f6d42eb170dba8f19b375f8e7c588b3 +4741c257cb7cb98fd268d443cfa12135 diff --git a/images/breeze/output-commands.svg b/images/breeze/output-commands.svg index be4ea5a514d12..a592f4642e045 100644 --- a/images/breeze/output-commands.svg +++ b/images/breeze/output-commands.svg @@ -1,4 +1,4 @@ - + - - + + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + + - Breeze commands + Breeze commands - + - - -Usage: breeze [OPTIONS] COMMAND [ARGS]... - -╭─ Basic flags for the default (shell) command ────────────────────────────────────────────────────────────────────────╮ ---python-pPython major/minor version used in Airflow image for images.(>3.7< | 3.8 | 3.9 | 3.10) -[default: 3.7]                                               ---backend-bDatabase backend to use.(>sqlite< | mysql | postgres | mssql)[default: sqlite] ---postgres-version-PVersion of Postgres used.(>10< | 11 | 12 | 13 | 14)[default: 10] ---mysql-version-MVersion of MySQL used.(>5.7< | 8)[default: 5.7] ---mssql-version-SVersion of MsSQL used.(>2017-latest< | 2019-latest)[default: 2017-latest] ---integrationIntegration(s) to enable when running (can be more than one).                             -(cassandra | kerberos | mongo | openldap | pinot | rabbitmq | redis | statsd | trino |    -all)                                                                                      ---forward-credentials-fForward local credentials to container when running. ---db-reset-dReset DB when entering the container. -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─ Advanced flags for the default (shell) command ─────────────────────────────────────────────────────────────────────╮ ---use-airflow-versionUse (reinstall at entry) Airflow version from PyPI. It can also be `none`, `wheel`, or   -`sdist` if Airflow should be removed, installed from wheel packages or sdist packages    -available in dist folder respectively. Implies --mount-sources `none`.                   -(none | wheel | sdist | <airflow_version>)                                               ---airflow-extrasAirflow extras to install when --use-airflow-version is used(TEXT) ---use-packages-from-distInstall all found packages (--package-format determines type) from 'dist' folder when    -entering breeze.                                                                         ---package-formatFormat of packages that should be installed from dist.(wheel | sdist)[default: wheel] ---force-buildForce image build no matter if it is determined as needed. ---mount-sourcesChoose scope of local sources should be mounted (default = selected). -(selected | all | none)                                               -[default: selected]                                                   ---debian-versionDebian version used for the image.(bullseye | buster)[default: bullseye] -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ ---verbose-vPrint verbose information about performed steps. ---dry-run-DIf dry-run is set, commands are only printed, not executed. ---github-repository-gGitHub repository used to pull, push run images.(TEXT)[default: apache/airflow] ---answer-aForce answer to questions.(y | n | q | yes | no | quit) ---help-hShow this message and exit. -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─ Developer tools ────────────────────────────────────────────────────────────────────────────────────────────────────╮ -shell          Enter breeze.py environment. this is the default command use when no other is selected.             -start-airflow  Enter breeze.py environment and starts all Airflow components in the tmux session.                  -exec           Joins the interactive shell of running airflow container                                            -stop           Stop running breeze environment.                                                                    -build-docs     Build documentation in the container.                                                               -static-checks  Run static checks.                                                                                  -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─ Testing ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ -docker-compose-tests Run docker-compose tests.                                                                     -tests                Run the specified unit test targets. Multiple targets may be specified separated by spaces.   -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─ Configuration & maintenance ────────────────────────────────────────────────────────────────────────────────────────╮ -cleanup            Cleans the cache of parameters, docker cache and optionally - currently downloaded images.      -self-upgrade       Self upgrade Breeze.                                                                            -setup-autocomplete Enables autocompletion of breeze commands.                                                      -config             Show/update configuration (Python, Backend, Cheatsheet, ASCIIART).                              -resource-check     Check if available docker resources are enough.                                                 -free-space         Free space for jobs run in CI.                                                                  -fix-ownership      Fix ownership of source files to be same as host user.                                          -command-hash-exportOutputs hash of all click commands to file or stdout if `-` is used (useful to see if images    -should be regenerated).                                                                         -version            Print information about version of apache-airflow-breeze.                                       -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─ CI Image tools ─────────────────────────────────────────────────────────────────────────────────────────────────────╮ -build-image   Build CI image. Include building multiple images for all python versions (sequentially).             -pull-image    Pull and optionally verify CI images - possibly in parallel for all Python versions.                 -verify-image  Verify CI image.                                                                                     -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─ Production Image tools ─────────────────────────────────────────────────────────────────────────────────────────────╮ -build-prod-image Build Production image. Include building multiple images for all or selected Python versions      -sequentially.                                                                                     -pull-prod-image  Pull and optionally verify Production images - possibly in parallel for all Python versions.      -verify-prod-imageVerify Production image.                                                                          -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ -╭─ Release management ─────────────────────────────────────────────────────────────────────────────────────────────────╮ -verify-provider-packages         Verifies if all provider code is following expectations for providers.            -prepare-provider-documentation   Prepare CHANGELOG, README and COMMITS information for providers.                  -prepare-provider-packages        Prepare sdist/whl packages of Airflow Providers.                                  -prepare-airflow-package          Prepare sdist/whl package of Airflow.                                             -release-prod-images              Release production images to DockerHub (needs DockerHub permissions).             -generate-constraints             Generates pinned constraint files with all extras from setup.py in parallel.      -find-newer-dependencies          Finds which dependencies are being upgraded.                                      -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + +Usage: breeze [OPTIONS] COMMAND [ARGS]... + +╭─ Basic flags for the default (shell) command ────────────────────────────────────────────────────────────────────────╮ +--python-pPython major/minor version used in Airflow image for images.(>3.7< | 3.8 | 3.9 | 3.10) +[default: 3.7]                                               +--backend-bDatabase backend to use.(>sqlite< | mysql | postgres | mssql)[default: sqlite] +--postgres-version-PVersion of Postgres used.(>10< | 11 | 12 | 13 | 14)[default: 10] +--mysql-version-MVersion of MySQL used.(>5.7< | 8)[default: 5.7] +--mssql-version-SVersion of MsSQL used.(>2017-latest< | 2019-latest)[default: 2017-latest] +--integrationIntegration(s) to enable when running (can be more than one).                             +(cassandra | kerberos | mongo | openldap | pinot | rabbitmq | redis | statsd | trino |    +all)                                                                                      +--forward-credentials-fForward local credentials to container when running. +--db-reset-dReset DB when entering the container. +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ Advanced flags for the default (shell) command ─────────────────────────────────────────────────────────────────────╮ +--use-airflow-versionUse (reinstall at entry) Airflow version from PyPI. It can also be `none`, `wheel`, or   +`sdist` if Airflow should be removed, installed from wheel packages or sdist packages    +available in dist folder respectively. Implies --mount-sources `none`.                   +(none | wheel | sdist | <airflow_version>)                                               +--airflow-extrasAirflow extras to install when --use-airflow-version is used(TEXT) +--use-packages-from-distInstall all found packages (--package-format determines type) from 'dist' folder when    +entering breeze.                                                                         +--package-formatFormat of packages that should be installed from dist.(wheel | sdist)[default: wheel] +--force-buildForce image build no matter if it is determined as needed. +--mount-sourcesChoose scope of local sources should be mounted (default = selected). +(selected | all | none)                                               +[default: selected]                                                   +--debian-versionDebian version used for the image.(bullseye | buster)[default: bullseye] +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +--verbose-vPrint verbose information about performed steps. +--dry-run-DIf dry-run is set, commands are only printed, not executed. +--github-repository-gGitHub repository used to pull, push run images.(TEXT)[default: apache/airflow] +--answer-aForce answer to questions.(y | n | q | yes | no | quit) +--help-hShow this message and exit. +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ Developer tools ────────────────────────────────────────────────────────────────────────────────────────────────────╮ +shell          Enter breeze.py environment. this is the default command use when no other is selected.             +start-airflow  Enter breeze.py environment and starts all Airflow components in the tmux session.                  +exec           Joins the interactive shell of running airflow container                                            +stop           Stop running breeze environment.                                                                    +build-docs     Build documentation in the container.                                                               +static-checks  Run static checks.                                                                                  +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ Testing ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +docker-compose-tests Run docker-compose tests.                                                                     +tests                Run the specified unit test targets. Multiple targets may be specified separated by spaces.   +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ Configuration & maintenance ────────────────────────────────────────────────────────────────────────────────────────╮ +cleanup                  Cleans the cache of parameters, docker cache and optionally - currently downloaded        +images.                                                                                   +self-upgrade             Self upgrade Breeze.                                                                      +setup-autocomplete       Enables autocompletion of breeze commands.                                                +config                   Show/update configuration (Python, Backend, Cheatsheet, ASCIIART).                        +resource-check           Check if available docker resources are enough.                                           +free-space               Free space for jobs run in CI.                                                            +fix-ownership            Fix ownership of source files to be same as host user.                                    +regenerate-command-imagesRegenerate breeze command images.                                                         +command-hash-export      Outputs hash of all click commands to file or stdout if `-` is used (useful to see if     +images should be regenerated).                                                            +version                  Print information about version of apache-airflow-breeze.                                 +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ CI Image tools ─────────────────────────────────────────────────────────────────────────────────────────────────────╮ +build-image   Build CI image. Include building multiple images for all python versions (sequentially).             +pull-image    Pull and optionally verify CI images - possibly in parallel for all Python versions.                 +verify-image  Verify CI image.                                                                                     +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ Production Image tools ─────────────────────────────────────────────────────────────────────────────────────────────╮ +build-prod-image Build Production image. Include building multiple images for all or selected Python versions      +sequentially.                                                                                     +pull-prod-image  Pull and optionally verify Production images - possibly in parallel for all Python versions.      +verify-prod-imageVerify Production image.                                                                          +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ +╭─ Release management ─────────────────────────────────────────────────────────────────────────────────────────────────╮ +verify-provider-packages         Verifies if all provider code is following expectations for providers.            +prepare-provider-documentation   Prepare CHANGELOG, README and COMMITS information for providers.                  +prepare-provider-packages        Prepare sdist/whl packages of Airflow Providers.                                  +prepare-airflow-package          Prepare sdist/whl package of Airflow.                                             +release-prod-images              Release production images to DockerHub (needs DockerHub permissions).             +generate-constraints             Generates pinned constraint files with all extras from setup.py in parallel.      +find-newer-dependencies          Finds which dependencies are being upgraded.                                      +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ diff --git a/images/breeze/output-regenerate-command-images.svg b/images/breeze/output-regenerate-command-images.svg new file mode 100644 index 0000000000000..0842e64fa1da3 --- /dev/null +++ b/images/breeze/output-regenerate-command-images.svg @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Command: regenerate-command-images + + + + + + + + + + +Usage: breeze regenerate-command-images [OPTIONS] + +Regenerate breeze command images. + +╭─ Options ────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ +--verbose-vPrint verbose information about performed steps. +--dry-run-DIf dry-run is set, commands are only printed, not executed. +--help-hShow this message and exit. +╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ + + + +