Skip to content

Commit cc21ea1

Browse files
committed
Play with random
1 parent 0ab2821 commit cc21ea1

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

enterprise_gateway/itests/test_python_kernel.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,12 @@ def test_run_pi_example(self):
122122
pi_code = []
123123
pi_code.append("from random import random\n")
124124
pi_code.append("from operator import add\n")
125-
pi_code.append("from pyspark.cloudpickle import cloudpickle\n")
126125
pi_code.append("partitions = 20\n")
127126
pi_code.append("n = 100000 * partitions\n")
128-
# Define the function with explicit imports inside to avoid serialization issues
129127
pi_code.append("def f(_):\n")
130-
pi_code.append(" from random import random\n") # Include import inside function
131128
pi_code.append(" x = random() * 2 - 1\n")
132129
pi_code.append(" y = random() * 2 - 1\n")
133130
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
137131
pi_code.append("count = sc.parallelize(range(1, n + 1), partitions).map(f).reduce(add)\n")
138132
pi_code.append('print("Pi is roughly %f" % (4.0 * count / n))\n')
139133
result, has_error = self.kernel.execute(pi_code)

0 commit comments

Comments
 (0)