Skip to content

Commit 9c74e2a

Browse files
committed
Fix for relationshipType as str
1 parent 86521ce commit 9c74e2a

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

examples/kge-predict-transe-pyg-train.ipynb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,13 +307,16 @@
307307
"outputs": [],
308308
"source": [
309309
"def create_data_from_graph(relationship_type):\n",
310-
" rels_tmp = gds.graph.relationshipProperties.stream(ttv_G, [\"rel_id\"], [relationship_type])\n",
310+
" rels_tmp = gds.graph.relationshipProperties.stream(\n",
311+
" ttv_G, [\"rel_id\"], relationship_type, separate_property_columns=True\n",
312+
" )\n",
313+
" # print(rels_tmp)\n",
311314
" topology = [\n",
312315
" rels_tmp.sourceNodeId.map(lambda x: nodeId_to_id[x]),\n",
313316
" rels_tmp.targetNodeId.map(lambda x: nodeId_to_id[x]),\n",
314317
" ]\n",
315318
" edge_index = torch.tensor(topology, dtype=torch.long)\n",
316-
" edge_type = torch.tensor(rels_tmp.propertyValue.astype(int), dtype=torch.long)\n",
319+
" edge_type = torch.tensor(rels_tmp.rel_id.astype(int), dtype=torch.long)\n",
317320
" data = Data(edge_index=edge_index, edge_type=edge_type)\n",
318321
" data.num_nodes = len(nodeId_to_id)\n",
319322
" display(data)\n",

graphdatascience/graph/base_graph_proc_runner.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,7 @@ def writeRelationship(
517517
).squeeze()
518518

519519
@multimethod
520-
def removeNodeProperties(self) -> None:
521-
...
520+
def removeNodeProperties(self) -> None: ...
522521

523522
@removeNodeProperties.register
524523
@graph_type_check

graphdatascience/graph/graph_entity_ops_runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,8 @@ def stream(
209209
) -> DataFrame:
210210
self._namespace += ".stream"
211211

212+
relationship_types = [relationship_types] if isinstance(relationship_types, str) else relationship_types
213+
212214
result = self._handle_properties(G, relationship_properties, relationship_types, config)
213215

214216
# new format was requested, but the query was run via Cypher

graphdatascience/tests/integration/test_graph_ops.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,26 @@ def test_graph_relationshipProperties_stream_with_arrow_rel_as_str(gds: GraphDat
704704
assert {e for e in y_values["propertyValue"]} == {5, 6, 7}
705705

706706

707+
@pytest.mark.compatible_with(min_inclusive=ServerVersion(2, 2, 0))
708+
def test_graph_relationshipProperties_stream_with_arrow_rel_as_str_sep(gds: GraphDataScience) -> None:
709+
G, _ = gds.graph.project(GRAPH_NAME, "*", {"REL": {"properties": ["relX", "relY"]}})
710+
711+
result = gds.graph.relationshipProperties.stream(
712+
G, ["relX", "relY"], "REL", separate_property_columns=True, concurrency=2
713+
)
714+
715+
assert list(result.keys()) == [
716+
"sourceNodeId",
717+
"targetNodeId",
718+
"relationshipType",
719+
"relX",
720+
"relY",
721+
]
722+
723+
assert {e for e in result["relX"]} == {4, 5, 6}
724+
assert {e for e in result["relY"]} == {5, 6, 7}
725+
726+
707727
@pytest.mark.compatible_with(min_inclusive=ServerVersion(2, 2, 0))
708728
def test_graph_relationshipProperties_stream_with_arrow_rel_as_str_separate(gds: GraphDataScience) -> None:
709729
G, _ = gds.graph.project(GRAPH_NAME, "*", {"REL": {"properties": ["relX", "relY"]}})

0 commit comments

Comments
 (0)