Skip to content

Commit 30be4ec

Browse files
committed
Merge branch 'main' into develop
2 parents e808c73 + a79ed04 commit 30be4ec

11 files changed

Lines changed: 178 additions & 58 deletions

.github/workflows/containers.yml

Lines changed: 65 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# This file is auto-generated. Do not edit manually.
2+
13
name: "📦 Publish (base images)"
24

35
on:
46
push:
5-
tags:
7+
tags:
68
- '[0-9]+.[0-9]+.[0-9]+'
79
workflow_dispatch:
810
inputs:
@@ -19,11 +21,11 @@ jobs:
1921
steps:
2022
- name: "📌 Set VERSION value from dispatch inputs"
2123
id: get_version_dispatch
22-
if: ${{ github.event_name == 'workflow_dispatch' }}
24+
if: ${{ github.event_name == 'workflow_dispatch' }}
2325
run: echo "VERSION=${{ github.event.inputs.version }}" >> $GITHUB_ENV
2426
- name: "📌 Set VERSION value from pushed tag"
2527
id: get_version_tag
26-
if: ${{ github.event_name == 'push' }}
28+
if: ${{ github.event_name == 'push' }}
2729
run: echo "VERSION=$(echo "${{ github.ref }}" | cut -d/ -f3)" >> $GITHUB_ENV
2830
- name: "🏷 Record VERSION for follow-up jobs"
2931
id: output_version
@@ -51,31 +53,31 @@ jobs:
5153
buildfilename: './container/Containerfile'
5254
version: ${{ needs.set-version.outputs.version }}
5355

54-
call-build-jdk8:
55-
name: "🤙 Call container workflow with `jdk8`"
56+
call-build-ffmpeg:
57+
name: "🤙 Call container workflow with `ffmpeg`"
5658
needs: ['set-version', 'call-build-base']
5759
uses: ./.github/workflows/container.yml
5860
secrets: inherit
5961
with:
60-
buildfilename: './container/jdk8.containerfile'
62+
buildfilename: './container/ffmpeg.containerfile'
6163
version: ${{ needs.set-version.outputs.version }}
6264

63-
call-build-tf2:
64-
name: "🤙 Call container workflow with `tf2`"
65+
call-build-jdk8:
66+
name: "🤙 Call container workflow with `jdk8`"
6567
needs: ['set-version', 'call-build-base']
6668
uses: ./.github/workflows/container.yml
6769
secrets: inherit
6870
with:
69-
buildfilename: './container/tf2.containerfile'
71+
buildfilename: './container/jdk8.containerfile'
7072
version: ${{ needs.set-version.outputs.version }}
7173

72-
call-build-torch:
73-
name: "🤙 Call container workflow with `torch`"
74+
call-build-tf2:
75+
name: "🤙 Call container workflow with `tf2`"
7476
needs: ['set-version', 'call-build-base']
7577
uses: ./.github/workflows/container.yml
7678
secrets: inherit
7779
with:
78-
buildfilename: './container/torch.containerfile'
80+
buildfilename: './container/tf2.containerfile'
7981
version: ${{ needs.set-version.outputs.version }}
8082

8183
call-build-torch2:
@@ -87,15 +89,6 @@ jobs:
8789
buildfilename: './container/torch2.containerfile'
8890
version: ${{ needs.set-version.outputs.version }}
8991

90-
call-build-ffmpeg:
91-
name: "🤙 Call container workflow with `ffmpeg`"
92-
needs: ['set-version', 'call-build-base']
93-
uses: ./.github/workflows/container.yml
94-
secrets: inherit
95-
with:
96-
buildfilename: './container/ffmpeg.containerfile'
97-
version: ${{ needs.set-version.outputs.version }}
98-
9992
call-build-ffmpeg-tf2:
10093
name: "🤙 Call container workflow with `ffmpeg-tf2`"
10194
needs: ['set-version', 'call-build-ffmpeg']
@@ -105,15 +98,6 @@ jobs:
10598
buildfilename: './container/ffmpeg-tf2.containerfile'
10699
version: ${{ needs.set-version.outputs.version }}
107100

108-
call-build-ffmpeg-torch:
109-
name: "🤙 Call container workflow with `ffmpeg-torch`"
110-
needs: ['set-version', 'call-build-ffmpeg']
111-
uses: ./.github/workflows/container.yml
112-
secrets: inherit
113-
with:
114-
buildfilename: './container/ffmpeg-torch.containerfile'
115-
version: ${{ needs.set-version.outputs.version }}
116-
117101
call-build-ffmpeg-torch2:
118102
name: "🤙 Call container workflow with `ffmpeg-torch2`"
119103
needs: ['set-version', 'call-build-ffmpeg']
@@ -141,21 +125,65 @@ jobs:
141125
buildfilename: './container/opencv4-tf2.containerfile'
142126
version: ${{ needs.set-version.outputs.version }}
143127

144-
call-build-opencv4-torch:
145-
name: "🤙 Call container workflow with `opencv4-torch`"
128+
call-build-opencv4-torch2:
129+
name: "🤙 Call container workflow with `opencv4-torch2`"
146130
needs: ['set-version', 'call-build-opencv4']
147131
uses: ./.github/workflows/container.yml
148132
secrets: inherit
149133
with:
150-
buildfilename: './container/opencv4-torch.containerfile'
134+
buildfilename: './container/opencv4-torch2.containerfile'
151135
version: ${{ needs.set-version.outputs.version }}
152136

153-
call-build-opencv4-torch2:
154-
name: "🤙 Call container workflow with `opencv4-torch2`"
155-
needs: ['set-version', 'call-build-opencv4']
137+
call-build-tf2-hf:
138+
name: "🤙 Call container workflow with `tf2-hf`"
139+
needs: ['set-version', 'call-build-tf2']
156140
uses: ./.github/workflows/container.yml
157141
secrets: inherit
158142
with:
159-
buildfilename: './container/opencv4-torch2.containerfile'
143+
buildfilename: './container/tf2-hf.containerfile'
144+
version: ${{ needs.set-version.outputs.version }}
145+
146+
call-build-hf:
147+
name: "🤙 Call container workflow with `hf`"
148+
needs: ['set-version', 'call-build-torch2']
149+
uses: ./.github/workflows/container.yml
150+
secrets: inherit
151+
with:
152+
buildfilename: './container/hf.containerfile'
160153
version: ${{ needs.set-version.outputs.version }}
161154

155+
call-build-ffmpeg-tf2-hf:
156+
name: "🤙 Call container workflow with `ffmpeg-tf2-hf`"
157+
needs: ['set-version', 'call-build-ffmpeg-tf2']
158+
uses: ./.github/workflows/container.yml
159+
secrets: inherit
160+
with:
161+
buildfilename: './container/ffmpeg-tf2-hf.containerfile'
162+
version: ${{ needs.set-version.outputs.version }}
163+
164+
call-build-ffmpeg-hf:
165+
name: "🤙 Call container workflow with `ffmpeg-hf`"
166+
needs: ['set-version', 'call-build-ffmpeg-torch2']
167+
uses: ./.github/workflows/container.yml
168+
secrets: inherit
169+
with:
170+
buildfilename: './container/ffmpeg-hf.containerfile'
171+
version: ${{ needs.set-version.outputs.version }}
172+
173+
call-build-opencv4-tf2-hf:
174+
name: "🤙 Call container workflow with `opencv4-tf2-hf`"
175+
needs: ['set-version', 'call-build-opencv4-tf2']
176+
uses: ./.github/workflows/container.yml
177+
secrets: inherit
178+
with:
179+
buildfilename: './container/opencv4-tf2-hf.containerfile'
180+
version: ${{ needs.set-version.outputs.version }}
181+
182+
call-build-opencv4-hf:
183+
name: "🤙 Call container workflow with `opencv4-hf`"
184+
needs: ['set-version', 'call-build-opencv4-torch2']
185+
uses: ./.github/workflows/container.yml
186+
secrets: inherit
187+
with:
188+
buildfilename: './container/opencv4-hf.containerfile'
189+
version: ${{ needs.set-version.outputs.version }}

container/Containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.8-slim-bookworm
1+
FROM python:3.10-slim-bookworm
22
LABEL org.opencontainers.image.description="clams-python image is a base image for CLAMS apps"
33

44
ARG clams_version

container/ffmpeg-tf2-hf.containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG clams_version
2-
FROM ghcr.io/clamsproject/clams-python-ffmpeg-tf2-torch2:$clams_version
2+
FROM ghcr.io/clamsproject/clams-python-ffmpeg-tf2:$clams_version
33
LABEL org.opencontainers.image.description="clams-python-ffmpeg-tf2-hf image is shipped with clams-python, ffmpeg, tensorflow2, and vairous huggingface libraries"
44

55
RUN pip install --no-cache-dir transformers[tf,tokenizers]==4.*

container/ffmpeg-transformers4.containerfile

Lines changed: 0 additions & 5 deletions
This file was deleted.
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
from pathlib import Path
2+
3+
def scan_container_files(directory):
4+
"""Scan the container directory for Containerfile and *.containerfile files."""
5+
container_files = [f.name for f in Path(directory).iterdir() if f.is_file() and (f.name.endswith('.containerfile') or f.name == 'Containerfile')]
6+
return container_files
7+
8+
def determine_dependencies(container_files):
9+
"""Determine dependencies based on the `FROM` line in the file content."""
10+
dependencies = {}
11+
for file in container_files:
12+
file_path = Path(__file__).parent / file
13+
with open(file_path, 'r') as f:
14+
for line in f:
15+
if line.startswith('FROM'):
16+
base_image = line.split()[1].strip()
17+
# common prefix: ghcr.io/clamsproject/clams-python
18+
# common suffix: :#clams_version
19+
# just get the middle
20+
base_image = base_image[len("ghcr.io/clamsproject/clams-python"):-len(":#clams_version")]
21+
if len(base_image) == 0:
22+
dependencies[file] = []
23+
else:
24+
dependencies[file] = base_image.split('-')[1:] # assuming suffix starts with a dash
25+
break
26+
for k in sorted(dependencies.keys()):
27+
print(f"{k}: {dependencies[k]}") # Debugging output to check dependencies
28+
return dependencies
29+
30+
def generate_workflow(container_files, dependencies, output_file):
31+
"""Generate the containers.yml workflow file."""
32+
with open(output_file, 'w') as f:
33+
# Add a comment indicating the file is auto-generated
34+
f.write("# This file is auto-generated. Do not edit manually.\n\n")
35+
36+
# Write the static configuration part
37+
f.write("name: \"📦 Publish (base images)\"\n\n")
38+
f.write("on:\n push:\n tags:\n - '[0-9]+.[0-9]+.[0-9]+'\n workflow_dispatch:\n inputs:\n version:\n description: 'version to tag images'\n required: true\n\n")
39+
f.write("jobs:\n")
40+
f.write(" set-version:\n")
41+
f.write(" runs-on: ubuntu-latest\n")
42+
f.write(" name: \"🏷 Set version value\"\n")
43+
f.write(" outputs:\n")
44+
f.write(" version: ${{ steps.output_version.outputs.version }}\n")
45+
f.write(" steps:\n")
46+
f.write(" - name: \"📌 Set VERSION value from dispatch inputs\"\n")
47+
f.write(" id: get_version_dispatch\n")
48+
f.write(" if: ${{ github.event_name == 'workflow_dispatch' }}\n")
49+
f.write(" run: echo \"VERSION=${{ github.event.inputs.version }}\" >> $GITHUB_ENV\n")
50+
f.write(" - name: \"📌 Set VERSION value from pushed tag\"\n")
51+
f.write(" id: get_version_tag\n")
52+
f.write(" if: ${{ github.event_name == 'push' }}\n")
53+
f.write(" run: echo \"VERSION=$(echo \"${{ github.ref }}\" | cut -d/ -f3)\" >> $GITHUB_ENV\n")
54+
f.write(" - name: \"🏷 Record VERSION for follow-up jobs\"\n")
55+
f.write(" id: output_version\n")
56+
f.write(" run: |\n")
57+
f.write(" echo \"version=${{ env.VERSION }}\" >> $GITHUB_OUTPUT\n")
58+
f.write(" check-deployment:\n")
59+
f.write(" name: \"✅ PyPI deployment check\"\n")
60+
f.write(" runs-on: ubuntu-latest\n")
61+
f.write(" needs: ['set-version']\n")
62+
f.write(" steps:\n")
63+
f.write(" - name: \"⏱️ Wait up to 20 minutes for the new clams-python is deployed on PyPI\"\n")
64+
f.write(" uses: nev7n/wait_for_response@v1\n")
65+
f.write(" with:\n")
66+
f.write(" url: \"https://pypi.org/project/clams-python/${{ needs.set-version.outputs.version }}/\"\n")
67+
f.write(" responseCode: 200\n")
68+
f.write(" timeout: 1200000\n")
69+
f.write(" interval: 5000\n")
70+
71+
# Sort jobs: base first, then by dependency length and filename
72+
sorted_files = sorted(container_files, key=lambda x: (x != 'Containerfile', len(dependencies.get(x, [])), '-'.join(dependencies.get(x, [])), x))
73+
74+
for file in sorted_files:
75+
job_name = 'base' if file == 'Containerfile' else file.replace('.containerfile', '')
76+
f.write(f"\n call-build-{job_name}:\n")
77+
human_friendly_job_name = "the base" if job_name == 'base' else f"`{job_name}`"
78+
f.write(f" name: \"🤙 Call container workflow with {human_friendly_job_name}\"\n")
79+
dependency_job = dependencies.get(file, None)
80+
print(job_name, dependency_job)
81+
if len(dependency_job) > 0:
82+
f.write(f" needs: ['set-version', 'call-build-{'-'.join(dependency_job)}']\n")
83+
else:
84+
if job_name == 'base':
85+
f.write(f" needs: ['set-version', 'check-deployment']\n")
86+
else:
87+
f.write(f" needs: ['set-version', 'call-build-base']\n")
88+
f.write(" uses: ./.github/workflows/container.yml\n")
89+
f.write(" secrets: inherit\n")
90+
f.write(" with:\n")
91+
f.write(f" buildfilename: './container/{file}'\n")
92+
f.write(f" version: ${{{{ needs.set-version.outputs.version }}}}\n")
93+
94+
if __name__ == "__main__":
95+
container_dir = Path(__file__).parent
96+
output_file = Path(__file__).parent.parent / ".github/workflows/containers.yml"
97+
98+
print("Scanning container directory...")
99+
container_files = scan_container_files(container_dir)
100+
101+
print("Determining dependencies...")
102+
dependencies = determine_dependencies(container_files)
103+
104+
print("Generating workflow file...")
105+
generate_workflow(container_files, dependencies, output_file)
106+
107+
print(f"Workflow file generated at {output_file}")

container/hf.containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG clams_version
2-
FROM ghcr.io/clamsproject/clams-python--torch2:$clams_version
2+
FROM ghcr.io/clamsproject/clams-python-torch2:$clams_version
33
LABEL org.opencontainers.image.description="clams-python-hf image is shipped with clams-python and vairous huggingface libraries (PyTorch backend)"
44

55
RUN pip install --no-cache-dir transformers[torch,tokenizers]==4.*

container/opencv4-tf2-hf.containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG clams_version
2-
FROM ghcr.io/clamsproject/clams-python-opencv4-tf2-torch2:$clams_version
2+
FROM ghcr.io/clamsproject/clams-python-opencv4-tf2:$clams_version
33
LABEL org.opencontainers.image.description="clams-python-opencv4-tf2-hf image is shipped with clams-python, opencv4 (ffmpeg backend), tensorflow2, and vairous huggingface libraries"
44

55
RUN pip install --no-cache-dir transformers[tf,tokenizers]==4.*

container/opencv4-transformers4.containerfile

Lines changed: 0 additions & 5 deletions
This file was deleted.

container/opencv4.containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG clams_version
2-
FROM ghcr.io/clamsproject/clams-python--ffmpeg:$clams_version
2+
FROM ghcr.io/clamsproject/clams-python-ffmpeg:$clams_version
33
LABEL org.opencontainers.image.description="clams-python-opencv4 image is shipped with clams-python and opencv4 (ffmpeg backend)"
44

55
ARG OPENCV_VERSION=4.10.0

container/tf2-hf.containerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
ARG clams_version
2-
FROM ghcr.io/clamsproject/clams-python-tf2-torch2:$clams_version
2+
FROM ghcr.io/clamsproject/clams-python-tf2:$clams_version
33
LABEL org.opencontainers.image.description="clams-python-tf2-hf image is shipped with clams-python, tensorflow2, and vairous huggingface libraries"
44

55
RUN pip install --no-cache-dir transformers[tf,tokenizers]==4.*

0 commit comments

Comments
 (0)