Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pickle protocol option support for Spark #3001

Merged
merged 5 commits into from
Jan 11, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add pickle protocol option support for Spark
gunnsoo committed Sep 19, 2020
commit 06ee46f414c96d23e6d0ff5d41fcc6befb01d6f7
8 changes: 6 additions & 2 deletions luigi/contrib/spark.py
Original file line number Diff line number Diff line change
@@ -292,6 +292,10 @@ def files(self):
if self.deploy_mode == "cluster":
return [self.run_pickle]

@property
def pickle_protocol(self):
return configuration.get_config().getint(self.spark_version, "pickle-protocol", pickle.DEFAULT_PROTOCOL)

def setup(self, conf):
"""
Called by the pyspark_runner with a SparkConf instance that will be used to instantiate the SparkContext
@@ -335,12 +339,12 @@ def run(self):
def _dump(self, fd):
with self.no_unpicklable_properties():
if self.__module__ == '__main__':
d = pickle.dumps(self)
d = pickle.dumps(self, protocol=self.pickle_protocol)
module_name = os.path.basename(sys.argv[0]).rsplit('.', 1)[0]
d = d.replace(b'c__main__', b'c' + module_name.encode('ascii'))
fd.write(d)
else:
pickle.dump(self, fd)
pickle.dump(self, fd, protocol=self.pickle_protocol)

def _setup_packages(self, sc):
"""