Skip to content

Commit eed6e2a

Browse files
committed
rollback not needed changes
1 parent e00136b commit eed6e2a

File tree

5 files changed

+64
-71
lines changed

5 files changed

+64
-71
lines changed

bin/pyspark

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ export PYSPARK_SUBMIT_ARGS
8787
if [[ -n "$SPARK_TESTING" ]]; then
8888
unset YARN_CONF_DIR
8989
unset HADOOP_CONF_DIR
90-
exec "$PYSPARK_PYTHON" $1
90+
if [[ -n "$PYSPARK_DOC_TEST" ]]; then
91+
exec "$PYSPARK_PYTHON" -m doctest $1
92+
else
93+
exec "$PYSPARK_PYTHON" $1
94+
fi
9195
exit
9296
fi
9397

python/pyspark/accumulators.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,3 @@ def _start_update_server():
256256
thread.daemon = True
257257
thread.start()
258258
return server
259-
260-
261-
if __name__ == "__main__":
262-
import doctest
263-
doctest.testmod()

python/pyspark/serializers.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,3 @@ def write_int(value, stream):
526526
def write_with_length(obj, stream):
527527
write_int(len(obj), stream)
528528
stream.write(obj)
529-
530-
531-
if __name__ == "__main__":
532-
import doctest
533-
doctest.testmod()

python/pyspark/streaming/tests.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,25 @@ def func(a, b):
341341
expected = [[('a', (1, None)), ('b', (2, 3)), ('c', (None, 4))]]
342342
self._test_func(input, func, expected, True, input2)
343343

344+
def update_state_by_key(self):
345+
346+
def updater(it):
347+
for k, vs, s in it:
348+
if not s:
349+
s = vs
350+
else:
351+
s.extend(vs)
352+
yield (k, s)
353+
354+
input = [[('k', i)] for i in range(5)]
355+
356+
def func(dstream):
357+
return dstream.updateStateByKey(updater)
358+
359+
expected = [[0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4]]
360+
expected = [[('k', v)] for v in expected]
361+
self._test_func(input, func, expected)
362+
344363

345364
class TestWindowFunctions(PySparkStreamingTestCase):
346365

@@ -398,25 +417,6 @@ def test_reduce_by_invalid_window(self):
398417
self.assertRaises(ValueError, lambda: d1.reduceByKeyAndWindow(None, None, 0.1, 0.1))
399418
self.assertRaises(ValueError, lambda: d1.reduceByKeyAndWindow(None, None, 1, 0.1))
400419

401-
def update_state_by_key(self):
402-
403-
def updater(it):
404-
for k, vs, s in it:
405-
if not s:
406-
s = vs
407-
else:
408-
s.extend(vs)
409-
yield (k, s)
410-
411-
input = [[('k', i)] for i in range(5)]
412-
413-
def func(dstream):
414-
return dstream.updateStateByKey(updater)
415-
416-
expected = [[0], [0, 1], [0, 1, 2], [0, 1, 2, 3], [0, 1, 2, 3, 4]]
417-
expected = [[('k', v)] for v in expected]
418-
self._test_func(input, func, expected)
419-
420420

421421
class TestStreamingContext(PySparkStreamingTestCase):
422422

python/run-tests

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -48,39 +48,6 @@ function run_test() {
4848
fi
4949
}
5050

51-
function run_core_tests() {
52-
run_test "pyspark/conf.py"
53-
run_test "pyspark/context.py"
54-
run_test "pyspark/broadcast.py"
55-
run_test "pyspark/accumulators.py"
56-
run_test "pyspark/serializers.py"
57-
run_test "pyspark/shuffle.py"
58-
run_test "pyspark/rdd.py"
59-
run_test "pyspark/tests.py"
60-
}
61-
62-
function run_sql_tests() {
63-
run_test "pyspark/sql.py"
64-
}
65-
66-
function run_mllib_tests() {
67-
run_test "pyspark/mllib/util.py"
68-
run_test "pyspark/mllib/linalg.py"
69-
run_test "pyspark/mllib/classification.py"
70-
run_test "pyspark/mllib/clustering.py"
71-
run_test "pyspark/mllib/random.py"
72-
run_test "pyspark/mllib/recommendation.py"
73-
run_test "pyspark/mllib/regression.py"
74-
run_test "pyspark/mllib/stat.py"
75-
run_test "pyspark/mllib/tree.py"
76-
run_test "pyspark/mllib/tests.py"
77-
}
78-
79-
function run_streaming_tests() {
80-
run_test "pyspark/streaming/util.py"
81-
run_test "pyspark/streaming/tests.py"
82-
}
83-
8451
echo "Running PySpark tests. Output is in python/unit-tests.log."
8552

8653
export PYSPARK_PYTHON="python"
@@ -93,21 +60,53 @@ fi
9360
echo "Testing with Python version:"
9461
$PYSPARK_PYTHON --version
9562

96-
run_core_tests
97-
run_sql_tests
98-
run_mllib_tests
99-
run_streaming_tests
63+
run_test "pyspark/rdd.py"
64+
run_test "pyspark/context.py"
65+
run_test "pyspark/conf.py"
66+
run_test "pyspark/sql.py"
67+
# These tests are included in the module-level docs, and so must
68+
# be handled on a higher level rather than within the python file.
69+
export PYSPARK_DOC_TEST=1
70+
run_test "pyspark/broadcast.py"
71+
run_test "pyspark/accumulators.py"
72+
run_test "pyspark/serializers.py"
73+
unset PYSPARK_DOC_TEST
74+
run_test "pyspark/shuffle.py"
75+
run_test "pyspark/tests.py"
76+
run_test "pyspark/mllib/classification.py"
77+
run_test "pyspark/mllib/clustering.py"
78+
run_test "pyspark/mllib/linalg.py"
79+
run_test "pyspark/mllib/random.py"
80+
run_test "pyspark/mllib/recommendation.py"
81+
run_test "pyspark/mllib/regression.py"
82+
run_test "pyspark/mllib/stat.py"
83+
run_test "pyspark/mllib/tests.py"
84+
run_test "pyspark/mllib/tree.py"
85+
run_test "pyspark/mllib/util.py"
86+
run_test "pyspark/streaming/util.py"
87+
run_test "pyspark/streaming/tests.py"
10088

10189
# Try to test with PyPy
10290
if [ $(which pypy) ]; then
10391
export PYSPARK_PYTHON="pypy"
10492
echo "Testing with PyPy version:"
10593
$PYSPARK_PYTHON --version
10694

107-
run_core_tests
108-
run_sql_tests
109-
run_mllib_tests
110-
run_streaming_tests
95+
run_test "pyspark/rdd.py"
96+
run_test "pyspark/context.py"
97+
run_test "pyspark/conf.py"
98+
run_test "pyspark/sql.py"
99+
# These tests are included in the module-level docs, and so must
100+
# be handled on a higher level rather than within the python file.
101+
export PYSPARK_DOC_TEST=1
102+
run_test "pyspark/broadcast.py"
103+
run_test "pyspark/accumulators.py"
104+
run_test "pyspark/serializers.py"
105+
unset PYSPARK_DOC_TEST
106+
run_test "pyspark/shuffle.py"
107+
run_test "pyspark/tests.py"
108+
run_test "pyspark/streaming/util.py"
109+
run_test "pyspark/streaming/tests.py"
111110
fi
112111

113112
if [[ $FAILED == 0 ]]; then

0 commit comments

Comments
 (0)