Skip to content

Commit

Permalink
Update recording of SVG output to rich-click 1.7.0 (apache#34941)
Browse files Browse the repository at this point in the history
  • Loading branch information
potiuk authored Oct 14, 2023
1 parent 91581c4 commit 5155e7f
Show file tree
Hide file tree
Showing 74 changed files with 2,203 additions and 2,342 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ repos:
^generated/provider_dependencies.json$
require_serial: true
pass_filenames: false
additional_dependencies: ['rich>=12.4.4', 'rich-click>=1.5', 'inputimeout', 'pyyaml', 'packaging']
additional_dependencies: ['rich>=12.4.4', 'rich-click>=1.7.0', 'inputimeout', 'pyyaml', 'packaging']
- id: check-example-dags-urls
name: Check that example dags url include provider versions
entry: ./scripts/ci/pre_commit/pre_commit_update_example_dags_paths.py
Expand Down
2 changes: 1 addition & 1 deletion dev/breeze/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ PLEASE DO NOT MODIFY THE HASH BELOW! IT IS AUTOMATICALLY UPDATED BY PRE-COMMIT.

---------------------------------------------------------------------------------------------------------

Package config hash: 782a39916ea95eedd0cd81f76c9dbf3bbb5cbdc5c03271621a8dd3805324ee6868fbead2b95ac653d9efea0225db85de46b17c6f0e3b07923c7d18de666d236e
Package config hash: 20d095e80d897b7c19f3eef96e0e6ceef4a7a0c0a9b82def7089ec962da64e1bd2ee20f02532fc2ef64137d86c045c340bc8038695f53d29aa72833cafe8b153

---------------------------------------------------------------------------------------------------------
4 changes: 2 additions & 2 deletions dev/breeze/setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ install_requires =
pyyaml
PyGithub
requests
rich>=12.6.0
rich-click>=1.5
rich>=13.6.0
rich-click>=1.7.0
gitpython
twine
wheel
Expand Down
33 changes: 20 additions & 13 deletions dev/breeze/src/airflow_breeze/utils/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@
import atexit
import os
import sys
from typing import TYPE_CHECKING

import rich
from copy import deepcopy
from typing import IO, TYPE_CHECKING

from airflow_breeze.utils.path_utils import in_autocomplete

Expand Down Expand Up @@ -51,20 +50,28 @@ def save_ouput_as_svg():
if help_console:
help_console.save_svg(path=path, title=title, unique_id=unique_id)

class RecordingConsole(rich.console.Console):
def __init__(self, **kwargs):
kwargs["force_terminal"] = True
kwargs["width"] = width_int
super().__init__(record=True, **kwargs)
global help_console
help_console = self

atexit.register(save_ouput_as_svg)
click.rich_click.MAX_WIDTH = width_int
click.formatting.FORCED_WIDTH = width_int - 2 # type: ignore[attr-defined]
click.rich_click.COLOR_SYSTEM = "standard"
# monkeypatch rich_click console to record help (rich_click does not allow passing extra args to console)
click.rich_click.Console = RecordingConsole # type: ignore[misc]
# monkeypatch rich_click console to record help
import rich_click

original_create_console = rich_click.rich_help_formatter.create_console

from rich_click import RichHelpConfiguration

def create_recording_console(config: RichHelpConfiguration, file: IO[str] | None = None) -> Console:
recording_config = deepcopy(config)
recording_config.width = width_int
recording_config.force_terminal = True
recording_console = original_create_console(recording_config, file)
recording_console.record = True
global help_console
help_console = recording_console
return recording_console

rich_click.rich_help_formatter.create_console = create_recording_console


output_file = os.environ.get("RECORD_BREEZE_OUTPUT_FILE")
Expand Down
114 changes: 57 additions & 57 deletions images/breeze/output-commands.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 41 additions & 44 deletions images/breeze/output_build-docs.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
36 changes: 18 additions & 18 deletions images/breeze/output_ci-image.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
178 changes: 89 additions & 89 deletions images/breeze/output_ci-image_build.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 39 additions & 39 deletions images/breeze/output_ci-image_pull.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 24 additions & 24 deletions images/breeze/output_ci-image_verify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 22 additions & 22 deletions images/breeze/output_ci.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 11 additions & 11 deletions images/breeze/output_ci_find-backtracking-candidates.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5155e7f

Please sign in to comment.