Skip to content

Commit d040173

Browse files
committed
Separate out beta endpoints
1 parent 5824371 commit d040173

18 files changed

+219
-113
lines changed

graphdatascience/alpha_endpoints.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from .algo.algo_endpoints import AlgoEndpoints
21
from .algo.single_mode_algo_endpoints import SingleModeAlgoEndpoints
3-
from .call_builder import CallBuilder
2+
from .call_builder import IndirectAlphaCallBuilder
43
from .graph.graph_endpoints import GraphAlphaEndpoints
54
from .model.model_endpoints import ModelAlphaEndpoints
65
from .pipeline.pipeline_endpoints import PipelineAlphaEndpoints
@@ -10,14 +9,8 @@
109
from .system.system_endpoints import SystemAlphaEndpoints
1110
from .topological_lp.topological_lp_endpoints import TopologicalLPEndpoints
1211

13-
"""
14-
This class should inherit endpoint classes that only contain endpoints that can be called directly from
15-
the `gds` namespace. Example of such endpoints are: "graph" and "list".
16-
"""
17-
1812

1913
class AlphaEndpoints(
20-
AlgoEndpoints,
2114
GraphAlphaEndpoints,
2215
PipelineAlphaEndpoints,
2316
TopologicalLPEndpoints,
@@ -29,5 +22,5 @@ class AlphaEndpoints(
2922
def __init__(self, query_runner: QueryRunner, namespace: str, server_version: ServerVersion):
3023
super().__init__(query_runner, namespace, server_version)
3124

32-
def __getattr__(self, attr: str) -> CallBuilder:
33-
return CallBuilder(self._query_runner, f"{self._namespace}.{attr}", self._server_version)
25+
def __getattr__(self, attr: str) -> IndirectAlphaCallBuilder:
26+
return IndirectAlphaCallBuilder(self._query_runner, f"{self._namespace}.{attr}", self._server_version)

graphdatascience/beta_endpoints.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from .call_builder import IndirectBetaCallBuilder
2+
from .graph.graph_endpoints import GraphBetaEndpoints
3+
from .model.model_endpoints import ModelBetaEndpoints
4+
from .pipeline.pipeline_endpoints import PipelineBetaEndpoints
5+
from .query_runner.query_runner import QueryRunner
6+
from .server_version.server_version import ServerVersion
7+
from .system.system_endpoints import SystemBetaEndpoints
8+
9+
10+
class BetaEndpoints(GraphBetaEndpoints, PipelineBetaEndpoints, ModelBetaEndpoints, SystemBetaEndpoints):
11+
def __init__(self, query_runner: QueryRunner, namespace: str, server_version: ServerVersion):
12+
super().__init__(query_runner, namespace, server_version)
13+
14+
def __getattr__(self, attr: str) -> IndirectBetaCallBuilder:
15+
return IndirectBetaCallBuilder(self._query_runner, f"{self._namespace}.{attr}", self._server_version)

graphdatascience/call_builder.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,21 @@
1+
from .algo.algo_endpoints import AlgoEndpoints
12
from .error.uncallable_namespace import UncallableNamespace
2-
from .indirect_endpoints import IndirectEndpoints
3+
from .utils.util_endpoints import IndirectUtilAlphaEndpoints
34

45

5-
class CallBuilder(IndirectEndpoints, UncallableNamespace):
6-
def __getattr__(self, attr: str) -> "CallBuilder":
6+
class IndirectCallBuilder(AlgoEndpoints, UncallableNamespace):
7+
def __getattr__(self, attr: str) -> "IndirectCallBuilder":
78
namespace = f"{self._namespace}.{attr}"
8-
return CallBuilder(self._query_runner, namespace, self._server_version)
9+
return IndirectCallBuilder(self._query_runner, namespace, self._server_version)
10+
11+
12+
class IndirectBetaCallBuilder(AlgoEndpoints, UncallableNamespace):
13+
def __getattr__(self, attr: str) -> "IndirectBetaCallBuilder":
14+
namespace = f"{self._namespace}.{attr}"
15+
return IndirectBetaCallBuilder(self._query_runner, namespace, self._server_version)
16+
17+
18+
class IndirectAlphaCallBuilder(AlgoEndpoints, IndirectUtilAlphaEndpoints, UncallableNamespace):
19+
def __getattr__(self, attr: str) -> "IndirectAlphaCallBuilder":
20+
namespace = f"{self._namespace}.{attr}"
21+
return IndirectAlphaCallBuilder(self._query_runner, namespace, self._server_version)
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from typing import Any, List, Tuple, Union
2+
3+
from pandas import Series
4+
5+
from ..caller_base import CallerBase
6+
from ..error.illegal_attr_checker import IllegalAttrChecker
7+
from ..error.uncallable_namespace import UncallableNamespace
8+
from .graph_export_runner import GraphExportCsvEndpoints
9+
from .graph_object import Graph
10+
from .graph_project_runner import GraphProjectBetaRunner
11+
from graphdatascience.graph.graph_entity_ops_runner import GraphRelationshipsBetaRunner
12+
13+
Strings = Union[str, List[str]]
14+
15+
16+
class GraphBetaProcRunner(CallerBase, UncallableNamespace, IllegalAttrChecker):
17+
@property
18+
def project(self) -> GraphProjectBetaRunner:
19+
self._namespace += ".project"
20+
return GraphProjectBetaRunner(self._query_runner, self._namespace, self._server_version)
21+
22+
@property
23+
def export(self) -> GraphExportCsvEndpoints:
24+
self._namespace += ".export"
25+
return GraphExportCsvEndpoints(self._query_runner, self._namespace, self._server_version)
26+
27+
@property
28+
def relationships(self) -> GraphRelationshipsBetaRunner:
29+
self._namespace += ".relationships"
30+
return GraphRelationshipsBetaRunner(self._query_runner, self._namespace, self._server_version)
31+
32+
def generate(
33+
self, graph_name: str, node_count: int, average_degree: int, **config: Any
34+
) -> Tuple[Graph, "Series[Any]"]:
35+
self._namespace += ".generate"
36+
37+
query = f"CALL {self._namespace}($graph_name, $node_count, $average_degree, $config)"
38+
params = {
39+
"graph_name": graph_name,
40+
"node_count": node_count,
41+
"average_degree": average_degree,
42+
"config": config,
43+
}
44+
45+
result = self._query_runner.run_query(query, params).squeeze()
46+
47+
return Graph(graph_name, self._query_runner, self._server_version), result

graphdatascience/graph/graph_endpoints.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from ..caller_base import CallerBase
22
from .graph_alpha_proc_runner import GraphAlphaProcRunner
3+
from .graph_beta_proc_runner import GraphBetaProcRunner
34
from .graph_proc_runner import GraphProcRunner
45

56

@@ -13,3 +14,9 @@ class GraphAlphaEndpoints(CallerBase):
1314
@property
1415
def graph(self) -> GraphAlphaProcRunner:
1516
return GraphAlphaProcRunner(self._query_runner, f"{self._namespace}.graph", self._server_version)
17+
18+
19+
class GraphBetaEndpoints(CallerBase):
20+
@property
21+
def graph(self) -> GraphBetaProcRunner:
22+
return GraphBetaProcRunner(self._query_runner, f"{self._namespace}.graph", self._server_version)

graphdatascience/graph/graph_entity_ops_runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ def drop(
228228

229229
return self._query_runner.run_query(query, params).squeeze() # type: ignore
230230

231+
232+
class GraphRelationshipsBetaRunner(GraphEntityOpsBaseRunner):
231233
@compatible_with("stream", min_inclusive=ServerVersion(2, 2, 0))
232234
@graph_type_check
233235
def stream(self, G: Graph, relationship_types: List[str] = ["*"], **config: Any) -> TopologyDataFrame:

graphdatascience/graph/graph_export_runner.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
from pandas import Series
44

5+
from ..caller_base import CallerBase
56
from ..error.illegal_attr_checker import IllegalAttrChecker
7+
from ..error.uncallable_namespace import UncallableNamespace
68
from .graph_object import Graph
79
from .graph_type_check import graph_type_check
810

@@ -26,7 +28,15 @@ def estimate(self, G: Graph, **config: Any) -> "Series[Any]":
2628
return self._export_call(G, config)
2729

2830

29-
class GraphExportRunner(IllegalAttrChecker):
31+
class GraphExportCsvEndpoints(CallerBase, UncallableNamespace, IllegalAttrChecker):
32+
@property
33+
def csv(self) -> GraphExportCsvRunner:
34+
self._namespace += ".csv"
35+
36+
return GraphExportCsvRunner(self._query_runner, self._namespace, self._server_version)
37+
38+
39+
class GraphExportRunner(CallerBase, IllegalAttrChecker):
3040
def __call__(self, G: Graph, **config: Any) -> "Series[Any]":
3141
return self._export_call(G, config)
3242

graphdatascience/graph/graph_project_runner.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def estimate(self, node_spec: Any, relationship_spec: Any, **config: Any) -> "Se
4040
def cypher(self) -> "GraphProjectRunner":
4141
return GraphProjectRunner(self._query_runner, self._namespace + ".cypher", self._server_version)
4242

43+
44+
class GraphProjectBetaRunner(CallerBase, IllegalAttrChecker):
4345
@from_graph_type_check
4446
def subgraph(
4547
self,

graphdatascience/graph_data_science.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
from pandas import DataFrame, Series
66

77
from .alpha_endpoints import AlphaEndpoints
8-
from .call_builder import CallBuilder
8+
from .beta_endpoints import BetaEndpoints
9+
from .call_builder import IndirectCallBuilder
910
from .direct_endpoints import DirectEndpoints
1011
from .error.unable_to_connect import UnableToConnectError
1112
from .error.uncallable_namespace import UncallableNamespace
@@ -130,12 +131,12 @@ def __init__(
130131
def alpha(self) -> AlphaEndpoints:
131132
return AlphaEndpoints(self._query_runner, "gds.alpha", self._server_version)
132133

133-
# TODO
134-
# def beta(self) -> None:
135-
# pass
134+
@property
135+
def beta(self) -> BetaEndpoints:
136+
return BetaEndpoints(self._query_runner, "gds.beta", self._server_version)
136137

137-
def __getattr__(self, attr: str) -> CallBuilder:
138-
return CallBuilder(self._query_runner, f"gds.{attr}", self._server_version)
138+
def __getattr__(self, attr: str) -> IndirectCallBuilder:
139+
return IndirectCallBuilder(self._query_runner, f"gds.{attr}", self._server_version)
139140

140141
def set_database(self, database: str) -> None:
141142
self._query_runner.set_database(database)
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
from .algo.algo_endpoints import AlgoEndpoints
2-
from .graph.graph_endpoints import GraphEndpoints
3-
from .model.model_endpoints import ModelEndpoints
4-
from .pipeline.pipeline_endpoints import PipelineEndpoints
52
from .query_runner.query_runner import QueryRunner
63
from .server_version.server_version import ServerVersion
7-
from .system.system_endpoints import IndirectSystemEndpoints
8-
from .utils.util_endpoints import IndirectUtilEndpoints
94

105
"""
116
This class should inherit endpoint classes that only contain endpoints that needs more of a prefix
@@ -14,13 +9,6 @@
149
"""
1510

1611

17-
class IndirectEndpoints(
18-
AlgoEndpoints,
19-
GraphEndpoints,
20-
ModelEndpoints,
21-
PipelineEndpoints,
22-
IndirectSystemEndpoints,
23-
IndirectUtilEndpoints,
24-
):
12+
class IndirectProductEndpoints(AlgoEndpoints):
2513
def __init__(self, query_runner: QueryRunner, namespace: str, server_version: ServerVersion):
2614
super().__init__(query_runner, namespace, server_version)

0 commit comments

Comments
 (0)