File tree Expand file tree Collapse file tree 2 files changed +3
-7
lines changed
enterprise_gateway/itests
etc/kernel-launchers/python/scripts Expand file tree Collapse file tree 2 files changed +3
-7
lines changed Original file line number Diff line number Diff line change @@ -122,18 +122,13 @@ 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
128+ pi_code .append (" from random import random\n " )
131129 pi_code .append (" x = random() * 2 - 1\n " )
132130 pi_code .append (" y = random() * 2 - 1\n " )
133131 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
137132 pi_code .append ("count = sc.parallelize(range(1, n + 1), partitions).map(f).reduce(add)\n " )
138133 pi_code .append ('print("Pi is roughly %f" % (4.0 * count / n))\n ' )
139134 result , has_error = self .kernel .execute (pi_code )
Original file line number Diff line number Diff line change 55import json
66import logging
77import os
8- import random
8+
99import signal
1010import socket
1111import tempfile
1212import uuid
13+ from random import random
1314from multiprocessing import Process
1415from threading import Thread
1516
You can’t perform that action at this time.
0 commit comments