Skip to content

Commit d3b518c

Browse files
authored
Merge pull request #378 from orazve/rwr-no-alpha
Remove alpha tier from RWR algorithm endpoint
2 parents 2126812 + 09c0174 commit d3b518c

File tree

6 files changed

+44
-11
lines changed

6 files changed

+44
-11
lines changed

doc/sphinx/source/algorithms.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ These all assume that an object of :class:`.GraphDataScience` is available as `g
9797

9898
Constructs a random subgraph based on common-neighbour-aware random walks.
9999

100+
.. py:function:: gds.graph.sample.cnarw.estimate(G: Graph, **config: Any) -> "Series[Any]"
101+
102+
Returns an estimation of the memory consumption for that procedure.
103+
100104
.. py:function:: gds.alpha.hits.mutate(G: Graph, **config: Any) -> "Series[Any]"
101105
102106
Hyperlink-Induced Topic Search (HITS) is a link analysis algorithm that rates nodes.

graphdatascience/graph/graph_alpha_proc_runner.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
from .graph_alpha_project_runner import GraphAlphaProjectRunner
1212
from .graph_entity_ops_runner import GraphLabelRunner, GraphPropertyRunner
1313
from .graph_object import Graph
14-
from .graph_sample_runner import GraphSampleRunner
14+
from .graph_sample_runner import GraphAlphaSampleRunner
1515

1616

1717
class GraphAlphaProcRunner(UncallableNamespace, IllegalAttrChecker):
1818
@property
19-
def sample(self) -> GraphSampleRunner:
19+
def sample(self) -> GraphAlphaSampleRunner:
2020
self._namespace += ".sample"
21-
return GraphSampleRunner(self._query_runner, self._namespace, self._server_version)
21+
return GraphAlphaSampleRunner(self._query_runner, self._namespace, self._server_version)
2222

2323
@property
2424
def graphProperty(self) -> GraphPropertyRunner:

graphdatascience/graph/graph_sample_runner.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,37 @@
22

33
from pandas import Series
44

5+
from ..error.deprecation_warning import deprecation_warning
56
from ..error.illegal_attr_checker import IllegalAttrChecker
67
from ..server_version.compatible_with import compatible_with
78
from ..server_version.server_version import ServerVersion
89
from .graph_object import Graph
910
from .graph_type_check import from_graph_type_check
1011

1112

12-
class GraphSampleRunner(IllegalAttrChecker):
13+
class GraphAlphaSampleRunner(IllegalAttrChecker):
1314
@compatible_with("construct", min_inclusive=ServerVersion(2, 2, 0))
15+
@deprecation_warning("gds.graph.sample.rwr", ServerVersion(2, 4, 0))
1416
@from_graph_type_check
1517
def rwr(self, graph_name: str, from_G: Graph, **config: Any) -> Tuple[Graph, "Series[Any]"]:
16-
self._namespace += ".rwr"
18+
runner = RWRRunner(self._query_runner, self._namespace + ".rwr", self._server_version)
19+
return runner(graph_name, from_G, **config)
20+
21+
22+
class GraphSampleRunner(IllegalAttrChecker):
23+
@property
24+
def rwr(self) -> "RWRRunner":
25+
return RWRRunner(self._query_runner, self._namespace + ".rwr", self._server_version)
26+
27+
@property
28+
def cnarw(self) -> "CNARWRunner":
29+
return CNARWRunner(self._query_runner, self._namespace + ".cnarw", self._server_version)
1730

31+
32+
class RWRRunner(IllegalAttrChecker):
33+
@compatible_with("construct", min_inclusive=ServerVersion(2, 2, 0))
34+
@from_graph_type_check
35+
def __call__(self, graph_name: str, from_G: Graph, **config: Any) -> Tuple[Graph, "Series[Any]"]:
1836
query = f"CALL {self._namespace}($graph_name, $from_graph_name, $config)"
1937
params = {
2038
"graph_name": graph_name,
@@ -26,10 +44,6 @@ def rwr(self, graph_name: str, from_G: Graph, **config: Any) -> Tuple[Graph, "Se
2644

2745
return Graph(graph_name, self._query_runner, self._server_version), result
2846

29-
@property
30-
def cnarw(self) -> "CNARWRunner":
31-
return CNARWRunner(self._query_runner, self._namespace + ".cnarw", self._server_version)
32-
3347

3448
class CNARWRunner(IllegalAttrChecker):
3549
@compatible_with("construct", min_inclusive=ServerVersion(2, 4, 0))

graphdatascience/tests/integration/test_graph_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def test_project_subgraph(runner: QueryRunner, gds: GraphDataScience) -> None:
9090
def test_sample_rwr(runner: QueryRunner, gds: GraphDataScience) -> None:
9191
from_G, _ = gds.graph.project(GRAPH_NAME, {"Node": {"properties": "x"}}, "*")
9292

93-
rwr_G, result = gds.alpha.graph.sample.rwr("s", from_G, samplingRatio=0.6, concurrency=1, randomSeed=42)
93+
rwr_G, result = gds.graph.sample.rwr("s", from_G, samplingRatio=0.6, concurrency=1, randomSeed=42)
9494

9595
assert rwr_G.name() == "s"
9696
assert result["graphName"] == "s"

graphdatascience/tests/unit/resources/example_server_endpoints.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@
272272
"gds.graph.relationshipProperty.stream",
273273
"gds.graph.relationships.drop",
274274
"gds.graph.removeNodeProperties",
275+
"gds.graph.sample.rwr",
276+
"gds.graph.sample.cnarw",
277+
"gds.graph.sample.cnarw.estimate",
275278
"gds.graph.streamNodeProperties",
276279
"gds.graph.streamNodeProperty",
277280
"gds.graph.streamRelationshipProperties",

graphdatascience/tests/unit/test_graph_ops.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ def test_graph_generate(runner: CollectingQueryRunner, gds: GraphDataScience) ->
602602
}
603603

604604

605-
def test_graph_sample_rwr(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
605+
def test_alpha_graph_sample_rwr(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
606606
from_G, _ = gds.graph.project("g", "*", "*")
607607
gds.alpha.graph.sample.rwr("s", from_G, samplingRatio=0.9, concurrency=7)
608608

@@ -614,6 +614,18 @@ def test_graph_sample_rwr(runner: CollectingQueryRunner, gds: GraphDataScience)
614614
}
615615

616616

617+
def test_graph_sample_rwr(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
618+
from_G, _ = gds.graph.project("g", "*", "*")
619+
gds.graph.sample.rwr("s", from_G, samplingRatio=0.9, concurrency=7)
620+
621+
assert runner.last_query() == "CALL gds.graph.sample.rwr($graph_name, $from_graph_name, $config)"
622+
assert runner.last_params() == {
623+
"graph_name": "s",
624+
"from_graph_name": "g",
625+
"config": {"samplingRatio": 0.9, "concurrency": 7},
626+
}
627+
628+
617629
def test_graph_sample_cnarw(runner: CollectingQueryRunner, gds: GraphDataScience) -> None:
618630
from_G, _ = gds.graph.project("g", "*", "*")
619631
gds.graph.sample.cnarw("s", from_G, samplingRatio=0.9, concurrency=7)

0 commit comments

Comments
 (0)