Skip to content

Commit e71f775

Browse files
authored
chore(deps): bump gremlinpython to 3.8 and adjust traversal source construction (#3370)
gremlinpython 3.8 removed both `Graph().traversal()` and the deprecated `traversal().withGraph(Graph())` form. `Graph` is now an empty placeholder. Add a `local_traversal_source()` helper in `_gremlin_init` that constructs `GraphTraversalSource(Graph(), TraversalStrategies())` directly. This is sufficient for the bytecode → Translator → query string path used by `to_property_graph` (no remote connection needed). Replace the two `Graph().traversal()` call sites in `to_property_graph` with the new helper. Side effect of the lock refresh: gremlinpython 3.8 added an `async-timeout` dependency with a `<5` constraint, downgrading async-timeout from 5.0.1 to 4.0.3. `awswrangler` does not import async-timeout directly, so this is a pure resolver consequence.
1 parent a4e72e4 commit e71f775

3 files changed

Lines changed: 19 additions & 11 deletions

File tree

awswrangler/neptune/_gremlin_init.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,15 @@
88
from gremlin_python.process.anonymous_traversal import traversal
99
from gremlin_python.process.graph_traversal import GraphTraversalSource, __
1010
from gremlin_python.process.translator import Translator
11-
from gremlin_python.process.traversal import Cardinality, T
11+
from gremlin_python.process.traversal import Cardinality, T, TraversalStrategies
1212
from gremlin_python.structure.graph import Edge, Graph, Path, Property, Vertex, VertexProperty
1313

14+
def local_traversal_source() -> "GraphTraversalSource":
15+
# gremlinpython 3.8 removed Graph().traversal() and traversal().withGraph(Graph()).
16+
# We only need a traversal source to build bytecode that the Translator turns into
17+
# a query string — no remote connection or strategies are needed.
18+
return GraphTraversalSource(Graph(), TraversalStrategies())
19+
1420
__all__ = [
1521
"__",
1622
"Cardinality",
@@ -22,6 +28,8 @@
2228
"Property",
2329
"T",
2430
"Translator",
31+
"TraversalStrategies",
32+
"local_traversal_source",
2533
"traversal",
2634
"Vertex",
2735
"VertexProperty",

awswrangler/neptune/_neptune.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def to_property_graph(
170170
... )
171171
"""
172172
# check if ~id and ~label column exist and if not throw error
173-
g = gremlin.Graph().traversal()
173+
g = gremlin.local_traversal_source()
174174
is_edge_df = False
175175
is_update_df = True
176176
if "~id" in df.columns:
@@ -198,7 +198,7 @@ def to_property_graph(
198198
if index > 0 and index + 1 % batch_size == 0:
199199
res = _run_gremlin_insert(client, g)
200200
if res:
201-
g = gremlin.Graph().traversal()
201+
g = gremlin.local_traversal_source()
202202

203203
return _run_gremlin_insert(client, g)
204204

uv.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)