Skip to content

Commit fafa2e5

Browse files
authored
Merge pull request #687 from FlorentinD/sessions-disable-topological-lp
Sessions - disallow topological lp + support util functions
2 parents fd76c5c + a0594c1 commit fafa2e5

20 files changed

+285
-60
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@ The manual is versioned to cover all GDS Python Client versions, so make sure to
9898
Operations known to not yet work with `graphdatascience`:
9999

100100
* [Numeric utility functions](https://neo4j.com/docs/graph-data-science/current/management-ops/utility-functions/#utility-functions-numeric) (will never be supported)
101-
* [Cypher on GDS](https://neo4j.com/docs/graph-data-science/current/management-ops/create-cypher-db/) (might be supported in the future)
102-
* [Projecting graphs using Cypher Aggregation](https://neo4j.com/docs/graph-data-science/current/management-ops/projections/graph-project-cypher-aggregation/) (might be supported in the future)
103101

104102

105103
## License

doc/modules/ROOT/pages/gds-session.adoc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ gds.graph.nodeProperties.stream(G, db_node_properties=["name"], node_properties=
255255
For a full list of the available algorithms, see the https://neo4j.com/docs/graph-data-science-client/{page-version}/api/[API reference].
256256

257257

258+
=== Limitations
259+
260+
Topological Link Prediction algorithms are not yet supported.
261+
262+
258263
== Remote write-back
259264

260265
The GDS Session's in-memory graph was projected from data in AuraDB, so write-back operations will persist the data back to the same AuraDB instance.
@@ -282,5 +287,3 @@ Therefore, you will not be able to call any GDS procedures from the `run_cypher(
282287
----
283288
gds.run_cypher("MATCH (n:User) RETURN n.name, n.embedding")
284289
----
285-
286-

doc/modules/ROOT/pages/tutorials/gds-sessions.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ to have the `graphdatascience` Python library installed, version
2828

2929
[source, python, role=no-test]
3030
----
31-
%pip install --pre "graphdatascience>1.10"
31+
%pip install --pre "graphdatascience>1.11a3"
3232
----
3333

3434
== Aura API credentials

examples/gds-sessions.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
"outputs": [],
5757
"source": [
58-
"%pip install --pre \"graphdatascience>1.10\""
58+
"%pip install --pre \"graphdatascience>1.11a3\""
5959
]
6060
},
6161
{

graphdatascience/call_builder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from .algo.algo_endpoints import AlgoEndpoints
22
from .error.uncallable_namespace import UncallableNamespace
3-
from .utils.util_endpoints import IndirectUtilAlphaEndpoints
3+
from .utils.direct_util_endpoints import IndirectUtilAlphaEndpoints
44

55

66
class IndirectCallBuilder(AlgoEndpoints, UncallableNamespace):

graphdatascience/endpoints.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
SystemBetaEndpoints,
2424
)
2525
from .topological_lp.topological_lp_endpoints import TopologicalLPAlphaEndpoints
26-
from .utils.util_endpoints import DirectUtilEndpoints
26+
from .utils.direct_util_endpoints import DirectUtilEndpoints
2727

2828
"""
2929
This class should inherit endpoint classes that only contain endpoints that can be called directly from
@@ -44,7 +44,7 @@ def __init__(self, query_runner: QueryRunner, namespace: str, server_version: Se
4444

4545

4646
"""
47-
This class should inherit endpoint classes that only expose calls of the `gds.beta` namespace.
47+
This class should inherit endpoint classes that only expose calls of the `gds.alpha` namespace.
4848
Example of such endpoints: "gds.alpha.listProgress".
4949
"""
5050

@@ -65,6 +65,21 @@ def __getattr__(self, attr: str) -> IndirectAlphaCallBuilder:
6565
return IndirectAlphaCallBuilder(self._query_runner, f"{self._namespace}.{attr}", self._server_version)
6666

6767

68+
class AlphaRemoteEndpoints(
69+
GraphAlphaEndpoints,
70+
PipelineAlphaEndpoints,
71+
ModelAlphaEndpoints,
72+
SingleModeAlphaAlgoEndpoints,
73+
SystemAlphaEndpoints,
74+
AlphaConfigEndpoints,
75+
):
76+
def __init__(self, query_runner: QueryRunner, namespace: str, server_version: ServerVersion):
77+
super().__init__(query_runner, namespace, server_version)
78+
79+
def __getattr__(self, attr: str) -> IndirectAlphaCallBuilder:
80+
return IndirectAlphaCallBuilder(self._query_runner, f"{self._namespace}.{attr}", self._server_version)
81+
82+
6883
"""
6984
This class should inherit endpoint classes that only expose calls of the `gds.beta` namespace.
7085
Example of such endpoints: "gds.beta.listProgress".

graphdatascience/graph_data_science.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .query_runner.query_runner import QueryRunner
1414
from .server_version.server_version import ServerVersion
1515
from graphdatascience.graph.graph_proc_runner import GraphProcRunner
16+
from graphdatascience.utils.util_proc_runner import UtilProcRunner
1617

1718

1819
class GraphDataScience(DirectEndpoints, UncallableNamespace):
@@ -81,12 +82,16 @@ def __init__(
8182
None if arrow is True else arrow,
8283
)
8384

84-
super().__init__(self._query_runner, "gds", self._server_version)
85+
super().__init__(self._query_runner, namespace="gds", server_version=self._server_version)
8586

8687
@property
8788
def graph(self) -> GraphProcRunner:
8889
return GraphProcRunner(self._query_runner, f"{self._namespace}.graph", self._server_version)
8990

91+
@property
92+
def util(self) -> UtilProcRunner:
93+
return UtilProcRunner(self._query_runner, f"{self._namespace}.util", self._server_version)
94+
9095
@property
9196
def alpha(self) -> AlphaEndpoints:
9297
return AlphaEndpoints(self._query_runner, "gds.alpha", self._server_version)

graphdatascience/query_runner/arrow_query_runner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def run_cypher(
6464
) -> DataFrame:
6565
return self._fallback_query_runner.run_cypher(query, params, database, custom_error)
6666

67+
def call_function(self, endpoint: str, params: Optional[CallParameters] = None) -> Any:
68+
return self._fallback_query_runner.call_function(endpoint, params)
69+
6770
def call_procedure(
6871
self,
6972
endpoint: str,

graphdatascience/query_runner/aura_db_query_runner.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def run_cypher(
3535
) -> DataFrame:
3636
return self._db_query_runner.run_cypher(query, params, database, custom_error)
3737

38+
def call_function(self, endpoint: str, params: Optional[CallParameters] = None) -> Any:
39+
return self._gds_query_runner.call_function(endpoint, params)
40+
3841
def call_procedure(
3942
self,
4043
endpoint: str,

graphdatascience/query_runner/neo4j_query_runner.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,13 @@ def run_cypher(
131131

132132
return df
133133

134+
def call_function(self, endpoint: str, params: Optional[CallParameters] = None) -> Any:
135+
if params is None:
136+
params = CallParameters()
137+
query = f"RETURN {endpoint}({params.placeholder_str()})"
138+
139+
return self.run_cypher(query, params).squeeze()
140+
134141
def call_procedure(
135142
self,
136143
endpoint: str,

0 commit comments

Comments
 (0)