From c10bd61648ee68cbd4ebd677948e5c121a2f4315 Mon Sep 17 00:00:00 2001
From: Yaman Umuroglu <yamanu@xilinx.com>
Date: Thu, 17 Oct 2019 11:11:53 +0100
Subject: [PATCH] [Docker] mount all deps from host, rm tmp files, run test

---
 Dockerfile    | 12 +++++-------
 run-docker.sh | 20 ++++++++++++++++++--
 2 files changed, 23 insertions(+), 9 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 09577dff5..d68bf0abf 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -3,21 +3,19 @@ MAINTAINER Yaman Umuroglu <yamanu@xilinx.com>
 ARG PYTHON_VERSION=3.6
 
 WORKDIR /workspace
-RUN git clone https://github.com/maltanar/brevitas_cnv_lfc.git
-# Assume brevitas is cloned on host and mounted, see below.
-#RUN git clone --branch feature/finn_onnx_export https://github.com/Xilinx/brevitas
-#RUN cd brevitas; pip install .
 
 COPY requirements.txt .
 RUN pip install -r requirements.txt
 RUN rm requirements.txt
 
-
 # Note that we expect the cloned finn directory on the host to be
 # mounted on /workspace/finn -- see run-docker.sh for an example
 # of how to do this.
+# This branch assumes the same for brevitas and brevitas_cnv_lfc for easier
+# co-development.
 ENV PYTHONPATH "${PYTHONPATH}:/workspace/finn/src"
 ENV PYTHONPATH "${PYTHONPATH}:/workspace/brevitas_cnv_lfc/training_scripts"
 
-# And this branch assumes the same for brevitas for easier co-development.
-ENTRYPOINT pip install -e /workspace/brevitas && /bin/bash
+WORKDIR /workspace/finn
+
+ENTRYPOINT pip install -e /workspace/brevitas && python setup.py test; /bin/bash
diff --git a/run-docker.sh b/run-docker.sh
index d8a34ca26..291f89415 100755
--- a/run-docker.sh
+++ b/run-docker.sh
@@ -4,12 +4,28 @@
 SCRIPT=$(readlink -f "$0")
 # Absolute path this script is in, thus /home/user/bin
 SCRIPTPATH=$(dirname "$SCRIPT")
+
+BREVITAS_REPO=https://github.com/Xilinx/brevitas.git
+EXAMPLES_REPO=https://github.com/maltanar/brevitas_cnv_lfc.git
+
+BREVITAS_LOCAL=$SCRIPTPATH/brevitas
+EXAMPLES_LOCAL=$SCRIPTPATH/brevitas_cnv_lfc
+
+# clone dependency repos
+git clone --branch feature/finn_onnx_export $BREVITAS_REPO $BREVITAS_LOCAL ||  git -C "$BREVITAS_LOCAL" pull
+git clone $EXAMPLES_REPO $EXAMPLES_LOCAL ||  git -C "$EXAMPLES_LOCAL" pull
+
+# remove possible temp files created from previous execution
+sudo rm -rf .eggs tests/__pycache__/
+
 echo "Mounting $SCRIPTPATH into /workspace/finn"
-echo "Mounting $SCRIPTPATH/../brevitas into /workspace/brevitas"
+echo "Mounting $SCRIPTPATH/brevitas into /workspace/brevitas"
+echo "Mounting $SCRIPTPATH/brevitas_cnv_lfc into /workspace/brevitas_cnv_lfc"
 # Build the FINN Docker image
 docker build --tag=finn .
 # Launch container with current directory mounted
 docker run --rm --name finn_dev -it \
 -v $SCRIPTPATH:/workspace/finn \
--v $SCRIPTPATH/../brevitas:/workspace/brevitas \
+-v $SCRIPTPATH/brevitas:/workspace/brevitas \
+-v $SCRIPTPATH/brevitas_cnv_lfc:/workspace/brevitas_cnv_lfc \
 finn bash
-- 
GitLab