Skip to content

Commit a548187

Browse files
committed
docker: fix setting tags
1 parent 4c0eb3a commit a548187

File tree

2 files changed

+27
-18
lines changed

2 files changed

+27
-18
lines changed

.actions/assistant.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,25 @@ def convert_version2nightly(ver_file: str = "src/version.info") -> None:
481481
with open(ver_file, "w") as fo:
482482
fo.write(version + os.linesep)
483483

484+
@staticmethod
485+
def generate_docker_tags(
486+
release_version: str,
487+
python_version: str,
488+
torch_version: str,
489+
cuda_version: str,
490+
docker_project: str = "pytorchlightning/pytorch_lightning",
491+
add_latest: bool = False,
492+
) -> str:
493+
"""Generate docker tags for the given versions."""
494+
tags = [f"latest-py{python_version}-torch{torch_version}-cuda{cuda_version}"]
495+
if release_version:
496+
tags += [f"{release_version}-py{python_version}-torch{torch_version}-cuda{cuda_version}"]
497+
if add_latest:
498+
tags += ["latest"]
499+
500+
tags = [f"{docker_project}:{tag}" for tag in tags]
501+
return ",".join(tags)
502+
484503

485504
if __name__ == "__main__":
486505
import sys

.github/workflows/docker-build.yml

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
- { python_version: "3.11", pytorch_version: "2.2", cuda_version: "12.1.0" }
4848
- { python_version: "3.11", pytorch_version: "2.3", cuda_version: "12.1.0" }
4949
- { python_version: "3.11", pytorch_version: "2.4", cuda_version: "12.1.0" }
50-
- { python_version: "3.12", pytorch_version: "2.5", cuda_version: "12.1.0" }
50+
- { python_version: "3.12", pytorch_version: "2.5", cuda_version: "12.1.0" , latest: true}
5151
steps:
5252
- uses: actions/checkout@v4
5353
with:
@@ -65,23 +65,13 @@ jobs:
6565
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF##*/})" >> $GITHUB_ENV
6666
- name: Set tags
6767
run: |
68-
import os
69-
70-
repo = "pytorchlightning/pytorch_lightning"
71-
ver = os.getenv('RELEASE_VERSION')
72-
py_ver = "${{ matrix.python_version }}"
73-
pt_ver = "${{ matrix.pytorch_version }}"
74-
cuda_ver = "${{ matrix.cuda_version }}"
75-
tags = [f"latest-py{py_ver}-torch{pt_ver}-cuda{cuda_ver}"]
76-
if ver:
77-
tags += [f"{ver}-py{py_ver}-torch{pt_ver}-cuda{cuda_ver}"]
78-
if py_ver == '3.11' and pt_ver == '2.3' and cuda_ver == '12.1.0':
79-
tags += ["latest"]
80-
81-
tags = [f"{repo}:{tag}" for tag in tags]
82-
with open(os.getenv('GITHUB_ENV'), "a") as gh_env:
83-
gh_env.write("DOCKER_TAGS=" + ",".join(tags))
84-
shell: python
68+
tags = $(python .actions/assistant.py generate_docker_tags \
69+
--release-version="${{ env.RELEASE_VERSION }}" \
70+
--python-version="${{ matrix.python_version }}" \
71+
--torch-version="${{ matrix.pytorch_version }}" \
72+
--cuda-version="${{ matrix.cuda_version }}" \
73+
--add_latest="${{ matrix.latest }}")
74+
echo "DOCKER_TAGS=$tags" >> $GITHUB_ENV
8575
8676
- uses: docker/build-push-action@v6
8777
with:

0 commit comments

Comments
 (0)