Skip to content

Commit cc215bf

Browse files
committed
Support str as param type
1 parent 3dc5a1e commit cc215bf

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
* Allow passing the optional graph filter also as type `str` to `gds.graph.list()` instead of only `Graph`.
2525
* Listen and to SIGINT and SIGTERM and interrupt projection and write-backs based on GDS Session. Note this only works if the query runs in the main thread.
2626
* Avoid data copy by using the arrow-based DataFrame backend for arrow-based endpoints and if pandas>2.0
27+
* Support `node_properties` parameter also as type `str` instead of only list for endpoint `gds.graph.nodeProperties.stream`.
2728

2829
## Other changes

doc/sphinx/source/graph.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ These all assume that an object of :class:`.GraphDataScience` is available as `g
131131
132132
Removes node properties from a projected graph.
133133

134-
.. py:function:: gds.graph.nodeProperties.stream(G: Graph,node_properties: List[str],node_labels: Strings = ["*"],separate_property_columns: bool = False, db_node_properties: List[str] = [], **config: Any,) -> DataFrame
134+
.. py:function:: gds.graph.nodeProperties.stream(G: Graph,node_properties: Union[List[str], str],node_labels: Strings = ["*"],separate_property_columns: bool = False, db_node_properties: List[str] = [], **config: Any,) -> DataFrame
135135
136136
Streams the given node properties.
137137

graphdatascience/graph/graph_entity_ops_runner.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,17 @@ class GraphNodePropertiesRunner(GraphEntityOpsBaseRunner):
101101
def stream(
102102
self,
103103
G: Graph,
104-
node_properties: list[str],
104+
node_properties: Union[str, list[str]],
105105
node_labels: Strings = ["*"],
106106
separate_property_columns: bool = False,
107107
db_node_properties: list[str] = [],
108108
**config: Any,
109109
) -> DataFrame:
110110
self._namespace += ".stream"
111111

112+
if isinstance(node_properties, str):
113+
node_properties = [node_properties]
114+
112115
# find if list contain duplicates
113116
if len(set(node_properties)) != len(node_properties):
114117
raise ValueError(f"The provided node_properties contain duplicate property names: `{node_properties}`.")

graphdatascience/tests/unit/test_graph_ops.py

+9
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,15 @@ def test_graph_nodeProperties_stream(runner: CollectingQueryRunner, gds: GraphDa
263263
"config": {"concurrency": 2},
264264
}
265265

266+
gds.graph.nodeProperties.stream(G, "dummyProp", "dummyLabel", concurrency=2)
267+
assert runner.last_query() == "CALL gds.graph.nodeProperties.stream($graph_name, $properties, $entities, $config)"
268+
assert runner.last_params() == {
269+
"graph_name": "g",
270+
"properties": ["dummyProp"],
271+
"entities": "dummyLabel",
272+
"config": {"concurrency": 2},
273+
}
274+
266275

267276
def test_graph_streamRelationshipProperty(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
268277
G, _ = gds.graph.project("g", "*", "*")

0 commit comments

Comments
 (0)