Skip to content
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
Let classic python version work without grpc deps
  • Loading branch information
Kimahriman committed Jul 17, 2025
commit 7c1a44e718023075171c4f58e34643cf1f32e3b6
14 changes: 4 additions & 10 deletions python/graphframes/graphframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,9 @@ def is_remote() -> bool:
from graphframes.classic.graphframe import GraphFrame as GraphFrameClassic
from graphframes.lib import Pregel

if __version__[:3] >= "3.4":
from graphframes.connect.graphframe_client import GraphFrameConnect
else:

class GraphFrameConnect:
def __init__(self, *args, **kwargs) -> None:
raise ValueError("Unreachable error happened!")


if TYPE_CHECKING:
from pyspark.sql import Column, DataFrame
from graphframes.connect.graphframe_client import GraphFrameConnect


class GraphFrame:
Expand All @@ -67,11 +59,13 @@ class GraphFrame:
"""

@staticmethod
def _from_impl(impl: GraphFrameClassic | GraphFrameConnect) -> "GraphFrame":
def _from_impl(impl: GraphFrameClassic | 'GraphFrameConnect') -> "GraphFrame":
return GraphFrame(impl.vertices, impl.edges)

def __init__(self, v: DataFrame, e: DataFrame) -> None:
self._impl: GraphFrameClassic | 'GraphFrameConnect'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of typing issues but fixed this one at least while I was here. _impl defaulted to the first thing assigned to it which was GraphFrameConnect

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope one day to implement something cool instead, like spark's decorator about dynamic dispatch... This "_impl" based realization is not perfect :(

if is_remote():
from graphframes.connect.graphframe_client import GraphFrameConnect
self._impl = GraphFrameConnect(v, e)
else:
self._impl = GraphFrameClassic(v, e)
Expand Down