Github user davies commented on a diff in the pull request:
https://github.com/apache/spark/pull/12398#discussion_r61992299
--- Diff: python/pyspark/context.py ---
@@ -814,6 +817,40 @@ def addPyFile(self, path):
import importlib
importlib.invalidate_caches()
+ def addPyPackage(self, pkg):
+ """
+ Add a package to the spark context, the package must have already
been
+ imported by the driver via __import__ semantics. Supports namespace
+ packages by simulating the loading __path__ as a set of modules
from
+ the __path__ list in a single package.
+ """
+ tmp_dir = tempfile.mkdtemp()
+ try:
+ tar_path = os.path.join(tmp_dir, pkg.__name__+'.tar.gz')
+ tar = tarfile.open(tar_path, "w:gz")
+ for mod in pkg.__path__[::-1]:
+ # adds in reverse to simulate namespace loading path
+ tar.add(mod, arcname=os.path.basename(mod))
+ tar.close()
+ self.addPyFile(tar_path)
+ finally:
+ shutil.rmtree(tmp_dir)
+
+ def addRequirementsFile(self, path):
--- End diff --
Will it be better to pass the requirements as string?
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]