Skip to content

Commit 048497c

Browse files
committed
Share logic for endpoint helpers
1 parent 8e42790 commit 048497c

38 files changed

+459
-398
lines changed

graphdatascience/arrow_client/v2/mutation_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def mutate_relationship_property(
2222
client: AuthenticatedArrowClient,
2323
job_id: str,
2424
mutate_relationship_type: str,
25-
mutate_property: str,
25+
mutate_property: str | None,
2626
) -> MutateResult:
2727
return MutationClient._mutate(
2828
client=client,

graphdatascience/procedure_surface/arrow/catalog/node_label_arrow_endpoints.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
NodeLabelMutateResult,
1010
NodeLabelWriteResult,
1111
)
12-
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpoints
12+
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpointsHelper
1313
from graphdatascience.procedure_surface.utils.config_converter import ConfigConverter
1414

1515

@@ -20,11 +20,11 @@ def __init__(
2020
write_back_client: RemoteWriteBackClient | None = None,
2121
show_progress: bool = True,
2222
):
23-
self._node_property_endpoints = NodePropertyEndpoints(
23+
self._node_property_endpoints = NodePropertyEndpointsHelper(
2424
arrow_client, write_back_client, show_progress=show_progress
2525
)
2626
self._arrow_client = arrow_client
27-
self._node_property_endpoints = NodePropertyEndpoints(arrow_client, write_back_client)
27+
self._node_property_endpoints = NodePropertyEndpointsHelper(arrow_client, write_back_client)
2828
self._show_progress = show_progress
2929

3030
def mutate(
@@ -83,6 +83,11 @@ def write(
8383
)
8484

8585
result = self._node_property_endpoints.run_job_and_write(
86-
"v2/graph.nodeLabel.stream", G, config, write_concurrency, concurrency
86+
"v2/graph.nodeLabel.stream",
87+
G,
88+
config,
89+
property_overwrites={},
90+
write_concurrency=write_concurrency,
91+
concurrency=concurrency,
8792
)
8893
return NodeLabelWriteResult(**result)

graphdatascience/procedure_surface/arrow/catalog/node_properties_arrow_endpoints.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
NodePropertiesWriteResult,
1515
NodePropertySpec,
1616
)
17-
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpoints
17+
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpointsHelper
1818
from graphdatascience.procedure_surface.utils.config_converter import ConfigConverter
1919
from graphdatascience.procedure_surface.utils.result_utils import join_db_node_properties
2020

@@ -31,7 +31,7 @@ def __init__(
3131
self._write_back_client: RemoteWriteBackClient | None = (
3232
RemoteWriteBackClient(arrow_client, query_runner) if query_runner is not None else None
3333
)
34-
self._node_property_endpoints = NodePropertyEndpoints(
34+
self._node_property_endpoints = NodePropertyEndpointsHelper(
3535
arrow_client, self._write_back_client, show_progress=show_progress
3636
)
3737
self._show_progress = show_progress

graphdatascience/procedure_surface/arrow/centrality/articlerank_arrow_endpoints.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ArticleRankWriteResult,
1313
)
1414
from graphdatascience.procedure_surface.api.estimation_result import EstimationResult
15-
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpoints
15+
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpointsHelper
1616

1717

1818
class ArticleRankArrowEndpoints(ArticleRankEndpoints):
@@ -22,7 +22,7 @@ def __init__(
2222
write_back_client: RemoteWriteBackClient | None = None,
2323
show_progress: bool = True,
2424
):
25-
self._node_property_endpoints = NodePropertyEndpoints(
25+
self._node_property_endpoints = NodePropertyEndpointsHelper(
2626
arrow_client, write_back_client, show_progress=show_progress
2727
)
2828

@@ -60,9 +60,7 @@ def mutate(
6060
tolerance=tolerance,
6161
)
6262

63-
result = self._node_property_endpoints.run_job_and_mutate(
64-
"v2/centrality.articleRank", G, config, mutate_property
65-
)
63+
result = self._node_property_endpoints.run_job_and_mutate("v2/centrality.articleRank", config, mutate_property)
6664

6765
return ArticleRankMutateResult(**result)
6866

@@ -99,9 +97,7 @@ def stats(
9997
tolerance=tolerance,
10098
)
10199

102-
computation_result = self._node_property_endpoints.run_job_and_get_summary(
103-
"v2/centrality.articleRank", G, config
104-
)
100+
computation_result = self._node_property_endpoints.run_job_and_get_summary("v2/centrality.articleRank", config)
105101

106102
return ArticleRankStatsResult(**computation_result)
107103

@@ -176,7 +172,12 @@ def write(
176172
)
177173

178174
result = self._node_property_endpoints.run_job_and_write(
179-
"v2/centrality.articleRank", G, config, write_concurrency, concurrency, write_property
175+
"v2/centrality.articleRank",
176+
G,
177+
config,
178+
property_overwrites=write_property,
179+
write_concurrency=write_concurrency,
180+
concurrency=concurrency,
180181
)
181182

182183
return ArticleRankWriteResult(**result)

graphdatascience/procedure_surface/arrow/centrality/articulationpoints_arrow_endpoints.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ArticulationPointsWriteResult,
1313
)
1414
from graphdatascience.procedure_surface.api.estimation_result import EstimationResult
15-
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpoints
15+
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpointsHelper
1616

1717

1818
class ArticulationPointsArrowEndpoints(ArticulationPointsEndpoints):
@@ -24,7 +24,7 @@ def __init__(
2424
write_back_client: RemoteWriteBackClient | None = None,
2525
show_progress: bool = True,
2626
):
27-
self._node_property_endpoints = NodePropertyEndpoints(
27+
self._node_property_endpoints = NodePropertyEndpointsHelper(
2828
arrow_client, write_back_client, show_progress=show_progress
2929
)
3030

@@ -52,7 +52,7 @@ def mutate(
5252
)
5353

5454
result = self._node_property_endpoints.run_job_and_mutate(
55-
"v2/centrality.articulationPoints", G, config, mutate_property
55+
"v2/centrality.articulationPoints", config, mutate_property
5656
)
5757

5858
return ArticulationPointsMutateResult(**result)
@@ -80,7 +80,7 @@ def stats(
8080
)
8181

8282
computation_result = self._node_property_endpoints.run_job_and_get_summary(
83-
"v2/centrality.articulationPoints", G, config
83+
"v2/centrality.articulationPoints", config
8484
)
8585

8686
return ArticulationPointsStatsResult(**computation_result)
@@ -127,7 +127,12 @@ def write(
127127
)
128128

129129
result = self._node_property_endpoints.run_job_and_write(
130-
"v2/centrality.articulationPoints", G, config, write_concurrency, concurrency, write_property
130+
"v2/centrality.articulationPoints",
131+
G,
132+
config,
133+
property_overwrites=write_property,
134+
write_concurrency=write_concurrency,
135+
concurrency=concurrency,
131136
)
132137

133138
return ArticulationPointsWriteResult(**result)

graphdatascience/procedure_surface/arrow/centrality/betweenness_arrow_endpoints.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
BetweennessWriteResult,
1313
)
1414
from graphdatascience.procedure_surface.api.estimation_result import EstimationResult
15-
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpoints
15+
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpointsHelper
1616

1717

1818
class BetweennessArrowEndpoints(BetweennessEndpoints):
@@ -24,7 +24,7 @@ def __init__(
2424
write_back_client: RemoteWriteBackClient | None = None,
2525
show_progress: bool = True,
2626
):
27-
self._node_property_endpoints = NodePropertyEndpoints(
27+
self._node_property_endpoints = NodePropertyEndpointsHelper(
2828
arrow_client, write_back_client, show_progress=show_progress
2929
)
3030

@@ -57,9 +57,7 @@ def mutate(
5757
username=username,
5858
)
5959

60-
result = self._node_property_endpoints.run_job_and_mutate(
61-
"v2/centrality.betweenness", G, config, mutate_property
62-
)
60+
result = self._node_property_endpoints.run_job_and_mutate("v2/centrality.betweenness", config, mutate_property)
6361

6462
return BetweennessMutateResult(**result)
6563

@@ -91,9 +89,7 @@ def stats(
9189
username=username,
9290
)
9391

94-
computation_result = self._node_property_endpoints.run_job_and_get_summary(
95-
"v2/centrality.betweenness", G, config
96-
)
92+
computation_result = self._node_property_endpoints.run_job_and_get_summary("v2/centrality.betweenness", config)
9793

9894
return BetweennessStatsResult(**computation_result)
9995

@@ -158,7 +154,12 @@ def write(
158154
)
159155

160156
result = self._node_property_endpoints.run_job_and_write(
161-
"v2/centrality.betweenness", G, config, write_concurrency, concurrency, write_property
157+
"v2/centrality.betweenness",
158+
G,
159+
config,
160+
property_overwrites=write_property,
161+
write_concurrency=write_concurrency,
162+
concurrency=concurrency,
162163
)
163164

164165
return BetweennessWriteResult(**result)

graphdatascience/procedure_surface/arrow/centrality/celf_arrow_endpoints.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
CelfWriteResult,
1313
)
1414
from graphdatascience.procedure_surface.api.estimation_result import EstimationResult
15-
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpoints
15+
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpointsHelper
1616

1717

1818
class CelfArrowEndpoints(CelfEndpoints):
@@ -22,7 +22,7 @@ def __init__(
2222
write_back_client: RemoteWriteBackClient | None = None,
2323
show_progress: bool = True,
2424
):
25-
self._node_property_endpoints = NodePropertyEndpoints(
25+
self._node_property_endpoints = NodePropertyEndpointsHelper(
2626
arrow_client, write_back_client, show_progress=show_progress
2727
)
2828

@@ -56,7 +56,7 @@ def mutate(
5656
random_seed=random_seed,
5757
)
5858

59-
result = self._node_property_endpoints.run_job_and_mutate("v2/centrality.celf", G, config, mutate_property)
59+
result = self._node_property_endpoints.run_job_and_mutate("v2/centrality.celf", config, mutate_property)
6060

6161
return CelfMutateResult(**result)
6262

@@ -89,7 +89,7 @@ def stats(
8989
random_seed=random_seed,
9090
)
9191

92-
computation_result = self._node_property_endpoints.run_job_and_get_summary("v2/centrality.celf", G, config)
92+
computation_result = self._node_property_endpoints.run_job_and_get_summary("v2/centrality.celf", config)
9393

9494
return CelfStatsResult(**computation_result)
9595

graphdatascience/procedure_surface/arrow/centrality/closeness_arrow_endpoints.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ClosenessWriteResult,
1313
)
1414
from graphdatascience.procedure_surface.api.estimation_result import EstimationResult
15-
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpoints
15+
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpointsHelper
1616

1717

1818
class ClosenessArrowEndpoints(ClosenessEndpoints):
@@ -24,7 +24,7 @@ def __init__(
2424
write_back_client: RemoteWriteBackClient | None = None,
2525
show_progress: bool = True,
2626
):
27-
self._node_property_endpoints = NodePropertyEndpoints(
27+
self._node_property_endpoints = NodePropertyEndpointsHelper(
2828
arrow_client, write_back_client, show_progress=show_progress
2929
)
3030

@@ -53,7 +53,7 @@ def mutate(
5353
job_id=job_id,
5454
)
5555

56-
result = self._node_property_endpoints.run_job_and_mutate("v2/centrality.closeness", G, config, mutate_property)
56+
result = self._node_property_endpoints.run_job_and_mutate("v2/centrality.closeness", config, mutate_property)
5757

5858
return ClosenessMutateResult(**result)
5959

@@ -81,7 +81,7 @@ def stats(
8181
job_id=job_id,
8282
)
8383

84-
computation_result = self._node_property_endpoints.run_job_and_get_summary("v2/centrality.closeness", G, config)
84+
computation_result = self._node_property_endpoints.run_job_and_get_summary("v2/centrality.closeness", config)
8585

8686
return ClosenessStatsResult(**computation_result)
8787

@@ -138,7 +138,12 @@ def write(
138138
)
139139

140140
result = self._node_property_endpoints.run_job_and_write(
141-
"v2/centrality.closeness", G, config, write_concurrency, concurrency, write_property
141+
"v2/centrality.closeness",
142+
G,
143+
config,
144+
write_concurrency=write_concurrency,
145+
concurrency=concurrency,
146+
property_overwrites=write_property,
142147
)
143148

144149
return ClosenessWriteResult(**result)

graphdatascience/procedure_surface/arrow/centrality/closeness_harmonic_arrow_endpoints.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
ClosenessHarmonicWriteResult,
1313
)
1414
from graphdatascience.procedure_surface.api.estimation_result import EstimationResult
15-
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpoints
15+
from graphdatascience.procedure_surface.arrow.node_property_endpoints import NodePropertyEndpointsHelper
1616

1717

1818
class ClosenessHarmonicArrowEndpoints(ClosenessHarmonicEndpoints):
@@ -22,7 +22,7 @@ def __init__(
2222
write_back_client: RemoteWriteBackClient | None = None,
2323
show_progress: bool = True,
2424
):
25-
self._node_property_endpoints = NodePropertyEndpoints(
25+
self._node_property_endpoints = NodePropertyEndpointsHelper(
2626
arrow_client, write_back_client, show_progress=show_progress
2727
)
2828

@@ -49,7 +49,7 @@ def mutate(
4949
username=username,
5050
)
5151

52-
result = self._node_property_endpoints.run_job_and_mutate("v2/centrality.harmonic", G, config, mutate_property)
52+
result = self._node_property_endpoints.run_job_and_mutate("v2/centrality.harmonic", config, mutate_property)
5353

5454
return ClosenessHarmonicMutateResult(**result)
5555

@@ -75,7 +75,7 @@ def stats(
7575
username=username,
7676
)
7777

78-
computation_result = self._node_property_endpoints.run_job_and_get_summary("v2/centrality.harmonic", G, config)
78+
computation_result = self._node_property_endpoints.run_job_and_get_summary("v2/centrality.harmonic", config)
7979

8080
return ClosenessHarmonicStatsResult(**computation_result)
8181

@@ -128,7 +128,12 @@ def write(
128128
)
129129

130130
result = self._node_property_endpoints.run_job_and_write(
131-
"v2/centrality.harmonic", G, config, write_concurrency, concurrency, write_property
131+
"v2/centrality.harmonic",
132+
G,
133+
config,
134+
property_overwrites=write_property,
135+
write_concurrency=write_concurrency,
136+
concurrency=concurrency,
132137
)
133138

134139
return ClosenessHarmonicWriteResult(**result)

0 commit comments

Comments
 (0)