Skip to content

Commit 9fe85e1

Browse files
d4l3kfacebook-github-bot
authored andcommitted
workflows/container: push to Github container registry (#56)
Summary: This sets up automatic push for the latest package version for the torchx container image and torchx-examples container image. For each container it pushes two tags, one with the version specified in version.py and the other with "latest". I updated any usages of images to point to the new versioned containers. Pull Request resolved: #56 Test Plan: push to torchxcontainer branch + CI https://github.com/orgs/pytorch/packages?repo_name=torchx https://github.com/orgs/pytorch/packages/container/package/torchx-examples https://github.com/orgs/pytorch/packages/container/package/torchx Reviewed By: kiukchung Differential Revision: D29116087 Pulled By: d4l3k fbshipit-source-id: 3863bdb3dba6721ad87fdda8b744858f94a1cfb0
1 parent 6dafa9e commit 9fe85e1

File tree

5 files changed

+48
-16
lines changed

5 files changed

+48
-16
lines changed

.github/workflows/container.yaml

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Docker Container
1+
name: Publish Docker Containers
22

33
on:
44
push:
@@ -10,18 +10,33 @@ jobs:
1010
build:
1111
runs-on: ubuntu-18.04
1212
steps:
13+
- name: Setup Python
14+
uses: actions/setup-python@v2
15+
with:
16+
python-version: 3.8
17+
architecture: x64
1318
- name: Checkout TorchX
1419
uses: actions/checkout@v2
20+
- name: Get TorchX version
21+
run: |
22+
set -eux
23+
python setup.py install
24+
echo "VERSION=$(python -c 'import torchx; print(torchx.__version__)')" >> $GITHUB_ENV
1525
- name: Configure Docker
16-
env:
17-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
18-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
1926
run: |
2027
set -eux
21-
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 495572122715.dkr.ecr.us-west-2.amazonaws.com
22-
- name: Build container
23-
run: torchx/runtime/container/build.sh
24-
- name: Tag container
25-
run: docker tag torchx ${{secrets.TORCHX_CONTAINER_REPO}}:latest
26-
- name: Push container
27-
run: docker push ${{secrets.TORCHX_CONTAINER_REPO}}:latest
28+
echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
29+
- name: Build torchx container
30+
run: |
31+
set -eux
32+
torchx/runtime/container/build.sh
33+
docker tag torchx "ghcr.io/pytorch/torchx:$VERSION"
34+
- name: Build examples container
35+
run: |
36+
set -eux
37+
docker build -t "ghcr.io/pytorch/torchx-examples:$VERSION" examples/apps/
38+
- name: Push containers
39+
run: |
40+
set -eux
41+
docker push "ghcr.io/pytorch/torchx-examples:$VERSION"
42+
docker push "ghcr.io/pytorch/torchx:$VERSION"

examples/pipelines/kfp/kfp_pipeline.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,20 @@
3232
# docker containers. We have one container for the example apps and one for
3333
# the standard built in apps. If you modify the torchx example code you'll
3434
# need to rebuild the container before launching it on KFP
35+
36+
from torchx.version import TORCHX_IMAGE, EXAMPLES_IMAGE
37+
3538
parser.add_argument(
3639
"--image",
3740
type=str,
38-
help="docker image to use",
39-
default="495572122715.dkr.ecr.us-west-2.amazonaws.com/torchx/examples:latest",
41+
help="docker image to use for the examples apps",
42+
default=EXAMPLES_IMAGE,
4043
)
4144
parser.add_argument(
4245
"--torchx_image",
4346
type=str,
44-
help="docker image to use",
45-
default="495572122715.dkr.ecr.us-west-2.amazonaws.com/torchx:latest",
47+
help="docker image to use for the builtin torchx apps",
48+
default=TORCHX_IMAGE,
4649
)
4750

4851
# %%

torchx/components/serve/serve.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@
77
from typing import Dict, Optional
88

99
import torchx.specs as specs
10+
from torchx.version import TORCHX_IMAGE
1011

1112

1213
def torchserve(
1314
model_path: str,
1415
management_api: str,
15-
image: str = "495572122715.dkr.ecr.us-west-2.amazonaws.com/torchx:latest",
16+
image: str = TORCHX_IMAGE,
1617
params: Optional[Dict[str, object]] = None,
1718
) -> specs.AppDef:
1819
"""Deploys the provided model to the given torchserve management API

torchx/test/version_test.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,11 @@ def test_can_get_version(self) -> None:
1313
import torchx
1414

1515
self.assertIsNotNone(torchx.__version__)
16+
17+
def test_images(self) -> None:
18+
from torchx.version import __version__, TORCHX_IMAGE, EXAMPLES_IMAGE
19+
20+
self.assertEqual(TORCHX_IMAGE, f"ghcr.io/pytorch/torchx:{__version__}")
21+
self.assertEqual(
22+
EXAMPLES_IMAGE, f"ghcr.io/pytorch/torchx-examples:{__version__}"
23+
)

torchx/version.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@
1515
# 0.1.0rcN # Release Candidate
1616
# 0.1.0 # Final release
1717
__version__ = "0.1.0.dev0"
18+
19+
# Use the github container registry images corresponding to the current package
20+
# version.
21+
TORCHX_IMAGE = f"ghcr.io/pytorch/torchx:{__version__}"
22+
EXAMPLES_IMAGE = f"ghcr.io/pytorch/torchx-examples:{__version__}"

0 commit comments

Comments
 (0)