Skip to content

Commit 7e3eb54

Browse files
committed
Inline default for community endpoints part 2
1 parent 027b508 commit 7e3eb54

24 files changed

+457
-442
lines changed

graphdatascience/procedure_surface/api/community/clique_counting_endpoints.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ def mutate(
1717
self,
1818
G: GraphV2,
1919
mutate_property: str,
20+
*,
2021
concurrency: int | None = None,
2122
job_id: str | None = None,
2223
log_progress: bool = True,
@@ -65,7 +66,7 @@ def stats(
6566
log_progress: bool = True,
6667
node_labels: list[str] = ALL_LABELS,
6768
relationship_types: list[str] = ALL_TYPES,
68-
sudo: bool | None = False,
69+
sudo: bool = False,
6970
username: str | None = None,
7071
) -> CliqueCountingStatsResult:
7172
"""
@@ -148,7 +149,7 @@ def write(
148149
log_progress: bool = True,
149150
node_labels: list[str] = ALL_LABELS,
150151
relationship_types: list[str] = ALL_TYPES,
151-
sudo: bool | None = False,
152+
sudo: bool = False,
152153
username: str | None = None,
153154
write_concurrency: int | None = None,
154155
) -> CliqueCountingWriteResult:

graphdatascience/procedure_surface/api/community/hdbscan_endpoints.py

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from abc import ABC, abstractmethod
44
from typing import Any
55

6-
import pandas as pd
6+
from pandas import DataFrame
77

88
from graphdatascience.procedure_surface.api.base_result import BaseResult
99
from graphdatascience.procedure_surface.api.catalog.graph_api import GraphV2
@@ -19,14 +19,14 @@ def mutate(
1919
node_property: str,
2020
mutate_property: str,
2121
*,
22-
leaf_size: int | None = None,
23-
samples: int | None = None,
24-
min_cluster_size: int | None = None,
22+
leaf_size: int = 1,
23+
samples: int = 10,
24+
min_cluster_size: int = 5,
2525
relationship_types: list[str] = ALL_TYPES,
2626
node_labels: list[str] = ALL_LABELS,
2727
concurrency: int | None = None,
2828
log_progress: bool = True,
29-
sudo: bool | None = None,
29+
sudo: bool = False,
3030
job_id: Any | None = None,
3131
username: str | None = None,
3232
) -> HdbscanMutateResult:
@@ -77,14 +77,14 @@ def stats(
7777
G: GraphV2,
7878
node_property: str,
7979
*,
80-
leaf_size: int | None = None,
81-
samples: int | None = None,
82-
min_cluster_size: int | None = None,
80+
leaf_size: int = 1,
81+
samples: int = 10,
82+
min_cluster_size: int = 5,
8383
relationship_types: list[str] = ALL_TYPES,
8484
node_labels: list[str] = ALL_LABELS,
8585
concurrency: int | None = None,
8686
log_progress: bool = True,
87-
sudo: bool | None = None,
87+
sudo: bool = False,
8888
job_id: Any | None = None,
8989
username: str | None = None,
9090
) -> HdbscanStatsResult:
@@ -133,17 +133,17 @@ def stream(
133133
G: GraphV2,
134134
node_property: str,
135135
*,
136-
leaf_size: int | None = None,
137-
samples: int | None = None,
138-
min_cluster_size: int | None = None,
136+
leaf_size: int = 1,
137+
samples: int = 10,
138+
min_cluster_size: int = 5,
139139
relationship_types: list[str] = ALL_TYPES,
140140
node_labels: list[str] = ALL_LABELS,
141141
concurrency: int | None = None,
142142
log_progress: bool = True,
143-
sudo: bool | None = None,
143+
sudo: bool = False,
144144
job_id: Any | None = None,
145145
username: str | None = None,
146-
) -> pd.DataFrame:
146+
) -> DataFrame:
147147
"""
148148
Runs the HDBSCAN algorithm and returns the cluster ID for each node as a DataFrame.
149149
@@ -190,17 +190,17 @@ def write(
190190
node_property: str,
191191
write_property: str,
192192
*,
193-
leaf_size: int | None = None,
194-
samples: int | None = None,
195-
min_cluster_size: int | None = None,
193+
leaf_size: int = 1,
194+
samples: int = 10,
195+
min_cluster_size: int = 5,
196196
relationship_types: list[str] = ALL_TYPES,
197197
node_labels: list[str] = ALL_LABELS,
198-
write_concurrency: int | None = None,
199198
concurrency: int | None = None,
200199
log_progress: bool = True,
201-
sudo: bool | None = None,
200+
sudo: bool = False,
202201
job_id: Any | None = None,
203202
username: str | None = None,
203+
write_concurrency: int | None = None,
204204
) -> HdbscanWriteResult:
205205
"""
206206
Runs the HDBSCAN algorithm and writes the cluster ID for each node back to the database.
@@ -245,19 +245,15 @@ def write(
245245
@abstractmethod
246246
def estimate(
247247
self,
248-
G: GraphV2,
248+
G: GraphV2 | dict[str, Any],
249249
node_property: str,
250250
*,
251-
leaf_size: int | None = None,
252-
samples: int | None = None,
253-
min_cluster_size: int | None = None,
251+
leaf_size: int = 1,
252+
samples: int = 10,
253+
min_cluster_size: int = 5,
254254
relationship_types: list[str] = ALL_TYPES,
255255
node_labels: list[str] = ALL_LABELS,
256256
concurrency: int | None = None,
257-
log_progress: bool = True,
258-
sudo: bool | None = None,
259-
job_id: Any | None = None,
260-
username: str | None = None,
261257
) -> EstimationResult:
262258
"""
263259
Estimates memory requirements and other statistics for the HDBSCAN algorithm.

graphdatascience/procedure_surface/api/community/kcore_endpoints.py

Lines changed: 58 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@ def mutate(
2121
self,
2222
G: GraphV2,
2323
mutate_property: str,
24-
relationship_types: list[str] = ALL_TYPES,
25-
node_labels: list[str] = ALL_LABELS,
26-
sudo: bool | None = None,
24+
*,
25+
concurrency: int | None = None,
26+
job_id: str | None = None,
2727
log_progress: bool = True,
28+
node_labels: list[str] = ALL_LABELS,
29+
relationship_types: list[str] = ALL_TYPES,
30+
sudo: bool = False,
2831
username: str | None = None,
29-
concurrency: Any | None = None,
30-
job_id: Any | None = None,
3132
) -> KCoreMutateResult:
3233
"""
3334
Executes the K-Core algorithm and writes the results to the in-memory graph as node properties.
@@ -38,20 +39,20 @@ def mutate(
3839
The graph to run the algorithm on
3940
mutate_property : str
4041
The property name to store the core value for each node
41-
relationship_types : list[str]
42-
The relationships types used to select relationships for this algorithm run
42+
concurrency : int | None, default=None
43+
The number of concurrent threads
44+
job_id : str | None, default=None
45+
An identifier for the job
46+
log_progress : bool, default=True
47+
Whether to log progress
4348
node_labels : list[str]
4449
The node labels used to select nodes for this algorithm run
45-
sudo : bool
50+
relationship_types : list[str]
51+
The relationship types used to select relationships for this algorithm run
52+
sudo : bool, default=False
4653
Override memory estimation limits
47-
log_progress : bool | None, default=None
48-
Whether to log progress
4954
username : str | None, default=None
5055
The username to attribute the procedure run to
51-
concurrency : Any | None, default=None
52-
The number of concurrent threads
53-
job_id : Any | None, default=None
54-
An identifier for the job
5556
5657
Returns
5758
-------
@@ -64,13 +65,14 @@ def mutate(
6465
def stats(
6566
self,
6667
G: GraphV2,
67-
relationship_types: list[str] = ALL_TYPES,
68-
node_labels: list[str] = ALL_LABELS,
69-
sudo: bool | None = None,
68+
*,
69+
concurrency: int | None = None,
70+
job_id: str | None = None,
7071
log_progress: bool = True,
72+
node_labels: list[str] = ALL_LABELS,
73+
relationship_types: list[str] = ALL_TYPES,
74+
sudo: bool = False,
7175
username: str | None = None,
72-
concurrency: Any | None = None,
73-
job_id: Any | None = None,
7476
) -> KCoreStatsResult:
7577
"""
7678
Executes the K-Core algorithm and returns statistics.
@@ -79,20 +81,20 @@ def stats(
7981
----------
8082
G : GraphV2
8183
The graph to run the algorithm on
82-
relationship_types : list[str]
83-
The relationships types used to select relationships for this algorithm run
84+
concurrency : int | None, default=None
85+
The number of concurrent threads
86+
job_id : str | None, default=None
87+
An identifier for the job
88+
log_progress : bool, default=True
89+
Whether to log progress
8490
node_labels : list[str]
8591
The node labels used to select nodes for this algorithm run
86-
sudo : bool
92+
relationship_types : list[str]
93+
The relationship types used to select relationships for this algorithm run
94+
sudo : bool, default=False
8795
Override memory estimation limits
88-
log_progress : bool | None, default=None
89-
Whether to log progress
9096
username : str | None, default=None
9197
The username to attribute the procedure run to
92-
concurrency : Any | None, default=None
93-
The number of concurrent threads
94-
job_id : Any | None, default=None
95-
An identifier for the job
9698
9799
Returns
98100
-------
@@ -105,13 +107,14 @@ def stats(
105107
def stream(
106108
self,
107109
G: GraphV2,
108-
relationship_types: list[str] = ALL_TYPES,
109-
node_labels: list[str] = ALL_LABELS,
110-
sudo: bool | None = None,
110+
*,
111+
concurrency: int | None = None,
112+
job_id: str | None = None,
111113
log_progress: bool = True,
114+
node_labels: list[str] = ALL_LABELS,
115+
relationship_types: list[str] = ALL_TYPES,
116+
sudo: bool = False,
112117
username: str | None = None,
113-
concurrency: Any | None = None,
114-
job_id: Any | None = None,
115118
) -> DataFrame:
116119
"""
117120
Executes the K-Core algorithm and returns a stream of results.
@@ -147,14 +150,15 @@ def write(
147150
self,
148151
G: GraphV2,
149152
write_property: str,
153+
*,
150154
relationship_types: list[str] = ALL_TYPES,
151155
node_labels: list[str] = ALL_LABELS,
152-
sudo: bool | None = None,
156+
sudo: bool = False,
153157
log_progress: bool = True,
154158
username: str | None = None,
155-
concurrency: Any | None = None,
156-
job_id: Any | None = None,
157-
write_concurrency: Any | None = None,
159+
concurrency: int | None = None,
160+
job_id: str | None = None,
161+
write_concurrency: int | None = None,
158162
) -> KCoreWriteResult:
159163
"""
160164
Executes the K-Core algorithm and writes the results to the Neo4j database.
@@ -165,21 +169,21 @@ def write(
165169
The graph to run the algorithm on
166170
write_property : str
167171
The property name to write core values to
168-
relationship_types : list[str]
169-
The relationships types considered in this algorithm run
172+
concurrency : int | None, default=None
173+
The number of concurrent threads
174+
job_id : str | None, default=None
175+
An identifier for the job
176+
log_progress : bool, default=True
177+
Whether to log progress
170178
node_labels : list[str]
171179
The node labels used to select nodes for this algorithm run
172-
sudo : bool
180+
relationship_types : list[str]
181+
The relationship types considered in this algorithm run
182+
sudo : bool, default=False
173183
Override memory estimation limits
174-
log_progress : bool | None, default=None
175-
Whether to log progress
176184
username : str | None, default=None
177185
The username to attribute the procedure run to
178-
concurrency : Any | None, default=None
179-
The number of concurrent threads
180-
job_id : Any | None, default=None
181-
An identifier for the job
182-
write_concurrency : Any | None, default=None
186+
write_concurrency : int | None, default=None
183187
The number of concurrent threads during the write phase
184188
185189
Returns
@@ -193,9 +197,10 @@ def write(
193197
def estimate(
194198
self,
195199
G: GraphV2 | dict[str, Any],
196-
relationship_types: list[str] = ALL_TYPES,
200+
*,
201+
concurrency: int | None = None,
197202
node_labels: list[str] = ALL_LABELS,
198-
concurrency: Any | None = None,
203+
relationship_types: list[str] = ALL_TYPES,
199204
) -> EstimationResult:
200205
"""
201206
Estimate the memory consumption of an algorithm run.
@@ -204,12 +209,12 @@ def estimate(
204209
----------
205210
G : GraphV2 | dict[str, Any]
206211
The graph to run the algorithm on or a dictionary representing the graph.
207-
relationship_types : list[str]
208-
The relationship types used to select relationships for this algorithm run
212+
concurrency : int | None, default=None
213+
The number of concurrent threads
209214
node_labels : list[str]
210215
The node labels used to select nodes for this algorithm run
211-
concurrency : Any | None, default=None
212-
The number of concurrent threads
216+
relationship_types : list[str]
217+
The relationship types used to select relationships for this algorithm run
213218
214219
Returns
215220
-------

0 commit comments

Comments
 (0)