[
https://issues.apache.org/jira/browse/SPARK-7721?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16305103#comment-16305103
]
Hyukjin Kwon commented on SPARK-7721:
-------------------------------------
Hey [~rxin], I think I made it now by few modification of the script and
forcing {{worker.py}} to produce the coverage results.
I ran it by Python 3 and Coverage 4.4 and all tests passed and just updated the
site - https://spark-test.github.io/pyspark-coverage-site
FYI, here is the diff I used in the main codes to force it to produces (15ish
lines addition)
{code}
diff --git a/python/pyspark/worker.py b/python/pyspark/worker.py
index e6737ae1c12..088debcf796 100644
--- a/python/pyspark/worker.py
+++ b/python/pyspark/worker.py
@@ -159,7 +159,7 @@ def read_udfs(pickleSer, infile, eval_type):
return func, None, ser, ser
-def main(infile, outfile):
+def _main(infile, outfile):
try:
boot_time = time.time()
split_index = read_int(infile)
@@ -259,6 +259,22 @@ def main(infile, outfile):
exit(-1)
+if "COVERAGE_PROCESS_START" in os.environ:
+ def _cov_wrapped(*args, **kwargs):
+ import coverage
+ cov = coverage.coverage(
+ config_file=os.environ["COVERAGE_PROCESS_START"])
+ cov.start()
+ try:
+ _main(*args, **kwargs)
+ finally:
+ cov.stop()
+ cov.save()
+ main = _cov_wrapped
+else:
+ main = _main
+
+
if __name__ == '__main__':
# Read a local port to connect to from stdin
java_port = int(sys.stdin.readline())
{code}
> Generate test coverage report from Python
> -----------------------------------------
>
> Key: SPARK-7721
> URL: https://issues.apache.org/jira/browse/SPARK-7721
> Project: Spark
> Issue Type: Test
> Components: PySpark, Tests
> Reporter: Reynold Xin
>
> Would be great to have test coverage report for Python. Compared with Scala,
> it is tricker to understand the coverage without coverage reports in Python
> because we employ both docstring tests and unit tests in test files.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]