Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix applying tags in local development #1939

Merged
merged 1 commit into from
Jul 7, 2023
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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ linkcheck-docs: ## check broken links

hook/%: ## run post-build hooks for an image
python3 -m tagging.write_tags_file --short-image-name "$(notdir $@)" --tags-dir /tmp/jupyter/tags/ --owner "$(OWNER)" && \
python3 -m tagging.apply_tags --short-image-name "$(notdir $@)" --tags-dir /tmp/jupyter/tags/ --platform "$(shell uname -m)" --owner "$(OWNER)" && \
python3 -m tagging.write_manifest --short-image-name "$(notdir $@)" --hist-line-dir /tmp/jupyter/hist_lines/ --manifest-dir /tmp/jupyter/manifests/ --owner "$(OWNER)"
python3 -m tagging.write_manifest --short-image-name "$(notdir $@)" --hist-line-dir /tmp/jupyter/hist_lines/ --manifest-dir /tmp/jupyter/manifests/ --owner "$(OWNER)" && \
python3 -m tagging.apply_tags --short-image-name "$(notdir $@)" --tags-dir /tmp/jupyter/tags/ --platform "$(shell uname -m)" --owner "$(OWNER)"
Comment on lines +72 to +73
Copy link
Member Author

@mathbunnyru mathbunnyru Jul 7, 2023

Choose a reason for hiding this comment

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

@twalcari the order is important here, because apply_tags removes latest tag, when write_manifest needs it.

hook-all: $(foreach I, $(ALL_IMAGES), hook/$(I)) ## run post-build hooks for all images


Expand Down
5 changes: 4 additions & 1 deletion tagging/apply_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

import plumbum

from tagging.get_platform import unify_aarch64

docker = plumbum.local["docker"]

LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -55,7 +57,7 @@ def apply_tags(
"--platform",
required=True,
type=str,
choices=["x86_64", "aarch64"],
choices=["x86_64", "aarch64", "arm64"],
help="Image platform",
)
arg_parser.add_argument(
Expand All @@ -64,5 +66,6 @@ def apply_tags(
help="Owner of the image",
)
args = arg_parser.parse_args()
args.platform = unify_aarch64(args.platform)
Copy link
Member Author

Choose a reason for hiding this comment

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

M1/M2 Macs return arm64 (and not aarch64 as Linux), and I work on Mac, so I fixed this as well.


apply_tags(args.short_image_name, args.owner, args.tags_dir, args.platform)
10 changes: 7 additions & 3 deletions tagging/get_platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
ALL_PLATFORMS = {"x86_64", "aarch64"}


def get_platform() -> str:
machine = platform.machine()
def unify_aarch64(platform: str) -> str:
return {
"aarch64": "aarch64",
"arm64": "aarch64", # To support local building on aarch64 Macs
"x86_64": "x86_64",
}[machine]
}[platform]


def get_platform() -> str:
machine = platform.machine()
return unify_aarch64(machine)