Skip to content

Commit 6844cce

Browse files
authored
Fix --from-pr feature for image load and stabilize help (#45575)
This is a follow-up after #45564 - it fixes the `--from-pr` and `--from-run` to work (it was failing with file does not exist). Also found out that gettempdir might return different directory depending on which is your designated tmp directory (for example in MacOS this is is a longer path in /var/.....) - so we have to force the default during help generation to always return "/tmp" so that the --help images do not change depending on which system you are and what your tmp directory is.
1 parent 14f6622 commit 6844cce

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

dev/breeze/src/airflow_breeze/commands/ci_image_commands.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -679,9 +679,6 @@ def load(
679679
else:
680680
image_file_to_load = image_file_dir / image_file
681681

682-
if not image_file_to_load.exists():
683-
get_console().print(f"[error]The image {image_file_to_load} does not exist.[/]")
684-
sys.exit(1)
685682
if not image_file_to_load.name.endswith(f"-{python}.tar"):
686683
get_console().print(
687684
f"[error]The image file {image_file_to_load} does not end with '-{python}.tar'. Exiting.[/]"
@@ -698,6 +695,11 @@ def load(
698695
download_artifact_from_run_id(from_run, image_file_to_load, github_repository, github_token)
699696
elif from_pr:
700697
download_artifact_from_pr(from_pr, image_file_to_load, github_repository, github_token)
698+
699+
if not image_file_to_load.exists():
700+
get_console().print(f"[error]The image {image_file_to_load} does not exist.[/]")
701+
sys.exit(1)
702+
701703
get_console().print(f"[info]Loading Python CI image from {image_file_to_load}[/]")
702704
result = run_command(["docker", "image", "load", "-i", image_file_to_load.as_posix()], check=False)
703705
if result.returncode != 0:

dev/breeze/src/airflow_breeze/commands/common_image_options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,6 @@
227227
readable=True,
228228
path_type=Path,
229229
),
230-
default=tempfile.gettempdir(),
230+
default=tempfile.gettempdir() if not generating_command_images() else "/tmp",
231231
show_default=True,
232232
)

0 commit comments

Comments
 (0)