Skip to content

Commit

Permalink
Add python examples auto test to jenkins (intel-analytics#1834)
Browse files Browse the repository at this point in the history
* auto-test

* fix openvino memory

* fix openvino memory

* keras2

* fix keras2

* fix

* fix

* fix k2

* fix k2

* temporary version

* test for #6

* keras test

* test nc

* test nc

* final

* final fix

* final fix

* ffffinal fix

* fix

* f

* f
  • Loading branch information
aqtjin authored and hkvision committed Dec 17, 2019
1 parent d9b25ba commit e3cc766
Show file tree
Hide file tree
Showing 4 changed files with 272 additions and 4 deletions.
28 changes: 28 additions & 0 deletions pyzoo/zoo/examples/run-example-tests-keras2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

export SPARK_HOME=$SPARK_HOME
export MASTER=local[4]
export FTP_URI=$FTP_URI
export ANALYTICS_ZOO_ROOT=$ANALYTICS_ZOO_ROOT
export ANALYTICS_ZOO_HOME=$ANALYTICS_ZOO_ROOT/dist

set -e

echo "#1 start example test for attention"
#timer
start=$(date "+%s")
sed "s/max_features = 20000/max_features = 100/g;s/max_len = 200/max_len = 10/g;s/hidden_size=128/hidden_size=8/g" \
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/transformer.py \
> ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/tmp.py

${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
--conf spark.executor.extraJavaOptions="-Xss512m" \
--conf spark.driver.extraJavaOptions="-Xss512m" \
--master ${MASTER} \
--driver-memory 20g \
--executor-memory 100g \
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/tmp.py

now=$(date "+%s")
time1=$((now-start))
echo "#1 attention time used:$time1 seconds"
28 changes: 28 additions & 0 deletions pyzoo/zoo/examples/run-example-tests-pip-keras2.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env bash
clear_up () {
echo "Clearing up environment. Uninstalling analytics-zoo"
pip uninstall -y analytics-zoo
pip uninstall -y bigdl
pip uninstall -y pyspark
}

echo "#1 start example test for attention"
start=$(date "+%s")
sed "s/max_features = 20000/max_features = 200/g;s/max_len = 200/max_len = 20/g;s/hidden_size=128/hidden_size=8/g" \
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/transformer.py \
> ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/tmp.py
export SPARK_DRIVER_MEMORY=20g
python ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/attention/tmp.py

exit_status=$?
if [ $exit_status -ne 0 ];
then
clear_up
echo "attention failed"
exit $exit_status
fi

unset SPARK_DRIVER_MEMORY
now=$(date "+%s")
time1=$((now-start))
echo "attention time used:$time1 seconds"
91 changes: 91 additions & 0 deletions pyzoo/zoo/examples/run-example-tests-pip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,95 @@ unset SPARK_DRIVER_MEMORY
now=$(date "+%s")
time10=$((now-start))

echo "#12 start example test for vnni/openvino"
start=$(date "+%s")
if [ -d analytics-zoo-models/vnni ]
then
echo "analytics-zoo-models/resnet_v1_50.xml already exists."
else
wget $FTP_URI/analytics-zoo-models/openvino/vnni/resnet_v1_50.zip \
-P analytics-zoo-models
unzip -q analytics-zoo-models/resnet_v1_50.zip -d analytics-zoo-models/vnni
fi
if [ -d analytics-zoo-data/data/object-detection-coco ]
then
echo "analytics-zoo-data/data/object-detection-coco already exists"
else
wget $FTP_URI/analytics-zoo-data/data/object-detection-coco.zip -P analytics-zoo-data/data
unzip -q analytics-zoo-data/data/object-detection-coco.zip -d analytics-zoo-data/data
fi
export SPARK_DRIVER_MEMORY=2g
python ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/vnni/openvino/predict.py \
--model analytics-zoo-models/vnni/resnet_v1_50.xml \
--image analytics-zoo-data/data/object-detection-coco

exit_status=$?
if [ $exit_status -ne 0 ];
then
clear_up
echo "vnni/openvino failed"
exit $exit_status
fi

unset SPARK_DRIVER_MEMORY
now=$(date "+%s")
time12=$((now-start))

echo "#13 start example test for streaming Object Detection"
#timer
start=$(date "+%s")
if [ -d analytics-zoo-data/data/object-detection-coco ]
then
echo "analytics-zoo-data/data/object-detection-coco already exists"
else
wget $FTP_URI/analytics-zoo-data/data/object-detection-coco.zip -P analytics-zoo-data/data
unzip -q analytics-zoo-data/data/object-detection-coco.zip -d analytics-zoo-data/data/
fi

if [ -f analytics-zoo-models/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model ]
then
echo "analytics-zoo-models/object-detection/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model already exists"
else
wget $FTP_URI/analytics-zoo-models/object-detection/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model \
-P analytics-zoo-models
fi

mkdir output
mkdir stream
export SPARK_DRIVER_MEMORY=2g
while true
do
temp1=$(find analytics-zoo-data/data/object-detection-coco -type f|wc -l)
temp2=$(find ./output -type f|wc -l)
temp3=$(($temp1+$temp1))
if [ $temp3 -eq $temp2 ];then
kill -9 $(ps -ef | grep StreamingObjectDetection | grep -v grep |awk '{print $2}')
rm -r output
rm -r stream
break
fi
done &
python ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/streaming/objectdetection/streaming_object_detection.py \
--streaming_path ./stream \
--model analytics-zoo-models/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model \
--output_path ./output &
python ${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/streaming/objectdetection/image_path_writer.py \
--streaming_path ./stream \
--img_path analytics-zoo-data/data/object-detection-coco

exit_status=$?
if [ $exit_status -ne 0 ];
then
clear_up
echo "streaming Object Detection failed"
exit $exit_status
fi

unset SPARK_DRIVER_MEMORY
now=$(date "+%s")
time13=$((now-start))


# This should be done at the very end after all tests finish.
clear_up

Expand All @@ -501,3 +590,5 @@ echo "#7 pytorch time used: $time7 seconds"
echo "#8 tensorflow time used: $time8 seconds"
echo "#9 anomalydetection time used: $time9 seconds"
echo "#10 qaranker time used: $time10 seconds"
echo "#12 vnni/openvino time used: $time12 seconds"
echo "#13 streaming Object Detection time used: $time13 seconds"
129 changes: 125 additions & 4 deletions pyzoo/zoo/examples/run-example-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,28 @@ ${SPARK_HOME}/bin/spark-submit \
now=$(date "+%s")
time1=$((now-start))

echo "#2 start example test for customized loss and layer (Funtional API)"
echo "#2 start example test for autograd"
#timer
start=$(date "+%s")
echo "#2.1 start example test for custom layer"
${SPARK_HOME}/bin/spark-submit \
--master ${MASTER} \
--driver-memory 20g \
--executor-memory 20g \
--driver-memory 2g \
--executor-memory 2g \
--py-files ${ANALYTICS_ZOO_PYZIP},${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/autograd/custom.py \
--jars ${ANALYTICS_ZOO_JAR} \
--conf spark.driver.extraClassPath=${ANALYTICS_ZOO_JAR} \
--conf spark.executor.extraClassPath=${ANALYTICS_ZOO_JAR} \
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/autograd/custom.py \
--nb_epoch 2

echo "#2.2 start example test for customloss"
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
--master ${MASTER} \
--driver-memory 2g \
--executor-memory 2g \
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/autograd/customloss.py

now=$(date "+%s")
time2=$((now-start))

Expand Down Expand Up @@ -437,8 +446,117 @@ ${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
now=$(date "+%s")
time10=$((now-start))

echo "#11 start example test for openvino"
#timer
start=$(date "+%s")
if [ -f analytics-zoo-models/faster_rcnn_resnet101_coco_2018_01_28.tar.gz ]
then
echo "analytics-zoo-models/faster_rcnn_resnet101_coco already exists."
else
wget $FTP_URI/analytics-zoo-models/openvino/faster_rcnn_resnet101_coco_2018_01_28.tar.gz \
-P analytics-zoo-models
tar zxf analytics-zoo-models/faster_rcnn_resnet101_coco_2018_01_28.tar.gz -C analytics-zoo-models/
fi
if [ -d analytics-zoo-data/data/object-detection-coco ]
then
echo "analytics-zoo-data/data/object-detection-coco already exists"
else
wget $FTP_URI/analytics-zoo-data/data/object-detection-coco.zip -P analytics-zoo-data/data
unzip -q analytics-zoo-data/data/object-detection-coco.zip -d analytics-zoo-data/data
fi
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
--master ${MASTER} \
--driver-memory 10g \
--executor-memory 10g \
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/openvino/predict.py \
--image analytics-zoo-data/data/object-detection-coco \
--model analytics-zoo-models/faster_rcnn_resnet101_coco_2018_01_28
now=$(date "+%s")
time11=$((now-start))

echo "#12 start example for vnni/openvino"
#timer
start=$(date "+%s")
if [ -d analytics-zoo-models/vnni ]
then
echo "analytics-zoo-models/resnet_v1_50.xml already exists."
else
wget $FTP_URI/analytics-zoo-models/openvino/vnni/resnet_v1_50.zip \
-P analytics-zoo-models
unzip -q analytics-zoo-models/resnet_v1_50.zip -d analytics-zoo-models/vnni
fi
if [ -d analytics-zoo-data/data/object-detection-coco ]
then
echo "analytics-zoo-data/data/object-detection-coco already exists"
else
wget $FTP_URI/analytics-zoo-data/data/object-detection-coco.zip -P analytics-zoo-data/data
unzip -q analytics-zoo-data/data/object-detection-coco.zip -d analytics-zoo-data/data
fi
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
--master ${MASTER} \
--driver-memory 2g \
--executor-memory 2g \
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/vnni/openvino/predict.py \
--model analytics-zoo-models/vnni/resnet_v1_50.xml \
--image analytics-zoo-data/data/object-detection-coco
now=$(date "+%s")
time12=$((now-start))

echo "#13 start example test for streaming Object Detection"
#timer
start=$(date "+%s")
if [ -d analytics-zoo-data/data/object-detection-coco ]
then
echo "analytics-zoo-data/data/object-detection-coco already exists"
else
wget $FTP_URI/analytics-zoo-data/data/object-detection-coco.zip -P analytics-zoo-data/data
unzip -q analytics-zoo-data/data/object-detection-coco.zip -d analytics-zoo-data/data/
fi

if [ -f analytics-zoo-models/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model ]
then
echo "analytics-zoo-models/object-detection/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model already exists"
else
wget $FTP_URI/analytics-zoo-models/object-detection/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model \
-P analytics-zoo-models
fi

mkdir output
mkdir stream
while true
do
temp1=$(find analytics-zoo-data/data/object-detection-coco -type f|wc -l)
temp2=$(find ./output -type f|wc -l)
temp3=$(($temp1+$temp1))
if [ $temp3 -eq $temp2 ];then
kill -9 $(ps -ef | grep StreamingObjectDetection | grep -v grep |awk '{print $2}')
rm -r output
rm -r stream
break
fi
done &
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
--master ${MASTER} \
--driver-memory 2g \
--executor-memory 2g \
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/streaming/objectdetection/streaming_object_detection.py \
--streaming_path ./stream \
--model analytics-zoo-models/analytics-zoo_ssd-vgg16-300x300_COCO_0.1.0.model \
--output_path ./output &
${ANALYTICS_ZOO_HOME}/bin/spark-submit-python-with-zoo.sh \
--master ${MASTER} \
--driver-memory 2g \
--executor-memory 2g \
${ANALYTICS_ZOO_ROOT}/pyzoo/zoo/examples/streaming/objectdetection/image_path_writer.py \
--streaming_path ./stream \
--img_path analytics-zoo-data/data/object-detection-coco

now=$(date "+%s")
time13=$((now-start))


echo "#1 textclassification time used: $time1 seconds"
echo "#2 customized loss and layer time used: $time2 seconds"
echo "#2 autograd time used: $time2 seconds"
echo "#3 image-classification time used: $time3 seconds"
echo "#4 object-detection loss and layer time used: $time4 seconds"
echo "#5 nnframes time used: $time5 seconds"
Expand All @@ -447,3 +565,6 @@ echo "#7 anomalydetection time used: $time7 seconds"
echo "#8 qaranker time used: $time8 seconds"
echo "#9 inceptionV1 training time used: $time9 seconds"
echo "#10 pytorch time used: $time10 seconds"
echo "#11 openvino time used: $time11 seconds"
echo "#12 vnni/openvino time used: $time12 seconds"
echo "#13 streaming Object Detection time used: $time13 seconds"

0 comments on commit e3cc766

Please sign in to comment.