Skip to content

CaaS - test APIs and E2E tests #2191

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

Merged
merged 41 commits into from
May 27, 2021
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
89b0f4c
Remove unnecessary examples
RobertLucian May 24, 2021
747d6bb
More APIs removed
RobertLucian May 24, 2021
a68fd68
Add test apis (realtime/async)
RobertLucian May 24, 2021
83079a1
Require less memory for text-generator api
RobertLucian May 24, 2021
8b37a94
Add tensorflow cpu/gpu api
RobertLucian May 25, 2021
52a42d1
Merge branch 'feature/caas-api' into caas/test-apis
RobertLucian May 25, 2021
8c7ba0b
Changes to the realtime APIs
RobertLucian May 25, 2021
73c0419
Remove tensorflow dir from tests
RobertLucian May 25, 2021
6cfc3f2
Add iris-classifier trainer task
RobertLucian May 25, 2021
2e1b8a6
Remove more unnecessary APIs
RobertLucian May 25, 2021
db5ed8a
Add batch API
RobertLucian May 25, 2021
16d7519
Add batch submitter
RobertLucian May 25, 2021
fc9bf12
Add batch sum API
RobertLucian May 25, 2021
ab61fa0
Finalize async E2E
RobertLucian May 25, 2021
80bd36c
Finalize autoscaling E2E test
RobertLucian May 25, 2021
4e671fb
Finalize batch E2E test
RobertLucian May 25, 2021
90d1d43
Finalize load E2E test
RobertLucian May 25, 2021
45d07c2
Finalize long running E2E test
RobertLucian May 25, 2021
2a95e0c
Finalize realtime E2E test
RobertLucian May 25, 2021
b24bded
Finalize task E2E test
RobertLucian May 25, 2021
69b54a0
Add TrafficSplitter API
RobertLucian May 25, 2021
10b5ad0
Tweak make file commands to build the api images
RobertLucian May 25, 2021
1f93a17
Use the correct image names (not considering the registry) for the te…
RobertLucian May 25, 2021
d144cb0
Remove the "sample/" word from the test API images
RobertLucian May 25, 2021
96aa2fe
Fix traffic splitter image builder
RobertLucian May 25, 2021
d22d287
Use master instead of latest tag
RobertLucian May 25, 2021
cdeac2a
Fix naming scheme of container images (for APIs)
RobertLucian May 25, 2021
2d29c7e
Address some PR comments
RobertLucian May 26, 2021
142aba8
Revert to using query params for sleep API
RobertLucian May 26, 2021
0cb8c60
Create make test-images-* commands
RobertLucian May 26, 2021
e099f7d
Fixes for the E2E tests
RobertLucian May 26, 2021
686aa51
Use the correct api name for the iris-classifier trainer
RobertLucian May 26, 2021
a833339
Rename test_async_api to test_async_api_gpu
RobertLucian May 26, 2021
85b0861
update traffic splitter example
deliahu May 26, 2021
b73d66b
Address PR thoughts
RobertLucian May 27, 2021
06faae8
Create hello-world realtime API
RobertLucian May 27, 2021
38601c9
Fix naming scheme of the test api images (in make cmd)
RobertLucian May 27, 2021
aa7e53e
Minor log correction
RobertLucian May 27, 2021
fbf79de
Use quay images for the test APIs
RobertLucian May 27, 2021
dba2883
Batch sum API fix
RobertLucian May 27, 2021
56e6810
Nits
RobertLucian May 27, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
20 changes: 10 additions & 10 deletions build/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. >/dev/null && pwd)"
CORTEX_VERSION=master

image=$1
image_type=$2

if [ "$image" == "inferentia" ]; then
aws ecr get-login-password --region us-west-2 | docker login --username AWS --password-stdin 790709498068.dkr.ecr.us-west-2.amazonaws.com
fi

build_args=""

if [ "${image}" == "python-handler-gpu" ]; then
cuda=("10.0" "10.1" "10.1" "10.2" "10.2" "11.0" "11.1")
cudnn=("7" "7" "8" "7" "8" "8" "8")
for i in ${!cudnn[@]}; do
build_args="${build_args} --build-arg CUDA_VERSION=${cuda[$i]} --build-arg CUDNN=${cudnn[$i]}"
docker build "$ROOT" -f $ROOT/images/$image/Dockerfile $build_args -t quay.io/cortexlabs/${image}:${CORTEX_VERSION}-cuda${cuda[$i]}-cudnn${cudnn[$i]} -t cortexlabs/${image}:${CORTEX_VERSION}-cuda${cuda[$i]}-cudnn${cudnn[$i]}
done
else
if [ "$image_type" = "non-api" ]; then
docker build "$ROOT" -f $ROOT/images/$image/Dockerfile $build_args -t quay.io/cortexlabs/${image}:${CORTEX_VERSION} -t cortexlabs/${image}:${CORTEX_VERSION}
else
num_words="$(awk -F'-' '{ for(i=1;i<=NF;i++) print $i }' <<< ${image} | wc -l | sed -e 's/^[[:space:]]*//')"
kind_dir="$( cut -d '-' -f 1 <<< "${image}" )"
api_name="$( cut -d '-' -f 2-$((num_words-1)) <<< "${image}" )"
compute_type="$( cut -d '-' -f ${num_words} <<< "${image}" )"

dir="${ROOT}/test/apis/${kind_dir}/${api_name}"
docker build $dir -f $dir/$api_name-$compute_type.dockerfile -t cortexlabs/$image:${CORTEX_VERSION}
fi
19 changes: 16 additions & 3 deletions build/build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,23 @@ source $ROOT/build/images.sh
source $ROOT/dev/util.sh

# if parallel utility is installed, the docker build commands will be parallelized
non_api_images=(
"${dev_images[@]}"
"${non_dev_images[@]}"
)
if command -v parallel &> /dev/null && [ -n "${NUM_BUILD_PROCS+set}" ] && [ "$NUM_BUILD_PROCS" != "1" ]; then
ROOT=$ROOT SHELL=$(type -p /bin/bash) parallel --will-cite --halt now,fail=1 --eta --jobs $NUM_BUILD_PROCS $ROOT/build/build-image.sh {} ::: "${all_images[@]}"
ROOT=$ROOT SHELL=$(type -p /bin/bash) parallel --will-cite --halt now,fail=1 --eta --jobs $NUM_BUILD_PROCS $ROOT/build/build-image.sh {} "non-api" ::: "${non_api_images[@]}"
else
for image in "${all_images[@]}"; do
$ROOT/build/build-image.sh $image
for image in "${non_api_images[@]}"; do
$ROOT/build/build-image.sh $image "non-api"
done
fi

# if parallel utility is installed, the docker build commands will be parallelized
if command -v parallel &> /dev/null && [ -n "${NUM_BUILD_PROCS+set}" ] && [ "$NUM_BUILD_PROCS" != "1" ]; then
ROOT=$ROOT SHELL=$(type -p /bin/bash) parallel --will-cite --halt now,fail=1 --eta --jobs $NUM_BUILD_PROCS $ROOT/build/build-image.sh {} "api" ::: "${api_images[@]}"
else
for image in "${api_images[@]}"; do
$ROOT/build/build-image.sh $image "api"
done
fi
17 changes: 13 additions & 4 deletions build/images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@
set -euo pipefail

api_images=(
"python-handler-cpu"
"python-handler-gpu"
"tensorflow-handler"
"python-handler-inf"
"async-text-generator-cpu"
"async-text-generator-gpu"
"batch-image-classifier-alexnet-cpu"
"batch-image-classifier-alexnet-gpu"
"batch-sum-cpu"
"realtime-image-classifier-resnet50-cpu"
"realtime-image-classifier-resnet50-gpu"
"realtime-prime-generator-cpu"
"realtime-sleep-cpu"
"realtime-text-generator-cpu"
"realtime-text-generator-gpu"
"task-iris-classifier-trainer-cpu"
"trafficsplitter-prime-generator-cpu"
)

dev_images=(
Expand Down
11 changes: 1 addition & 10 deletions build/push-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,4 @@ host=$1
image=$2

echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin

if [ "$image" == "python-handler-gpu" ]; then
cuda=("10.0" "10.1" "10.1" "10.2" "10.2" "11.0" "11.1")
cudnn=("7" "7" "8" "7" "8" "8" "8")
for i in ${!cudnn[@]}; do
docker push $host/cortexlabs/${image}:${CORTEX_VERSION}-cuda${cuda[$i]}-cudnn${cudnn[$i]}
done
else
docker push $host/cortexlabs/${image}:${CORTEX_VERSION}
fi
docker push $host/cortexlabs/${image}:${CORTEX_VERSION}
19 changes: 3 additions & 16 deletions dev/export_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,10 @@ for image in "${all_images[@]}"; do
done
echo

cuda=("10.0" "10.1" "10.1" "10.2" "10.2" "11.0" "11.1")
cudnn=("7" "7" "8" "7" "8" "8" "8")

# pull the images from source registry and push them to ECR
for image in "${all_images[@]}"; do
# copy the different cuda/cudnn variations of the python handler image
if [ "$image" = "python-handler-gpu" ]; then
for i in "${!cuda[@]}"; do
full_image="$image:$cortex_version-cuda${cuda[$i]}-cudnn${cudnn[$i]}"
echo "copying $full_image from $source_registry to $destination_registry"
skopeo copy --src-no-creds "docker://$source_registry/$full_image" "docker://$destination_registry/$full_image"
echo
done
else
echo "copying $image:$cortex_version from $source_registry to $destination_registry"
skopeo copy --src-no-creds "docker://$source_registry/$image:$cortex_version" "docker://$destination_registry/$image:$cortex_version"
echo
fi
echo "copying $image:$cortex_version from $source_registry to $destination_registry"
skopeo copy --src-no-creds "docker://$source_registry/$image:$cortex_version" "docker://$destination_registry/$image:$cortex_version"
echo
done
echo "done ✓"
43 changes: 29 additions & 14 deletions dev/registry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,27 @@ function create_ecr_repository() {
function build() {
local image=$1
local tag=$2
local dir="${ROOT}/images/${image}"

build_args=""
local image_type=$3

tag_args=""
if [ -n "$AWS_ACCOUNT_ID" ] && [ -n "$AWS_REGION" ]; then
tag_args+=" -t $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/cortexlabs/$image:$tag"
fi

blue_echo "Building $image:$tag..."
docker build $ROOT -f $dir/Dockerfile -t cortexlabs/$image:$tag $tag_args $build_args
if [ "$image_type" = "non-api" ]; then
local dir="${ROOT}/images/${image}"
docker build $ROOT -f $dir/Dockerfile -t cortexlabs/$image:$tag $tag_args
else
local num_words="$(awk -F'-' '{ for(i=1;i<=NF;i++) print $i }' <<< ${image} | wc -l | sed -e 's/^[[:space:]]*//')"
local kind_dir="$( cut -d '-' -f 1 <<< "${image}" )"
local api_name="$( cut -d '-' -f 2-$((num_words-1)) <<< "${image}" )"
local compute_type="$( cut -d '-' -f ${num_words} <<< "${image}" )"

local dir="${ROOT}/test/apis/${kind_dir}/${api_name}"
echo "docker build $dir -f $api_name-$compute_type.dockerfile -t cortexlabs/$image:$tag $tag_args"
docker build $dir -f $dir/$api_name-$compute_type.dockerfile -t cortexlabs/$image:$tag $tag_args
fi
green_echo "Built $image:$tag\n"
}

Expand Down Expand Up @@ -146,15 +156,12 @@ function push() {

function build_and_push() {
local image=$1
local image_type=$2

set -euo pipefail # necessary since this is called in a new shell by parallel

tag=$CORTEX_VERSION
if [ "${image}" == "python-handler-gpu" ]; then
tag="${CORTEX_VERSION}-cuda10.2-cudnn8"
fi

build $image $tag
build $image $tag $image_type
push $image $tag
}

Expand Down Expand Up @@ -225,7 +232,7 @@ elif [ "$cmd" = "update-single" ]; then
if [ "$image" = "operator" ] || [ "$image" = "proxy" ]; then
cache_builder $image
fi
build_and_push $image
build_and_push $image "non-api"

# usage: registry.sh update all|dev|api
# if parallel utility is installed, the docker build commands will be parallelized
Expand All @@ -240,8 +247,6 @@ elif [ "$cmd" = "update" ]; then
images_to_build+=( "${dev_images[@]}" )
fi

images_to_build+=( "${api_images[@]}" )

if [[ " ${images_to_build[@]} " =~ " operator " ]]; then
cache_builder operator
fi
Expand All @@ -252,11 +257,21 @@ elif [ "$cmd" = "update" ]; then
cache_builder async-gateway
fi

# build non-api images
if command -v parallel &> /dev/null && [ -n "${NUM_BUILD_PROCS+set}" ] && [ "$NUM_BUILD_PROCS" != "1" ]; then
is_registry_logged_in=$is_registry_logged_in ROOT=$ROOT registry_push_url=$registry_push_url SHELL=$(type -p /bin/bash) parallel --will-cite --halt now,fail=1 --eta --jobs $NUM_BUILD_PROCS build_and_push "{}" ::: "${images_to_build[@]}"
is_registry_logged_in=$is_registry_logged_in ROOT=$ROOT registry_push_url=$registry_push_url SHELL=$(type -p /bin/bash) parallel --will-cite --halt now,fail=1 --eta --jobs $NUM_BUILD_PROCS build_and_push "{}" "non-api"::: "${images_to_build[@]}"
else
for image in "${images_to_build[@]}"; do
build_and_push $image
build_and_push $image "non-api"
done
fi

# build api images
if command -v parallel &> /dev/null && [ -n "${NUM_BUILD_PROCS+set}" ] && [ "$NUM_BUILD_PROCS" != "1" ]; then
is_registry_logged_in=$is_registry_logged_in ROOT=$ROOT registry_push_url=$registry_push_url SHELL=$(type -p /bin/bash) parallel --will-cite --halt now,fail=1 --eta --jobs $NUM_BUILD_PROCS build_and_push "{}" "api" ::: "${api_images[@]}"
else
for image in "${api_images[@]}"; do
build_and_push $image "api"
done
fi

Expand Down
67 changes: 0 additions & 67 deletions test/apis/README.md

This file was deleted.

11 changes: 0 additions & 11 deletions test/apis/async/iris-classifier/cortex.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions test/apis/async/iris-classifier/expectations.yaml

This file was deleted.

26 changes: 0 additions & 26 deletions test/apis/async/iris-classifier/handler.py

This file was deleted.

2 changes: 0 additions & 2 deletions test/apis/async/iris-classifier/requirements.txt

This file was deleted.

6 changes: 0 additions & 6 deletions test/apis/async/iris-classifier/sample.json

This file was deleted.

7 changes: 0 additions & 7 deletions test/apis/async/tensorflow/cortex.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions test/apis/async/tensorflow/handler.py

This file was deleted.

6 changes: 0 additions & 6 deletions test/apis/async/tensorflow/sample.json

This file was deleted.

9 changes: 9 additions & 0 deletions test/apis/async/text-generator/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Dockerfile
README.md
sample.json
expectations.yaml
*.pyc
*.pyo
*.pyd
__pycache__
.pytest_cache
16 changes: 16 additions & 0 deletions test/apis/async/text-generator/cortex_cpu.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- name: text-generator
kind: AsyncAPI
pod:
port: 9000
containers:
- name: api
image: 499593605069.dkr.ecr.us-west-2.amazonaws.com/cortexlabs/realtime-async-text-generator-cpu:master
readiness_probe:
http_get:
path: "/healthz"
port: 9000
compute:
cpu: 1
mem: 2.5G
autoscaling:
max_concurrency: 1
Loading