jscheffl commented on code in PR #45266:
URL: https://github.com/apache/airflow/pull/45266#discussion_r1899176386
##########
dev/breeze/src/airflow_breeze/commands/ci_image_commands.py:
##########
@@ -594,6 +595,87 @@ def run_verify_in_parallel(
)
+@ci_image.command(name="save")
+@option_python
+@option_platform_single
+@option_github_repository
+@option_verbose
+@option_ci_image_file_to_save
+@option_dry_run
+def save(
+ python: str,
+ platform: str,
+ github_repository: str,
+ image_file: Path | None,
+):
+ """Save CI image to a file."""
+ perform_environment_checks()
+ image_name = BuildCiParams(
+ python=python,
+ github_repository=github_repository,
+ ).airflow_image_name
+ with ci_group("Buildx disk usage"):
+ run_command(["docker", "buildx", "du", "--verbose"], check=False)
+ escaped_platform = platform.replace("/", "_")
+ if not image_file:
+ image_file =
Path(f"/tmp/ci-image-save-{escaped_platform}-{python}.tar")
+ get_console().print(f"[info]Saving Python CI image {image_name} to
{image_file}[/]")
+ result = run_command(["docker", "image", "save", "-o",
image_file.as_posix(), image_name], check=False)
+ if result.returncode != 0:
+ get_console().print(f"[error]Error when saving image:
{result.stdout}[/]")
+ sys.exit(result.returncode)
+
+
+@ci_image.command(name="load")
+@option_python
+@option_platform_single
+@option_github_repository
+@option_skip_image_file_deletion
+@option_verbose
+@option_ci_image_file_to_load
+@option_dry_run
+def load(
+ python: str,
+ platform: str,
+ github_repository: str,
+ image_file: Path | None,
+ skip_image_file_deletion: bool,
+):
+ """Load CI image from a file."""
+ perform_environment_checks()
+ build_ci_params = BuildCiParams(
+ python=python,
+ github_repository=github_repository,
+ )
+ escaped_platform = platform.replace("/", "_")
+ if not image_file:
+ image_file =
Path(f"/tmp/ci-image-save-{escaped_platform}-{python}.tar")
+ if not image_file.exists():
+ get_console().print(f"[error]The image {image_file} does not
exist.[/]")
+ sys.exit(1)
+ if not image_file.name.endswith(f"-{python}.tar"):
+ get_console().print(
+ f"[error]The image file {image_file} does not end with
'-{python}.tar'. Exiting.[/]"
+ )
+ sys.exit(1)
+ if not image_file.name.startswith(f"ci-image-save-{escaped_platform}"):
+ get_console().print(
+ f"[error]The image file {image_file} does not start with
'ci-image-save-{escaped_platform}'. "
+ f"Exiting.[/]"
+ )
+ sys.exit(1)
+ get_console().print(f"[info]Loading Python CI image from {image_file}[/]")
+ result = run_command(["docker", "image", "load", "-i",
image_file.as_posix()], check=False)
+ if result.returncode != 0:
+ get_console().print(f"[error]Error when loading image:
{result.stdout}[/]")
+ sys.exit(result.returncode)
+ if not skip_image_file_deletion:
+ get_console().print(f"[info]Deleting image file {image_file}[/]")
+ image_file.unlink()
+ run_command(["docker", "images", "-a"])
Review Comment:
At least on my local machien this generates a very long list - shall we make
this maybe only in verbose mode?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]