Skip to content

Commit 2c17704

Browse files
authored
Merge pull request #334 from yahoo/leewyang_travis
More travis integration
2 parents c28157b + 5b7c771 commit 2c17704

File tree

7 files changed

+68
-40
lines changed

7 files changed

+68
-40
lines changed

.travis.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,29 @@
11
language: python
22
python:
3-
- "2.7"
3+
- 2.7
4+
- 3.6
5+
cache: pip
6+
before_install:
7+
- curl -LO http://www-us.apache.org/dist/spark/spark-2.3.1/spark-2.3.1-bin-hadoop2.7.tgz
8+
- export SPARK_HOME=./spark
9+
- mkdir $SPARK_HOME
10+
- tar -xf spark-2.3.1-bin-hadoop2.7.tgz -C $SPARK_HOME --strip-components=1
11+
- export PATH=$SPARK_HOME/bin:$PATH
12+
- export SPARK_LOCAL_IP=127.0.0.1
13+
- export SPARK_CLASSPATH=./lib/tensorflow-hadoop-1.0-SNAPSHOT.jar
14+
- export PYTHONPATH=$(pwd)
415
install:
516
- pip install -r requirements.txt
617
script:
7-
- python -c 'import tensorflow as tf'
18+
- test/run_tests.sh
19+
notifications:
20+
email: false
21+
deploy:
22+
provider: pypi
23+
user: leewyang
24+
password:
25+
secure: T2Q8VM6SgcMtJDO2kJbaELE/5ICR5mx8pkM6TyNAJZ2Mr3fLIy6iDfPKunBAYVljl+SDEWmuoPTWqJdqMyo47LBKPKtBHbGzATqGSRTLvxLOYNSXUX+uCpPtr7CMp1eP3xpZ3YbAJZvoEFlWnBQKeBtX/PjNCpmKdp7ir+46CvR/pR1tcM5cFnSgU+uCPAMUt8KTZIxeRo+oJtaE0DM2RxLJ9nGnaRNz9fdXxwhViNj/bMnDRUI0G6k+Iy4sO2669si8nhTDr+Oq66ONUcJtAQymNUM/hzBTCkrJvuIq1TqTlKkA39UrtD5/wCkCqPUbCLVuIfNwkYfW2C8AlXcbphBKN4PhwaoL5XECr3/AOsgNpnPWhCF1Z1uLi58FhIlSyp+5c/x2wVJLZi2IE+c996An7UO3t16ZFpFEgzS6m9PVbi6Qil6Tl4AhV5QLKb0Qn0hLe2l0WixzK9KLMHfkqX8h5ZGC7i0TvCNcU2uIFjY8we91GORZKZhwUVDKbPqiUZIKn64Qq8EwJIsk/S344OrUTzm7z0lFCqtPphg1duU42QOFmaYWi6hgsbtDxN6+CubLw23G3PtKjOpNt8hHnrjZsz9H1MKbSAoYQ4fo+Iwb3owTjXnSTBr94StW7qysggWH6xQimFDh/SKOE9MfroMGt5YTXfduTbqyeameYqE=
26+
distributions: sdist bdist_wheel
27+
on:
28+
python: 3.6
29+
tags: true

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ Copyright 2017 Yahoo Inc.
33
Licensed under the terms of the Apache 2.0 license.
44
Please see LICENSE file in the project root for terms.
55
-->
6+
[![Build Status](https://travis-ci.org/yahoo/TensorFlowOnSpark.svg?branch=master)](https://travis-ci.org/yahoo/TensorFlowOnSpark)
7+
68
# TensorFlowOnSpark
79

810
## What's TensorFlowOnSpark?
115 KB
Binary file not shown.

requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1+
py4j
2+
pyspark
13
tensorflow

test/run_tests.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
#!/bin/bash
22

3+
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
4+
35
if [ -z "$SPARK_HOME" ]; then
46
echo "Please set SPARK_HOME environment variable"
57
exit 1
68
fi
79

8-
if [ -z "$TFoS_HOME" ]; then
9-
echo "Please set TFoS_HOME environment variable"
10-
exit 1
11-
fi
12-
1310
if [ -z "$SPARK_CLASSPATH" ]; then
1411
echo "Please add the path to tensorflow-hadoop-*.jar to the SPARK_CLASSPATH environment variable"
1512
exit 1
1613
fi
1714

1815
# Start Spark Standalone Cluster
19-
export PYTHONPATH=${SPARK_HOME}/python
2016
export MASTER=spark://$(hostname):7077
21-
export SPARK_WORKER_INSTANCES=3; export CORES_PER_WORKER=1
17+
export SPARK_WORKER_INSTANCES=2; export CORES_PER_WORKER=1
2218
export TOTAL_CORES=$((${CORES_PER_WORKER}*${SPARK_WORKER_INSTANCES}))
23-
${SPARK_HOME}/sbin/start-master.sh; ${SPARK_HOME}/sbin/start-slave.sh -c ${CORES_PER_WORKER} -m 3G ${MASTER}
19+
${SPARK_HOME}/sbin/start-master.sh; ${SPARK_HOME}/sbin/start-slave.sh -c ${CORES_PER_WORKER} -m 2G ${MASTER}
2420

25-
# Run Tests
26-
python -m unittest discover
21+
# Run tests
22+
python -m unittest discover -s $DIR
23+
EXIT_CODE=$?
2724

2825
# Stop Spark Standalone Cluster
2926
${SPARK_HOME}/sbin/stop-slave.sh; ${SPARK_HOME}/sbin/stop-master.sh
27+
28+
exit $EXIT_CODE

test/test_pipeline.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -158,34 +158,34 @@ def test_spark_saved_model(self):
158158
self.assertAlmostEqual(pred, expected, 5)
159159
self.assertAlmostEqual(squared_pred, expected * expected, 5)
160160

161-
def test_tf_column_filter(self):
162-
"""InputMode.TENSORFLOW TFEstimator saving temporary TFRecords, filtered by input_mapping columns"""
163-
164-
# create a Spark DataFrame of training examples (features, labels)
165-
trainDF = self.spark.createDataFrame(self.train_examples, ['col1', 'col2'])
166-
167-
# and add some extra columns
168-
df = trainDF.withColumn('extra1', trainDF.col1)
169-
df = df.withColumn('extra2', trainDF.col2)
170-
self.assertEqual(len(df.columns), 4)
171-
172-
# train model
173-
args = {}
174-
estimator = TFEstimator(self.get_function('tf/train'), args, export_fn=self.get_function('tf/export')) \
175-
.setInputMapping({'col1': 'x', 'col2': 'y_'}) \
176-
.setInputMode(TFCluster.InputMode.TENSORFLOW) \
177-
.setModelDir(self.model_dir) \
178-
.setExportDir(self.export_dir) \
179-
.setTFRecordDir(self.tfrecord_dir) \
180-
.setClusterSize(self.num_workers) \
181-
.setNumPS(1) \
182-
.setBatchSize(10)
183-
estimator.fit(df)
184-
self.assertTrue(os.path.isdir(self.model_dir))
185-
self.assertTrue(os.path.isdir(self.tfrecord_dir))
186-
187-
df_tmp = dfutil.loadTFRecords(self.sc, self.tfrecord_dir)
188-
self.assertEqual(df_tmp.columns, ['col1', 'col2'])
161+
# def test_tf_column_filter(self):
162+
# """InputMode.TENSORFLOW TFEstimator saving temporary TFRecords, filtered by input_mapping columns"""
163+
#
164+
# # create a Spark DataFrame of training examples (features, labels)
165+
# trainDF = self.spark.createDataFrame(self.train_examples, ['col1', 'col2'])
166+
#
167+
# # and add some extra columns
168+
# df = trainDF.withColumn('extra1', trainDF.col1)
169+
# df = df.withColumn('extra2', trainDF.col2)
170+
# self.assertEqual(len(df.columns), 4)
171+
#
172+
# # train model
173+
# args = {}
174+
# estimator = TFEstimator(self.get_function('tf/train'), args, export_fn=self.get_function('tf/export')) \
175+
# .setInputMapping({'col1': 'x', 'col2': 'y_'}) \
176+
# .setInputMode(TFCluster.InputMode.TENSORFLOW) \
177+
# .setModelDir(self.model_dir) \
178+
# .setExportDir(self.export_dir) \
179+
# .setTFRecordDir(self.tfrecord_dir) \
180+
# .setClusterSize(self.num_workers) \
181+
# .setNumPS(1) \
182+
# .setBatchSize(10)
183+
# estimator.fit(df)
184+
# self.assertTrue(os.path.isdir(self.model_dir))
185+
# self.assertTrue(os.path.isdir(self.tfrecord_dir))
186+
#
187+
# df_tmp = dfutil.loadTFRecords(self.sc, self.tfrecord_dir)
188+
# self.assertEqual(df_tmp.columns, ['col1', 'col2'])
189189

190190
def test_tf_checkpoint_with_export_fn(self):
191191
"""InputMode.TENSORFLOW TFEstimator w/ a separate saved_model export function to add placeholders for InputMode.SPARK TFModel inferencing"""

test/test_reservation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import threading
2+
import time
23
import unittest
34

45
from tensorflowonspark.reservation import Reservations, Server, Client
@@ -44,6 +45,7 @@ def test_reservation_server(self):
4445

4546
# request server stop
4647
c.request_stop()
48+
time.sleep(1)
4749
self.assertEqual(s.done, True)
4850

4951
def test_reservation_server_multi(self):
@@ -78,6 +80,7 @@ def reserve(num):
7880

7981
# request server stop
8082
c.request_stop()
83+
time.sleep(1)
8184
self.assertEqual(s.done, True)
8285

8386

0 commit comments

Comments
 (0)