Skip to content

Commit a7b0154

Browse files
authored
Merge branch 'main' into python3.13
2 parents b433445 + 58649f1 commit a7b0154

File tree

9 files changed

+86
-47
lines changed

9 files changed

+86
-47
lines changed

.github/workflows/contributed-recipes.yml

+29-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Test the contributed recipes
22

3+
env:
4+
REGISTRY: quay.io
5+
OWNER: ${{ github.repository_owner }}
6+
37
on:
48
schedule:
59
# Images are rebuilt at 03:00 on Monday UTC
@@ -61,8 +65,31 @@ jobs:
6165
variant: default
6266

6367
# Not pulling the image, because it might be loaded from previous step or will be downloaded automatically
64-
- name: Build recipe 🛠
65-
run: docker build --rm --force-rm --tag my-custom-image -f ./${{ matrix.dockerfile }} ./
68+
- name: Build recipe with parent image 🛠
69+
if: ${{ matrix.parent-image != '' }}
70+
run: |
71+
docker build \
72+
--rm --force-rm \
73+
--tag my-custom-image \
74+
-f ./${{ matrix.dockerfile }} \
75+
--build-arg BASE_IMAGE=${{ env.REGISTRY }}/${{ env.OWNER }}/${{ matrix.parent-image }} \
76+
./
77+
env:
78+
DOCKER_BUILDKIT: 1
79+
# Full logs for CI build
80+
BUILDKIT_PROGRESS: plain
81+
working-directory: docs/using/recipe_code
82+
shell: bash
83+
84+
# Not pulling the image, because it might be loaded from previous step or will be downloaded automatically
85+
- name: Build recipe without parent image 🛠
86+
if: ${{ matrix.parent-image == '' }}
87+
run: |
88+
docker build \
89+
--rm --force-rm \
90+
--tag my-custom-image \
91+
-f ./${{ matrix.dockerfile }} \
92+
./
6693
env:
6794
DOCKER_BUILDKIT: 1
6895
# Full logs for CI build

.github/workflows/docker.yml

+12-10
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,16 @@ jobs:
336336
needs: x86_64-pyspark
337337
if: ${{ !contains(github.event.pull_request.title, '[FAST_BUILD]') }}
338338

339+
contributed-recipes:
340+
uses: ./.github/workflows/contributed-recipes.yml
341+
with:
342+
called-using-workflow-call: true
343+
# Contributed recipes only use these images
344+
# If recipes using other images will be added, they should be added here as well
345+
#
346+
# contributed-recipes will give an error if the image is not yet built and uploaded
347+
needs: [aarch64-base, x86_64-base, aarch64-minimal, x86_64-minimal]
348+
339349
tag-push:
340350
uses: ./.github/workflows/docker-tag-push.yml
341351
with:
@@ -370,6 +380,8 @@ jobs:
370380
variant: cuda12
371381
needs:
372382
[
383+
contributed-recipes,
384+
373385
aarch64-foundation,
374386
aarch64-base,
375387
aarch64-minimal,
@@ -425,13 +437,3 @@ jobs:
425437
uses: ./.github/workflows/docker-wiki-update.yml
426438
needs: tag-push-fast
427439
if: contains(github.event.pull_request.title, '[FAST_BUILD]')
428-
429-
contributed-recipes:
430-
uses: ./.github/workflows/contributed-recipes.yml
431-
with:
432-
called-using-workflow-call: true
433-
# Contributed recipes only use these images
434-
# If recipes using other images will be added, they should be added here as well
435-
#
436-
# contributed-recipes will give an error if the image is not yet built and uploaded
437-
needs: [aarch64-base, x86_64-base, aarch64-minimal, x86_64-minimal]

.pre-commit-config.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ repos:
4545
"numpy",
4646
"pytest",
4747
"requests",
48+
"tenacity",
4849
"urllib3",
4950
"types-beautifulsoup4",
5051
"types-python-dateutil",
@@ -98,7 +99,7 @@ repos:
9899

99100
# Lint: YAML
100101
- repo: https://github.com/adrienverge/yamllint
101-
rev: v1.35.1
102+
rev: v1.37.0
102103
hooks:
103104
- id: yamllint
104105
args: ["-d {extends: relaxed, rules: {line-length: disable}}", "-s"]
@@ -119,7 +120,7 @@ repos:
119120

120121
# Lint: Python
121122
- repo: https://github.com/PyCQA/flake8
122-
rev: 7.1.2
123+
rev: 7.2.0
123124
hooks:
124125
- id: flake8
125126

docs/using/custom-images.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Our repository provides several customization points:
2020
- `REGISTRY`, `OWNER`, `BASE_IMAGE` (docker arguments) - they allow to specify parent image for all the other images
2121
- `REGISTRY`, `OWNER` (part of `env` in some GitHub workflows) - these allow to properly tag and refer to images during following steps:
2222
- [`build-test-upload`](https://github.com/jupyter/docker-stacks/blob/main/.github/workflows/docker-build-test-upload.yml)
23+
- [`contributed-recipes`](https://github.com/jupyter/docker-stacks/blob/main/.github/workflows/contributed-recipes.yml)
2324
- [`tag-push`](https://github.com/jupyter/docker-stacks/blob/main/.github/workflows/docker-tag-push.yml)
2425

2526
These customization points can't be changed during runtime.

images/docker-stacks-foundation/Dockerfile

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ RUN set -x && \
131131
# Pin major.minor version of python
132132
# https://conda.io/projects/conda/en/latest/user-guide/tasks/manage-pkgs.html#preventing-packages-from-updating-pinning
133133
mamba list --full-name 'python' | awk 'END{sub("[^.]*$", "*", $2); print $1 " " $2}' >> "${CONDA_DIR}/conda-meta/pinned" && \
134+
# Temporarily pin libxml2 to avoid ABI breakage
135+
# https://github.com/conda-forge/libxml2-feedstock/issues/145
136+
echo 'libxml2<2.14.0' >> /opt/conda/conda-meta/pinned && \
134137
mamba clean --all -f -y && \
135138
fix-permissions "${CONDA_DIR}" && \
136139
fix-permissions "/home/${NB_USER}"

images/tensorflow-notebook/cuda/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ RUN mamba install --yes \
1919

2020
# Install TensorFlow, CUDA and cuDNN with pip
2121
RUN pip install --no-cache-dir \
22-
"tensorflow[and-cuda]<=2.17.1" && \
22+
'tensorflow[and-cuda]' && \
2323
fix-permissions "${CONDA_DIR}" && \
2424
fix-permissions "/home/${NB_USER}"
2525

requirements-dev.txt

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ pytest-xdist
99
python-dateutil
1010
requests
1111
tabulate
12+
tenacity

tagging/apps/merge_tags.py

+29-32
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
# Distributed under the terms of the Modified BSD License.
44
import logging
55
import os
6-
import time
7-
from collections.abc import Callable
86

97
import plumbum
8+
from tenacity import ( # type: ignore
9+
RetryError,
10+
retry,
11+
stop_after_attempt,
12+
wait_exponential,
13+
)
1014

1115
from tagging.apps.common_cli_arguments import common_arguments_parser
1216
from tagging.apps.config import Config
@@ -44,20 +48,11 @@ def read_local_tags_from_files(config: Config) -> tuple[list[str], set[str]]:
4448
return all_local_tags, merged_local_tags
4549

4650

47-
def run_with_retries(func: Callable[[], None]) -> None:
48-
ATTEMPTS = 3
49-
SLEEP_BACKOFF = 2
50-
51-
for attempt in range(ATTEMPTS):
52-
try:
53-
func()
54-
break
55-
except Exception as e:
56-
LOGGER.warning(f"Attempt {attempt + 1} failed: {e}")
57-
if attempt + 1 == ATTEMPTS:
58-
LOGGER.error(f"Failed after {ATTEMPTS} attempts")
59-
raise
60-
time.sleep(SLEEP_BACKOFF * (attempt + 1))
51+
@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4))
52+
def pull_tag(tag: str) -> None:
53+
LOGGER.info(f"Pulling tag: {tag}")
54+
docker["pull", tag] & plumbum.FG
55+
LOGGER.info(f"Tag {tag} pulled successfully")
6156

6257

6358
def pull_missing_tags(merged_tag: str, all_local_tags: list[str]) -> list[str]:
@@ -74,27 +69,35 @@ def pull_missing_tags(merged_tag: str, all_local_tags: list[str]) -> list[str]:
7469

7570
LOGGER.warning(f"Trying to pull: {platform_tag} from registry")
7671
try:
77-
run_with_retries(lambda: docker["pull", platform_tag] & plumbum.FG)
72+
pull_tag(platform_tag)
7873
existing_platform_tags.append(platform_tag)
7974
LOGGER.info(f"Tag {platform_tag} pulled successfully")
80-
except plumbum.ProcessExecutionError:
75+
except RetryError:
8176
LOGGER.warning(f"Pull failed, tag {platform_tag} doesn't exist")
8277

8378
return existing_platform_tags
8479

8580

86-
def push_manifest(merged_tag: str, existing_platform_tags: list[str]) -> None:
81+
@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4))
82+
def create_manifest(merged_tag: str, existing_platform_tags: list[str]) -> None:
83+
# This allows to rerun the script without having to remove the manifest manually
84+
try:
85+
docker["manifest", "rm", merged_tag] & plumbum.FG
86+
LOGGER.warning(f"Manifest {merged_tag} was present locally, removed it")
87+
except plumbum.ProcessExecutionError:
88+
pass
89+
8790
LOGGER.info(f"Creating manifest for tag: {merged_tag}")
8891
# Unfortunately, `docker manifest create` requires images to have been already pushed to the registry
8992
# which is not true for new tags in PRs
90-
run_with_retries(
91-
lambda: docker["manifest", "create", merged_tag][existing_platform_tags]
92-
& plumbum.FG
93-
)
93+
docker["manifest", "create", merged_tag][existing_platform_tags] & plumbum.FG
9494
LOGGER.info(f"Successfully created manifest for tag: {merged_tag}")
9595

96+
97+
@retry(stop=stop_after_attempt(3), wait=wait_exponential(multiplier=1, min=4))
98+
def push_manifest(merged_tag: str) -> None:
9699
LOGGER.info(f"Pushing manifest for tag: {merged_tag}")
97-
run_with_retries(lambda: docker["manifest", "push", merged_tag] & plumbum.FG)
100+
docker["manifest", "push", merged_tag] & plumbum.FG
98101
LOGGER.info(f"Successfully pushed manifest for tag: {merged_tag}")
99102

100103

@@ -103,16 +106,10 @@ def merge_tags(
103106
) -> None:
104107
LOGGER.info(f"Trying to merge tag: {merged_tag}")
105108

106-
# This allows to rerun the script without having to remove the manifest manually
107-
try:
108-
docker["manifest", "rm", merged_tag] & plumbum.FG
109-
LOGGER.warning(f"Manifest {merged_tag} was present locally, removed it")
110-
except plumbum.ProcessExecutionError:
111-
pass
112-
113109
existing_platform_tags = pull_missing_tags(merged_tag, all_local_tags)
114110
if push_to_registry:
115-
push_manifest(merged_tag, existing_platform_tags)
111+
create_manifest(merged_tag, existing_platform_tags)
112+
push_manifest(merged_tag)
116113
else:
117114
LOGGER.info(f"Skipping push for tag: {merged_tag}")
118115

tests/by_image/tensorflow-notebook/units/unit_tensorflow.py

+7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Copyright (c) Jupyter Development Team.
22
# Distributed under the terms of the Modified BSD License.
3+
import os
4+
import sys
5+
6+
if "NVIDIA_VISIBLE_DEVICES" in os.environ:
7+
print("Not running this test in GPU mode")
8+
sys.exit(0)
9+
310
import tensorflow as tf
411

512
print(tf.constant("Hello, TensorFlow"))

0 commit comments

Comments
 (0)