Skip to content

Commit eca77ca

Browse files
tomasatdatabricksthunterdb
authored andcommitted
Dockerized tests in order to run in Ubuntu 16.04 (required by tf >= 1.5) (#143)
* Dockerized tests in order to run in Ubuntu 16.04 (required by tf >= 1.5) * Udpated Readme.md to recommend using conda environment.
1 parent 37e2c08 commit eca77ca

File tree

4 files changed

+75
-48
lines changed

4 files changed

+75
-48
lines changed

.travis.yml

Lines changed: 62 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
dist: xenial
1+
dist: trusty
22

33
language: java
44

55
jdk: oraclejdk8
66

77
sudo: required
88

9+
services:
10+
- docker
11+
912
cache:
1013
directories:
1114
- $HOME/.ivy2/
@@ -28,9 +31,6 @@ env:
2831
- SCALA_BINARY_VERSION=2.10.6 SPARK_VERSION=2.2.0 SPARK_BUILD="spark-2.2.0-bin-hadoop2.7"
2932
SPARK_BUILD_URL="http://d3kbcqa49mib13.cloudfront.net/spark-2.2.0-bin-hadoop2.7.tgz"
3033
TF_PY2_BUILD=tensorflow-1.3.0-cp27-none-linux_x86_64.whl PYTHON_VERSION=3.6.2
31-
- SCALA_BINARY_VERSION=2.11.8 SPARK_VERSION=2.0.2 SPARK_BUILD="spark-2.0.2-bin-hadoop2.7"
32-
SPARK_BUILD_URL="http://d3kbcqa49mib13.cloudfront.net/spark-2.0.2-bin-hadoop2.7.tgz"
33-
TF_PY2_BUILD=tensorflow-1.3.0-cp27-none-linux_x86_64.whl PYTHON_VERSION=2.7.13
3434
- SCALA_BINARY_VERSION=2.11.8 SPARK_VERSION=2.1.1 SPARK_BUILD="spark-2.1.1-bin-hadoop2.7"
3535
SPARK_BUILD_URL="http://d3kbcqa49mib13.cloudfront.net/spark-2.1.1-bin-hadoop2.7.tgz"
3636
TF_PY2_BUILD=tensorflow-1.3.0-cp27-none-linux_x86_64.whl PYTHON_VERSION=2.7.13
@@ -52,45 +52,68 @@ env:
5252
PYTHON_VERSION=3.6.2
5353

5454
before_install:
55-
- ./bin/download_travis_dependencies.sh
55+
- ./bin/download_travis_dependencies.sh
56+
- if [[ "$PYTHON_VERSION" == 2.* ]]; then
57+
export CONDA_URL="repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh"
58+
export PYSPARK_PYTHON=python2;
59+
else
60+
export CONDA_URL="repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh";
61+
export PYSPARK_PYTHON=python3;
62+
fi
63+
- docker run -e "JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64"
64+
-e SPARK_VERSION
65+
-e SPARK_BUILD
66+
-e SCALA_BINARY_VERSION
67+
-e PYTHON_VERSION
68+
-e PYSPARK_PYTHON
69+
-e CONDA_URL
70+
-d --name ubuntu-test -v $HOME ubuntu:16.04 tail -f /dev/null
71+
- docker cp `pwd` ubuntu-test:$HOME/
72+
- docker cp $HOME/.cache ubuntu-test:$HOME/
73+
- docker ps
5674

5775
# See this page: http://conda.pydata.org/docs/travis.html
5876
install:
59-
- sudo apt-get update
60-
# We do this conditionally because it saves us some downloading if the
61-
# version is the same.
62-
- if [[ "$PYTHON_VERSION" == 2.* ]]; then
63-
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh;
64-
export PYSPARK_PYTHON=python2;
65-
else
66-
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
67-
export PYSPARK_PYTHON=python3;
68-
fi
69-
- bash miniconda.sh -b -p $HOME/miniconda
70-
- export PATH="$HOME/miniconda/bin:$PATH"
71-
- hash -r
72-
- conda config --set always_yes yes --set changeps1 no
73-
- conda update -q conda
74-
# Useful for debugging any issues with conda
75-
- conda info -a
77+
# install needed ubuntu packages
78+
- docker exec -t ubuntu-test bash -c "apt-get update && apt-get upgrade -y"
79+
- docker exec -t ubuntu-test bash -c "apt-get install -y curl bzip2 openjdk-8-jdk"
80+
# download and set up miniconda
81+
- docker exec -t ubuntu-test bash -c "
82+
curl https://$CONDA_URL >> $HOME/miniconda.sh;
83+
bash $HOME/miniconda.sh -b -p $HOME/miniconda;
84+
bash $HOME/miniconda.sh -b -p $HOME/miniconda;
85+
$HOME/miniconda/bin/conda config --set always_yes yes --set changeps1 no;
86+
$HOME/miniconda/bin/conda update -q conda;
87+
$HOME/miniconda/bin/conda info -a;
88+
$HOME/miniconda/bin/conda create -q -n test-environment python=$PYTHON_VERSION"
7689

77-
# Create and activate conda environment
78-
- conda create -q -n test-environment python=$PYTHON_VERSION
79-
- source activate test-environment
80-
# Log python & pip versions
81-
- python --version
82-
- pip --version
83-
# Install dependencies from requirements.txt
84-
- pip install --user -r ./python/requirements.txt
85-
# Install tensorflow
86-
- pip install --user tensorflow==1.6
90+
# Activate conda environment ad install required packages
91+
- docker exec -t ubuntu-test bash -c "
92+
source $HOME/miniconda/bin/activate test-environment;
93+
python --version;
94+
pip --version;
95+
pip install --user -r $HOME/tensorframes/python/requirements.txt;"
8796

8897
script:
89-
- rm -rf /home/travis/.javacpp
90-
# Manually remove previous versions, otherwise the snaphsot will not get updated.
91-
- rm -rf /home/travis/.ivy2/cache/org.bytedeco.javacpp-presets/*
9298
# Run the scala unit tests first
93-
- sbt -Dspark.version=$SPARK_VERSION -Dpython.version=$PYSPARK_PYTHON -Dscala.version=$SCALA_BINARY_VERSION tfs_testing/test
94-
# Run the python unit tests.
95-
- sbt -Dspark.version=$SPARK_VERSION -Dscala.version=$SCALA_BINARY_VERSION tfs_testing/assembly
96-
- SPARK_HOME=$HOME/.cache/spark-versions/$SPARK_BUILD ./python/run-tests.sh
99+
- docker exec -t ubuntu-test bash -c "
100+
source $HOME/miniconda/bin/activate test-environment;
101+
cd $HOME/tensorframes;
102+
./build/sbt -Dspark.version=$SPARK_VERSION
103+
-Dpython.version=$PYSPARK_PYTHON
104+
-Dscala.version=$SCALA_BINARY_VERSION
105+
tfs_testing/test"
106+
107+
# Build the assembly
108+
- docker exec -t ubuntu-test bash -c "
109+
source $HOME/miniconda/bin/activate test-environment;
110+
cd $HOME/tensorframes;
111+
./build/sbt -Dspark.version=$SPARK_VERSION
112+
-Dscala.version=$SCALA_BINARY_VERSION
113+
tfs_testing/assembly"
114+
115+
# Run python tests
116+
- docker exec -t ubuntu-test bash -c "
117+
source $HOME/miniconda/bin/activate test-environment;
118+
cd $HOME/tensorframes;
119+
SPARK_HOME=$HOME/.cache/spark-versions/$SPARK_BUILD ./python/run-tests.sh"

README.md

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,20 +178,23 @@ df2.collect()
178178
```
179179

180180
## How to compile and install for developers
181-
182-
It is recommended you use [Nix](http://nixos.org/nix/) to guarantee that the build environment
183-
can be reproduced. Once you have installed Nix, you can set the environment from
181+
It is recommended you use [Conda Environment](https://conda.io/docs/user-guide/tasks/manage-environments.html) to guarantee that the build environment
182+
can be reproduced. Once you have installed Conda, you can set the environment from
184183
the root of project:
185184

186185
```bash
187-
nix-shell --pure default.nix
186+
conda create -q -n tensorframes-environment python=$PYTHON_VERSION
188187
```
189188

190-
This will create a python 2.7 environment with all the dependencies. If you
191-
want to work with Python 3.5, use `default-3.5.nix` instead.
189+
This will create an environment for your project. We recommend using Python version 3.6.2 or 2.7.13.
190+
After the environemnt is created, you can activate it and install all dependencies as follows:
191+
192+
```bash
193+
conda activate tensorframes-environment
194+
pip install --user -r python/requirements.txt
195+
```
192196

193-
The C++ bindings are already compiled though, so you should only have to deal with compiling
194-
the scala code. The recommended procedure is to use the assembly:
197+
You also need to compile the scala code. The recommended procedure is to use the assembly:
195198

196199
```bash
197200
build/sbt tfs_testing/assembly

python/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
# This file should list any python package dependencies.
22
nose>=1.3.3
33
pandas>=0.19.1
4+
tensorflow==1.6

python/run-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ export TF_CPP_MIN_LOG_LEVEL=2 # Warning level
9393
if [[ "$python_major" == "2" ]]; then
9494

9595
# Horrible hack for spark 1.x: we manually remove some log lines to stay below the 4MB log limit on Travis.
96-
$PYSPARK_DRIVER_PYTHON `which nosetests` -v --all-modules -w "$PROJECT_HOME/src/main/python" 2>&1 | grep -vE "INFO (ParquetOutputFormat|SparkContext|ContextCleaner|ShuffleBlockFetcherIterator|MapOutputTrackerMaster|TaskSetManager|Executor|MemoryStore|CacheManager|BlockManager|DAGScheduler|PythonRDD|TaskSchedulerImpl|ZippedPartitionsRDD2)";
96+
$PYSPARK_DRIVER_PYTHON -m "nose" -v --all-modules -w "$PROJECT_HOME/src/main/python" 2>&1 | grep -vE "INFO (ParquetOutputFormat|SparkContext|ContextCleaner|ShuffleBlockFetcherIterator|MapOutputTrackerMaster|TaskSetManager|Executor|MemoryStore|CacheManager|BlockManager|DAGScheduler|PythonRDD|TaskSchedulerImpl|ZippedPartitionsRDD2)";
9797

9898
else
9999

0 commit comments

Comments
 (0)