Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nightly build for torchserve-kfs image #2574

Merged
merged 4 commits into from
Sep 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions .github/workflows/docker-nightly-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Push Docker Nightly
on:
# run every day at 1:15pm
schedule:
- cron: '15 13 * * *'
- cron: "15 13 * * *"
jobs:
nightly:
runs-on: ubuntu-20.04
Expand All @@ -23,12 +23,16 @@ jobs:
run: |
cd docker
python docker_nightly.py
- name: Push KServe Docker Nightly
run: |
cd kubernetes/kserve
python docker_nightly.py

- name: Open issue on failure
if: ${{ failure() && github.event_name == 'schedule' }}
uses: dacbd/create-issue-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Nightly Docker build failed
body: Commit ${{ github.sha }} daily scheduled [CI run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) failed, please check why
assignees: ''
body: Commit ${{ github.sha }} daily scheduled [CI run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) failed, please check why
assignees: ""
25 changes: 24 additions & 1 deletion kubernetes/kserve/build_image.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash

MACHINE=cpu
DOCKER_TAG="pytorch/torchserve-kfs:latest"
BASE_IMAGE="pytorch/torchserve:latest"
DOCKER_FILE="Dockerfile"
BUILD_NIGHTLY=false
USE_CUSTOM_TAG=false

for arg in "$@"
do
Expand All @@ -12,9 +15,11 @@ do
echo "-h, --help show brief help"
echo "-g, --gpu specify for gpu build"
echo "-t, --tag specify tag name for docker image"
echo "-n, --nightly specify to build with TorchServe nightly"
exit 0
;;
-g|--gpu)
MACHINE=gpu
DOCKER_TAG="pytorch/torchserve-kfs:latest-gpu"
BASE_IMAGE="pytorch/torchserve:latest-gpu"
shift
Expand All @@ -23,14 +28,32 @@ do
DOCKER_FILE="Dockerfile.dev"
shift
;;
-n|--nightly)
BUILD_NIGHTLY=true
shift
;;
-t|--tag)
DOCKER_TAG="$2"
CUSTOM_TAG="$2"
USE_CUSTOM_TAG=true
jagadeeshi2i marked this conversation as resolved.
Show resolved Hide resolved
shift
shift
;;
esac
done

if [[ "${MACHINE}" == "gpu" ]] && [[ "$BUILD_NIGHTLY" == true ]] ;
then
BASE_IMAGE="pytorch/torchserve-nightly:latest-gpu"
elif [[ "${MACHINE}" == "cpu" ]] && [[ "$BUILD_NIGHTLY" == true ]] ;
then
BASE_IMAGE="pytorch/torchserve-nightly:latest-cpu"
fi

if [ "$USE_CUSTOM_TAG" = true ]
then
DOCKER_TAG=${CUSTOM_TAG}
fi

cp ../../frontend/server/src/main/resources/proto/*.proto .

DOCKER_BUILDKIT=1 docker build --file "$DOCKER_FILE" --build-arg BASE_IMAGE=$BASE_IMAGE -t "$DOCKER_TAG" .
57 changes: 57 additions & 0 deletions kubernetes/kserve/docker_nightly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import argparse
import os
import sys

# To help discover local modules
REPO_ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "../..")
sys.path.append(REPO_ROOT)

from setup import get_nightly_version
from ts_scripts.utils import try_and_handle

if __name__ == "__main__":
failed_commands = []
parser = argparse.ArgumentParser()
parser.add_argument(
"--organization",
type=str,
default="pytorch",
help="The name of the Dockerhub organization where the images will be pushed",
)
parser.add_argument(
"--dry_run",
action="store_true",
help="dry_run will print the commands that will be run without running them",
)
args = parser.parse_args()
dry_run = args.dry_run
organization = args.organization

project = "torchserve-kfs-nightly"
cpu_version = f"{project}:cpu-{get_nightly_version()}"
gpu_version = f"{project}:gpu-{get_nightly_version()}"

# Build Nightly images and append the date in the name
try_and_handle(f"./build_image.sh -n -t {organization}/{cpu_version}", dry_run)
try_and_handle(
f"./build_image.sh -g -n -t {organization}/{gpu_version}",
dry_run,
)

# Push Nightly images to official PyTorch Dockerhub account
try_and_handle(f"docker push {organization}/{cpu_version}", dry_run)
try_and_handle(f"docker push {organization}/{gpu_version}", dry_run)

# Tag nightly images with latest
try_and_handle(
f"docker tag {organization}/{cpu_version} {organization}/{project}:latest-cpu",
dry_run,
)
try_and_handle(
f"docker tag {organization}/{gpu_version} {organization}/{project}:latest-gpu",
dry_run,
)

# Push images with latest tag
try_and_handle(f"docker push {organization}/{project}:latest-cpu", dry_run)
try_and_handle(f"docker push {organization}/{project}:latest-gpu", dry_run)