From 7a7876be5cd7e43d8fbde2e632fd4b000d4fb973 Mon Sep 17 00:00:00 2001 From: Holden Karau Date: Tue, 19 May 2015 17:54:05 -0700 Subject: [PATCH 1/3] Add a startTime property to match the corresponding one in the Scala SparkContext --- python/pyspark/context.py | 6 +++++- python/pyspark/tests.py | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/python/pyspark/context.py b/python/pyspark/context.py index 1f2b40b29faf..2ce0ca38e9c7 100644 --- a/python/pyspark/context.py +++ b/python/pyspark/context.py @@ -291,6 +291,11 @@ def version(self): """ return self._jsc.version() + @property + def startTime(self): + """Return the epoch time when the Spark Context was started.""" + return self._jsc.startTime() + @property def defaultParallelism(self): """ @@ -885,7 +890,6 @@ def dump_profiles(self, path): """ self.profiler_collector.dump_profiles(path) - def _test(): import atexit import doctest diff --git a/python/pyspark/tests.py b/python/pyspark/tests.py index d8e319994cc9..94a113c94a11 100644 --- a/python/pyspark/tests.py +++ b/python/pyspark/tests.py @@ -1809,6 +1809,9 @@ def run(): sc.stop() + def test_startTime(self): + with SparkContext() as sc: + self.assertGreater(sc.startTime, 0) @unittest.skipIf(not _have_scipy, "SciPy not installed") class SciPyTests(PySparkTestCase): From 7a87410bac59fd7a2d4519ac9ae0847b852e28eb Mon Sep 17 00:00:00 2001 From: Holden Karau Date: Tue, 19 May 2015 18:38:54 -0700 Subject: [PATCH 2/3] add back missing newline --- python/pyspark/context.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/pyspark/context.py b/python/pyspark/context.py index 2ce0ca38e9c7..aeb7ad4f2f83 100644 --- a/python/pyspark/context.py +++ b/python/pyspark/context.py @@ -890,6 +890,7 @@ def dump_profiles(self, path): """ self.profiler_collector.dump_profiles(path) + def _test(): import atexit import doctest From 06662dcefe5d792b998b643f57a50a3e197e7a0a Mon Sep 17 00:00:00 2001 From: Holden Karau Date: Wed, 20 May 2015 00:18:21 -0700 Subject: [PATCH 3/3] add mising blank line for style checks --- python/pyspark/tests.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/pyspark/tests.py b/python/pyspark/tests.py index 94a113c94a11..f9fb37f7fc13 100644 --- a/python/pyspark/tests.py +++ b/python/pyspark/tests.py @@ -1813,6 +1813,7 @@ def test_startTime(self): with SparkContext() as sc: self.assertGreater(sc.startTime, 0) + @unittest.skipIf(not _have_scipy, "SciPy not installed") class SciPyTests(PySparkTestCase):