Skip to content

Commit

Permalink
Fix applying tags in local development (#1939)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathbunnyru authored Jul 7, 2023
1 parent 4f92f2c commit 3d1dfb0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
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)"
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)

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)

0 comments on commit 3d1dfb0

Please sign in to comment.