File tree Expand file tree Collapse file tree 1 file changed +0
-6
lines changed
enterprise_gateway/itests Expand file tree Collapse file tree 1 file changed +0
-6
lines changed Original file line number Diff line number Diff line change @@ -122,18 +122,12 @@ def test_run_pi_example(self):
122
122
pi_code = []
123
123
pi_code .append ("from random import random\n " )
124
124
pi_code .append ("from operator import add\n " )
125
- pi_code .append ("from pyspark.cloudpickle import cloudpickle\n " )
126
125
pi_code .append ("partitions = 20\n " )
127
126
pi_code .append ("n = 100000 * partitions\n " )
128
- # Define the function with explicit imports inside to avoid serialization issues
129
127
pi_code .append ("def f(_):\n " )
130
- pi_code .append (" from random import random\n " ) # Include import inside function
131
128
pi_code .append (" x = random() * 2 - 1\n " )
132
129
pi_code .append (" y = random() * 2 - 1\n " )
133
130
pi_code .append (" return 1 if x ** 2 + y ** 2 <= 1 else 0\n " )
134
- pi_code .append ("pickled_f = cloudpickle.dumps(f)\n " )
135
- pi_code .append ("print('Function f successfully pickled!')\n " )
136
- # Use a lambda function directly in map to avoid complex serialization
137
131
pi_code .append ("count = sc.parallelize(range(1, n + 1), partitions).map(f).reduce(add)\n " )
138
132
pi_code .append ('print("Pi is roughly %f" % (4.0 * count / n))\n ' )
139
133
result , has_error = self .kernel .execute (pi_code )
You can’t perform that action at this time.
0 commit comments