Commit 187dee75 authored by mchrusci's avatar mchrusci Committed by Robert Kimball

[ONNX CI] Fix manual reproduction script (#1881)

* Update runCI.sh

Accommodate manual reproduction script.

* Update README.md

* Update runCI.sh

* fixes
* added rebuild parameter

* Fix rebuilding nGraph

* Added execution permission to runCI.sh
parent e07147f8
......@@ -11,3 +11,9 @@ To remove all items created during script execution (files, directories, docker
```
./runCI.sh --cleanup
```
After first run, executing the script will rerun tox tests. To rebuild nGraph and run tests use:
```
./runCI.sh --rebuild
```
......@@ -16,44 +16,73 @@
# limitations under the License.
# ******************************************************************************
NGRAPH_ONNX_REPO="https://github.com/NervanaSystems/ngraph-onnx"
CI_PATH="$(pwd)"
CI_ROOT=".ci/jenkins"
CI_ROOT=".ci/onnx/jenkins"
REPO_ROOT="${CI_PATH%$CI_ROOT}"
DOCKER_CONTAINER="ngraph-onnx_ci"
DOCKER_CONTAINER="ngraph-onnx_ci_reproduction"
# Function run() builds image with requirements needed to build ngraph and run onnx tests, runs container and executes tox tests
function run() {
set -x
set -e
cd ./dockerfiles
docker build --build-arg http_proxy=$http_proxy --build-arg https_proxy=$https_proxy -f=./ubuntu-16_04.dockerfile -t ngraph-onnx:ubuntu-16_04 .
cd "${CI_PATH}"
mkdir -p ${HOME}/ONNX_CI
if [[ -z $(docker ps -a | grep -i "${DOCKER_CONTAINER}") ]];
then
docker run -h "$(hostname)" --privileged --name "${DOCKER_CONTAINER}" -v ${HOME}/ONNX_CI:/home -v "${REPO_ROOT}":/root -d ngraph-onnx:ubuntu-16_04 tail -f /dev/null
docker cp ./prepare_environment.sh "${DOCKER_CONTAINER}":/home
docker exec "${DOCKER_CONTAINER}" ./home/prepare_environment.sh
cd "${CI_PATH}"
if [[ -z $(docker ps -a | grep -i "${DOCKER_CONTAINER}") ]];
then
docker run -h "$(hostname)" --privileged --name "${DOCKER_CONTAINER}" -v "${REPO_ROOT}":/root \
-d ngraph-onnx:ubuntu-16_04 tail -f /dev/null
BUILD="TRUE"
fi
NGRAPH_WHL=$(docker exec ${DOCKER_CONTAINER} find /home/ngraph/python/dist/ -name "ngraph*.whl")
docker exec -e TOX_INSTALL_NGRAPH_FROM="${NGRAPH_WHL}" "${DOCKER_CONTAINER}" tox -c /root
if [[ "${BUILD}" == "TRUE" ]];
then
BUILD_NGRAPH_CMD='cd /root && \
mkdir -p ./build && \
cd ./build && \
cmake ../ -DNGRAPH_TOOLS_ENABLE=FALSE -DNGRAPH_UNIT_TEST_ENABLE=FALSE -DNGRAPH_USE_PREBUILT_LLVM=TRUE \
-DNGRAPH_ONNX_IMPORT_ENABLE=TRUE -DCMAKE_INSTALL_PREFIX=/root/ngraph_dist && \
make -j $(lscpu --parse=CORE | grep -v '"'#'"' | sort | uniq | wc -l) && \
make install && \
cd /root/python && \
if [[ -z $(ls /root/ngraph-onnx 2>/dev/null) ]]; then
git clone --recursive https://github.com/pybind/pybind11.git;
fi
export PYBIND_HEADERS_PATH=/root/python/pybind11 && \
export NGRAPH_CPP_BUILD_PATH=/root/ngraph_dist && \
export NGRAPH_ONNX_IMPORT_ENABLE=TRUE && \
python3 setup.py bdist_wheel && \
cd /root'
docker exec "${DOCKER_CONTAINER}" bash -c "${BUILD_NGRAPH_CMD}"
fi
echo "========== FOLLOWING ITEMS WERE CREATED DURING SCRIPT EXECUTION =========="
echo "Docker image: ngraph-onnx:ubuntu-16_04"
echo "Docker container: ${DOCKER_CONTAINER}"
echo "Directory: ${HOME}/ONNX_CI"
echo "Multiple files generated during tox execution"
echo ""
echo "TO REMOVE THEM RUN THIS SCRIPT WITH PARAMETER: --cleanup"
CLONE_CMD='cd /root &&\
if [[ -z $(ls /root/ngraph-onnx 2>/dev/null) ]]; then
git clone '"${NGRAPH_ONNX_REPO}"';
fi'
docker exec "${DOCKER_CONTAINER}" bash -c "${CLONE_CMD}"
NGRAPH_WHL=$(docker exec ${DOCKER_CONTAINER} find /root/python/dist/ -name "ngraph*.whl")
docker exec -e TOX_INSTALL_NGRAPH_FROM="${NGRAPH_WHL}" "${DOCKER_CONTAINER}" tox -c /root/ngraph-onnx/
}
# Function cleanup() removes items related to nGraph, created during script execution
function cleanup_ngraph() {
set -x
docker exec "${DOCKER_CONTAINER}" bash -c 'rm -rf /root/build/* /root/ngraph_dist /root/python/dist'
}
# Function cleanup() removes items created during script execution
function cleanup() {
docker exec "${DOCKER_CONTAINER}" bash -c 'rm -rf /home/$(find /home/ -user root)'
rm -rf ${HOME}/ONNX_CI
docker exec "${DOCKER_CONTAINER}" bash -c 'rm -rf /root/$(find /root/ -user root)'
set -x
docker exec "${DOCKER_CONTAINER}" bash -c "rm -rf /root/ngraph_dist /root/ngraph-onnx/.tox /root/ngraph-onnx/.onnx \
/root/ngraph-onnx/__pycache__ /root/ngraph-onnx/ngraph_onnx.egg-info /root/ngraph-onnx/cpu_codegen"
docker exec "${DOCKER_CONTAINER}" bash -c 'rm -rf $(find /root/ -user root)'
docker rm -f "${DOCKER_CONTAINER}"
docker rmi --force ngraph-onnx:ubuntu-16_04
}
PATTERN='[-a-zA-Z0-9_]*='
......@@ -61,10 +90,15 @@ for i in "$@"
do
case $i in
--help*)
printf "Following parameters are available:
printf "Script builds nGraph and runs tox tests inside docker container.
Every execution after first run is going to run tox tests again.
To rebuild nGraph and run tests again use --rebuild parameter.
Following parameters are available:
--help displays this message
--cleanup removes docker image, container and files created during script execution
--help displays this message
--cleanup removes docker container and files created during script execution
--rebuild rebuilds nGraph and runs tox tests
"
exit 0
;;
......@@ -72,6 +106,10 @@ do
cleanup
exit 0
;;
--rebuild*)
cleanup_ngraph
BUILD="TRUE"
;;
esac
done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment