From 7b2d223f44ff24df51b737496a22daa15c2ecd7c Mon Sep 17 00:00:00 2001 From: Imran Rashid Date: Mon, 17 Dec 2018 16:21:17 -0600 Subject: [PATCH] style --- python/pyspark/context.py | 11 ++++++----- python/pyspark/java_gateway.py | 3 ++- python/pyspark/tests.py | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/python/pyspark/context.py b/python/pyspark/context.py index 94a6e4ce8e361..61804aea48e56 100644 --- a/python/pyspark/context.py +++ b/python/pyspark/context.py @@ -112,13 +112,14 @@ def __init__(self, master=None, appName=None, sparkHome=None, pyFiles=None, ValueError:... """ self._callsite = first_spark_call() or CallSite(None, None, None) - if gateway != None and gateway.gateway_parameters.auth_token == None: + if gateway is not None and gateway.gateway_parameters.auth_token is None: if conf and conf.get("spark.python.allowInsecurePy4j", "false") == "true": - print("****BAM****") - warnings.warn("You are passing in an insecure py4j gateway. This " - "presents a security risk, and will be completely forbidden in Spark 3.0") + warnings.warn( + "You are passing in an insecure py4j gateway. This " + "presents a security risk, and will be completely forbidden in Spark 3.0") else: - raise Exception("You are trying to pass an insecure py4j gateway to spark. This" + raise Exception( + "You are trying to pass an insecure py4j gateway to spark. This" " presents a security risk. If you are sure you understand and accept this" " risk, you can add the conf 'spark.python.allowInsecurePy4j=true', but" " note this option will be removed in Spark 3.0") diff --git a/python/pyspark/java_gateway.py b/python/pyspark/java_gateway.py index ce261b9fcad04..7c795156e374e 100644 --- a/python/pyspark/java_gateway.py +++ b/python/pyspark/java_gateway.py @@ -45,6 +45,7 @@ def launch_gateway(conf=None): """ return _launch_gateway(conf) + def _launch_gateway(conf=None, insecure=False): """ launch jvm gateway @@ -130,7 +131,7 @@ def killChild(): # Connect to the gateway gateway_params = GatewayParameters(port=gateway_port, auto_convert=True) if not insecure: - gateway_params.auth_token=gateway_secret + gateway_params.auth_token = gateway_secret gateway = JavaGateway(gateway_parameters=gateway_params) # Import the classes used by PySpark diff --git a/python/pyspark/tests.py b/python/pyspark/tests.py index 904c2f241d435..431a865e10609 100644 --- a/python/pyspark/tests.py +++ b/python/pyspark/tests.py @@ -2403,9 +2403,11 @@ def test_allow_insecure_gateway_with_conf(self): with SparkContext(conf=conf, gateway=gateway) as sc: print("sc created, about to create accum") a = sc.accumulator(1) - rdd = sc.parallelize([1,2,3]) + rdd = sc.parallelize([1, 2, 3]) + def f(x): a.add(x) + rdd.foreach(f) self.assertEqual(7, a.value) print("exiting allow insecure test")