forked from graphframes/graphframes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
32 lines (22 loc) · 1.04 KB
/
__init__.py
File metadata and controls
32 lines (22 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import pathlib
from importlib import resources
from pyspark.version import __version__
from .graphframe import GraphFrame
def get_gf_jar_location() -> str:
"""
Returns a location of the GraphFrames JAR,
included to the distribution of the graphframes-py.
Usage: just add the returned value of the function to `spark.jars`:
`SparkSession.builder.master(...).config("spark.jars", get_gf_jar_location()).getOrCreate()`.
In the case your version of PySpark is not compatible with the version of GraphFrames,
this function will raise an exception!
"""
resources_root = resources.files("graphframes").joinpath("resources")
for pp in resources_root.iterdir():
assert isinstance(pp, pathlib.PosixPath) # type checking
if pp.is_file() and pp.name.endswith(".jar") and __version__[:5] in pp.name:
return str(pp.absolute())
raise ValueError(
f"You version of spark {__version__} is not supported by this version of grpahframes!"
)
__all__ = ["GraphFrame", "get_gf_jar_location"]