Skip to content

Commit

Permalink
Fix --from-pr feature for image load and stabilize help (apache#45575)
Browse files Browse the repository at this point in the history
This is a follow-up after apache#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.
  • Loading branch information
potiuk authored Jan 11, 2025
1 parent 14f6622 commit 6844cce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions dev/breeze/src/airflow_breeze/commands/ci_image_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -679,9 +679,6 @@ def load(
else:
image_file_to_load = image_file_dir / image_file

if not image_file_to_load.exists():
get_console().print(f"[error]The image {image_file_to_load} does not exist.[/]")
sys.exit(1)
if not image_file_to_load.name.endswith(f"-{python}.tar"):
get_console().print(
f"[error]The image file {image_file_to_load} does not end with '-{python}.tar'. Exiting.[/]"
Expand All @@ -698,6 +695,11 @@ def load(
download_artifact_from_run_id(from_run, image_file_to_load, github_repository, github_token)
elif from_pr:
download_artifact_from_pr(from_pr, image_file_to_load, github_repository, github_token)

if not image_file_to_load.exists():
get_console().print(f"[error]The image {image_file_to_load} does not exist.[/]")
sys.exit(1)

get_console().print(f"[info]Loading Python CI image from {image_file_to_load}[/]")
result = run_command(["docker", "image", "load", "-i", image_file_to_load.as_posix()], check=False)
if result.returncode != 0:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,6 @@
readable=True,
path_type=Path,
),
default=tempfile.gettempdir(),
default=tempfile.gettempdir() if not generating_command_images() else "/tmp",
show_default=True,
)

0 comments on commit 6844cce

Please sign in to comment.