Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/merge_spark_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def main():
import doctest
(failure_count, test_count) = doctest.testmod()
if failure_count:
exit(-1)
sys.exit(-1)
try:
main()
except:
Expand Down
2 changes: 1 addition & 1 deletion dev/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ def _test():
import doctest
failure_count = doctest.testmod()[0]
if failure_count:
exit(-1)
sys.exit(-1)

if __name__ == "__main__":
_test()
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/avro_inputformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
Assumes you have Avro data stored in <data_file>. Reader schema can be optionally specified
in [reader_schema_file].
""", file=sys.stderr)
exit(-1)
sys.exit(-1)

path = sys.argv[1]

Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def closestPoint(p, centers):

if len(sys.argv) != 4:
print("Usage: kmeans <file> <k> <convergeDist>", file=sys.stderr)
exit(-1)
sys.exit(-1)

print("""WARN: This is a naive implementation of KMeans Clustering and is given
as an example! Please refer to examples/src/main/python/ml/kmeans_example.py for an
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def readPointBatch(iterator):

if len(sys.argv) != 3:
print("Usage: logistic_regression <file> <iterations>", file=sys.stderr)
exit(-1)
sys.exit(-1)

print("""WARN: This is a naive implementation of Logistic Regression and is
given as an example!
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/ml/dataframe_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
if __name__ == "__main__":
if len(sys.argv) > 2:
print("Usage: dataframe_example.py <libsvm file>", file=sys.stderr)
exit(-1)
sys.exit(-1)
elif len(sys.argv) == 2:
input = sys.argv[1]
else:
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/mllib/correlations.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
if __name__ == "__main__":
if len(sys.argv) not in [1, 2]:
print("Usage: correlations (<file>)", file=sys.stderr)
exit(-1)
sys.exit(-1)
sc = SparkContext(appName="PythonCorrelations")
if len(sys.argv) == 2:
filepath = sys.argv[1]
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/mllib/kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def parseVector(line):
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: kmeans <file> <k>", file=sys.stderr)
exit(-1)
sys.exit(-1)
sc = SparkContext(appName="KMeans")
lines = sc.textFile(sys.argv[1])
data = lines.map(parseVector)
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/mllib/logistic_regression.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def parsePoint(line):
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: logistic_regression <file> <iterations>", file=sys.stderr)
exit(-1)
sys.exit(-1)
sc = SparkContext(appName="PythonLR")
points = sc.textFile(sys.argv[1]).map(parsePoint)
iterations = int(sys.argv[2])
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/mllib/random_rdd_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
if __name__ == "__main__":
if len(sys.argv) not in [1, 2]:
print("Usage: random_rdd_generation", file=sys.stderr)
exit(-1)
sys.exit(-1)

sc = SparkContext(appName="PythonRandomRDDGeneration")

Expand Down
4 changes: 2 additions & 2 deletions examples/src/main/python/mllib/sampled_rdds.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
if __name__ == "__main__":
if len(sys.argv) not in [1, 2]:
print("Usage: sampled_rdds <libsvm data file>", file=sys.stderr)
exit(-1)
sys.exit(-1)
if len(sys.argv) == 2:
datapath = sys.argv[1]
else:
Expand All @@ -43,7 +43,7 @@
numExamples = examples.count()
if numExamples == 0:
print("Error: Data file had no samples to load.", file=sys.stderr)
exit(1)
sys.exit(1)
print('Loaded data with %d examples from file: %s' % (numExamples, datapath))

# Example: RDD.sample() and RDD.takeSample()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
if len(sys.argv) != 3:
print("Usage: streaming_linear_regression_example.py <trainingDir> <testDir>",
file=sys.stderr)
exit(-1)
sys.exit(-1)

sc = SparkContext(appName="PythonLogisticRegressionWithLBFGSExample")
ssc = StreamingContext(sc, 1)
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/pagerank.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def parseNeighbors(urls):
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: pagerank <file> <iterations>", file=sys.stderr)
exit(-1)
sys.exit(-1)

print("WARN: This is a naive implementation of PageRank and is given as an example!\n" +
"Please refer to PageRank implementation provided by graphx",
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/parquet_inputformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
/path/to/examples/parquet_inputformat.py <data_file>
Assumes you have Parquet data stored in <data_file>.
""", file=sys.stderr)
exit(-1)
sys.exit(-1)

path = sys.argv[1]

Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/sort.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: sort <file>", file=sys.stderr)
exit(-1)
sys.exit(-1)

spark = SparkSession\
.builder\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
print("""
Usage: structured_kafka_wordcount.py <bootstrap-servers> <subscribe-type> <topics>
""", file=sys.stderr)
exit(-1)
sys.exit(-1)

bootstrapServers = sys.argv[1]
subscribeType = sys.argv[2]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: structured_network_wordcount.py <hostname> <port>", file=sys.stderr)
exit(-1)
sys.exit(-1)

host = sys.argv[1]
port = int(sys.argv[2])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
msg = ("Usage: structured_network_wordcount_windowed.py <hostname> <port> "
"<window duration in seconds> [<slide duration in seconds>]")
print(msg, file=sys.stderr)
exit(-1)
sys.exit(-1)

host = sys.argv[1]
port = int(sys.argv[2])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: direct_kafka_wordcount.py <broker_list> <topic>", file=sys.stderr)
exit(-1)
sys.exit(-1)

sc = SparkContext(appName="PythonStreamingDirectKafkaWordCount")
ssc = StreamingContext(sc, 2)
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/streaming/flume_wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: flume_wordcount.py <hostname> <port>", file=sys.stderr)
exit(-1)
sys.exit(-1)

sc = SparkContext(appName="PythonStreamingFlumeWordCount")
ssc = StreamingContext(sc, 1)
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/streaming/hdfs_wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: hdfs_wordcount.py <directory>", file=sys.stderr)
exit(-1)
sys.exit(-1)

sc = SparkContext(appName="PythonStreamingHDFSWordCount")
ssc = StreamingContext(sc, 1)
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/streaming/kafka_wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: kafka_wordcount.py <zk> <topic>", file=sys.stderr)
exit(-1)
sys.exit(-1)

sc = SparkContext(appName="PythonStreamingKafkaWordCount")
ssc = StreamingContext(sc, 1)
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/streaming/network_wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: network_wordcount.py <hostname> <port>", file=sys.stderr)
exit(-1)
sys.exit(-1)
sc = SparkContext(appName="PythonStreamingNetworkWordCount")
ssc = StreamingContext(sc, 1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def print_happiest_words(rdd):
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: network_wordjoinsentiments.py <hostname> <port>", file=sys.stderr)
exit(-1)
sys.exit(-1)

sc = SparkContext(appName="PythonStreamingNetworkWordJoinSentiments")
ssc = StreamingContext(sc, 5)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def filterFunc(wordCount):
if len(sys.argv) != 5:
print("Usage: recoverable_network_wordcount.py <hostname> <port> "
"<checkpoint-directory> <output-file>", file=sys.stderr)
exit(-1)
sys.exit(-1)
host, port, checkpoint, output = sys.argv[1:]
ssc = StreamingContext.getOrCreate(checkpoint,
lambda: createContext(host, int(port), output))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def getSparkSessionInstance(sparkConf):
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: sql_network_wordcount.py <hostname> <port> ", file=sys.stderr)
exit(-1)
sys.exit(-1)
host, port = sys.argv[1:]
sc = SparkContext(appName="PythonSqlNetworkWordCount")
ssc = StreamingContext(sc, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
if __name__ == "__main__":
if len(sys.argv) != 3:
print("Usage: stateful_network_wordcount.py <hostname> <port>", file=sys.stderr)
exit(-1)
sys.exit(-1)
sc = SparkContext(appName="PythonStreamingStatefulNetworkWordCount")
ssc = StreamingContext(sc, 1)
ssc.checkpoint("checkpoint")
Expand Down
2 changes: 1 addition & 1 deletion examples/src/main/python/wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: wordcount <file>", file=sys.stderr)
exit(-1)
sys.exit(-1)

spark = SparkSession\
.builder\
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/accumulators.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,4 @@ def _start_update_server():
import doctest
(failure_count, test_count) = doctest.testmod()
if failure_count:
exit(-1)
sys.exit(-1)
2 changes: 1 addition & 1 deletion python/pyspark/broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,4 +162,4 @@ def clear(self):
import doctest
(failure_count, test_count) = doctest.testmod()
if failure_count:
exit(-1)
sys.exit(-1)
2 changes: 1 addition & 1 deletion python/pyspark/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def _test():
import doctest
(failure_count, test_count) = doctest.testmod(optionflags=doctest.ELLIPSIS)
if failure_count:
exit(-1)
sys.exit(-1)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ def _test():
(failure_count, test_count) = doctest.testmod(globs=globs, optionflags=doctest.ELLIPSIS)
globs['sc'].stop()
if failure_count:
exit(-1)
sys.exit(-1)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/daemon.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def shutdown(code):
signal.signal(SIGTERM, SIG_DFL)
# Send SIGHUP to notify workers of shutdown
os.kill(0, SIGHUP)
exit(code)
sys.exit(code)

def handle_sigterm(*args):
shutdown(1)
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/find_spark_home.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def is_spark_home(path):
return next(path for path in paths if is_spark_home(path))
except StopIteration:
print("Could not find valid SPARK_HOME while searching {0}".format(paths), file=sys.stderr)
exit(-1)
sys.exit(-1)

if __name__ == "__main__":
print(_find_spark_home())
3 changes: 2 additions & 1 deletion python/pyspark/heapq3.py
Original file line number Diff line number Diff line change
Expand Up @@ -884,6 +884,7 @@ def nlargest(n, iterable, key=None):

if __name__ == "__main__":
import doctest
import sys
(failure_count, test_count) = doctest.testmod()
if failure_count:
exit(-1)
sys.exit(-1)
3 changes: 2 additions & 1 deletion python/pyspark/ml/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#

import operator
import sys
from multiprocessing.pool import ThreadPool

from pyspark import since, keyword_only
Expand Down Expand Up @@ -2043,4 +2044,4 @@ def _to_java(self):
except OSError:
pass
if failure_count:
exit(-1)
sys.exit(-1)
4 changes: 3 additions & 1 deletion python/pyspark/ml/clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# limitations under the License.
#

import sys

from pyspark import since, keyword_only
from pyspark.ml.util import *
from pyspark.ml.wrapper import JavaEstimator, JavaModel, JavaWrapper
Expand Down Expand Up @@ -1181,4 +1183,4 @@ def getKeepLastCheckpoint(self):
except OSError:
pass
if failure_count:
exit(-1)
sys.exit(-1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to import sys.

3 changes: 2 additions & 1 deletion python/pyspark/ml/evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.
#

import sys
from abc import abstractmethod, ABCMeta

from pyspark import since, keyword_only
Expand Down Expand Up @@ -446,4 +447,4 @@ def getDistanceMeasure(self):
except OSError:
pass
if failure_count:
exit(-1)
sys.exit(-1)
2 changes: 1 addition & 1 deletion python/pyspark/ml/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -3717,4 +3717,4 @@ def setSize(self, value):
except OSError:
pass
if failure_count:
exit(-1)
sys.exit(-1)
4 changes: 3 additions & 1 deletion python/pyspark/ml/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
:members:
"""

import sys

import numpy as np
from pyspark import SparkContext
from pyspark.sql.types import Row, _create_row, _parse_datatype_json_string
Expand Down Expand Up @@ -251,7 +253,7 @@ def _test():
optionflags=doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE)
spark.stop()
if failure_count:
exit(-1)
sys.exit(-1)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion python/pyspark/ml/linalg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ def _test():
import doctest
(failure_count, test_count) = doctest.testmod(optionflags=doctest.ELLIPSIS)
if failure_count:
exit(-1)
sys.exit(-1)

if __name__ == "__main__":
_test()
Loading