Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4223,9 +4223,9 @@ def publish_docs_to_s3(
docs_to_s3.publish_all_docs()
if stable_versions:
docs_to_s3.publish_stable_version_docs()
from airflow_breeze.utils.publish_docs_to_s3 import version_error
from airflow_breeze.utils.publish_docs_to_s3 import VersionError

if version_error:
if VersionError.has_any_error():
get_console().print(
"[error]There was an error with the version of the docs. "
"Please check the version in the docs and try again.[/]"
Expand Down
10 changes: 3 additions & 7 deletions dev/breeze/src/airflow_breeze/utils/ci_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
if TYPE_CHECKING:
from airflow_breeze.utils.parallel import Output

# only allow top-level group
_in_ci_group = False


def in_github_actions() -> bool:
"""
Expand All @@ -51,8 +48,7 @@ def ci_group(
For more information, see:
https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#grouping-log-lines
"""
global _in_ci_group
if _in_ci_group or skip_group_output():
if getattr(ci_group, "__in_ci_group__", False) or skip_group_output():
Comment on lines -54 to +51
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect @jscheffl! This is what I was suggesting

yield
return
if not in_github_actions():
Expand All @@ -63,7 +59,7 @@ def ci_group(
get_console(output=output).print(f"\n{title}\n")
yield
return
_in_ci_group = True
setattr(ci_group, "__in_ci_group__", True)
if not skip_printing_title:
if message_type is not None:
get_console().print(f"::group::[{message_type.value}]{title}[/]")
Expand All @@ -73,4 +69,4 @@ def ci_group(
yield
finally:
get_console().print("::endgroup::")
_in_ci_group = False
setattr(ci_group, "__in_ci_group__", False)
17 changes: 14 additions & 3 deletions dev/breeze/src/airflow_breeze/utils/publish_docs_to_s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,19 @@
s3_client = boto3.client("s3")
cloudfront_client = boto3.client("cloudfront")

version_error = False

class VersionError:
"""Class to track version errors during processing."""

version_error: bool = False

@staticmethod
def has_any_error() -> bool:
return VersionError.version_error

@staticmethod
def set_version_error(value: bool):
VersionError.version_error = value


def get_cloudfront_distribution(destination_location):
Expand Down Expand Up @@ -326,8 +338,7 @@ def get_latest_minor_versions(package_name: str, versions: list[str]) -> list[st
all_versions.append(Version(v))
except ValueError as e:
get_console().print(f"[error]Invalid version {v}: {e}\n")
global version_error
version_error = True
VersionError.set_version_error(True)
all_versions.sort(reverse=True)
minor_versions: list[str] = []
good_versions = []
Expand Down
11 changes: 5 additions & 6 deletions dev/breeze/src/airflow_breeze/utils/recording.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
if TYPE_CHECKING:
from rich.console import Console

help_console: Console | None = None

DEFAULT_COLUMNS = 129


Expand All @@ -39,6 +37,8 @@ def generating_command_images() -> bool:
def enable_recording_of_help_output(path: str, title: str | None, width: str | None, unique_id: str | None):
import rich_click as click

help_consoles: list[Console] = []

if not title:
title = "Breeze screenshot"
if not width:
Expand All @@ -47,8 +47,8 @@ def enable_recording_of_help_output(path: str, title: str | None, width: str | N
width_int = int(width)

def save_output_as_svg():
if help_console:
help_console.save_svg(path=path, title=title, unique_id=unique_id)
for console in help_consoles:
console.save_svg(path=path, title=title, unique_id=unique_id)

atexit.register(save_output_as_svg)
click.rich_click.MAX_WIDTH = width_int
Expand All @@ -67,8 +67,7 @@ def create_recording_console(config: RichHelpConfiguration, file: IO[str] | None
recording_config.force_terminal = True
recording_console = original_create_console(recording_config, file)
recording_console.record = True
global help_console
help_console = recording_console
help_consoles.append(recording_console)
return recording_console

rich_click.rich_help_formatter.create_console = create_recording_console
Expand Down
31 changes: 10 additions & 21 deletions dev/breeze/src/airflow_breeze/utils/shared_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,48 +22,37 @@
from airflow_breeze.utils.coertions import coerce_bool_value


def __get_default_bool_value(env_var: str) -> bool:
string_val = os.environ.get(env_var, "")
return coerce_bool_value(string_val)


__verbose_value: bool = __get_default_bool_value("VERBOSE")
class _SharedOptions:
verbose_value: bool = coerce_bool_value(os.environ.get("VERBOSE", ""))
dry_run_value: bool = coerce_bool_value(os.environ.get("DRY_RUN", ""))
forced_answer: str | None = None


def set_verbose(verbose: bool):
global __verbose_value
__verbose_value = verbose
_SharedOptions.verbose_value = verbose


def get_verbose(verbose_override: bool | None = None) -> bool:
if verbose_override is None:
return __verbose_value
return _SharedOptions.verbose_value
return verbose_override


__dry_run_value: bool = __get_default_bool_value("DRY_RUN")


def set_dry_run(dry_run: bool):
global __dry_run_value
__dry_run_value = dry_run
_SharedOptions.dry_run_value = dry_run


def get_dry_run(dry_run_override: bool | None = None) -> bool:
if dry_run_override is None:
return __dry_run_value
return _SharedOptions.dry_run_value
return dry_run_override


__forced_answer: str | None = None


def set_forced_answer(answer: str | None):
global __forced_answer
__forced_answer = answer
_SharedOptions.forced_answer = answer


def get_forced_answer(answer_override: str | None = None) -> str | None:
if answer_override is None:
return __forced_answer
return _SharedOptions.forced_answer
return answer_override
Loading