Skip to content

Commit

Permalink
implement a mechanism for validating graph stores by injecting hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
lassewesth committed Jul 1, 2024
1 parent ec3cce3 commit 68ee9a6
Show file tree
Hide file tree
Showing 29 changed files with 214 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ public <G, A extends Algorithm<?>, C extends AlgoBaseConfig> MemoryEstimateResul
config,
maybeRelationshipProperty,
requestScopedDependencies.getUser(),
requestScopedDependencies.getDatabaseId()
requestScopedDependencies.getDatabaseId(),
Optional.empty()
).graphStore();
dimensions = GraphDimensionsComputer.of(graphStore, config);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ public <A extends Algorithm<R>, R, C extends AlgoBaseConfig> AlgorithmComputatio
config,
relationshipProperty,
requestScopedDependencies.getUser(),
requestScopedDependencies.getDatabaseId()
requestScopedDependencies.getDatabaseId(),
Optional.empty()
);

var graph = graphResources.graph();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.neo4j.gds.config.AlgoBaseConfig;
import org.neo4j.gds.core.loading.GraphResources;
import org.neo4j.gds.core.loading.GraphStoreCatalogService;
import org.neo4j.gds.core.loading.PostGraphStoreLoadValidationHook;
import org.neo4j.gds.logging.Log;
import org.neo4j.gds.metrics.ExecutionMetric;
import org.neo4j.gds.metrics.algorithms.AlgorithmMetricsService;
Expand Down Expand Up @@ -157,7 +158,8 @@ public GraphResources getGraphResources(
AlgoBaseConfig config,
Optional<String> relationshipProperty,
User user,
DatabaseId databaseId
DatabaseId databaseId,
Optional<Iterable<PostGraphStoreLoadValidationHook>> postGraphStoreLoadValidationHooks
) {
// this gets called right after the preconditions check
// so, we save ourselves trouble and shunt the rest of the method
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public <RESULT> RESULT articleRank(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
ArticleRank,
estimation::pageRank,
graph -> algorithms.articleRank(graph, configuration),
Expand All @@ -94,6 +95,7 @@ public <RESULT> RESULT betweennessCentrality(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
BetweennessCentrality,
() -> estimation.betweennessCentrality(configuration),
graph -> algorithms.betweennessCentrality(graph, configuration),
Expand All @@ -112,6 +114,7 @@ public <RESULT> RESULT celf(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
CELF,
() -> estimation.celf(configuration),
graph -> algorithms.celf(graph, configuration),
Expand All @@ -130,6 +133,7 @@ public <RESULT> RESULT closenessCentrality(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
ClosenessCentrality,
() -> estimation.closenessCentrality(configuration),
graph -> algorithms.closenessCentrality(graph, configuration),
Expand All @@ -148,6 +152,7 @@ public <RESULT> RESULT degreeCentrality(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
DegreeCentrality,
() -> estimation.degreeCentrality(configuration),
graph -> algorithms.degreeCentrality(graph, configuration),
Expand All @@ -166,6 +171,7 @@ public <RESULT> RESULT eigenVector(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
EigenVector,
estimation::pageRank,
graph -> algorithms.eigenVector(graph, configuration),
Expand All @@ -184,6 +190,7 @@ public <RESULT> RESULT harmonicCentrality(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
HarmonicCentrality,
estimation::harmonicCentrality,
graph -> algorithms.harmonicCentrality(graph, configuration),
Expand All @@ -202,6 +209,7 @@ public <RESULT> RESULT pageRank(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
PageRank,
estimation::pageRank,
graph -> algorithms.pageRank(graph, configuration),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public <RESULT> RESULT articleRank(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
ArticleRank,
estimationFacade::pageRank,
graph -> centralityAlgorithms.articleRank(graph, configuration),
Expand All @@ -82,6 +83,7 @@ public <RESULT> RESULT betweennessCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
BetweennessCentrality,
() -> estimationFacade.betweennessCentrality(configuration),
graph -> centralityAlgorithms.betweennessCentrality(graph, configuration),
Expand All @@ -98,6 +100,7 @@ public <RESULT> RESULT celf(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
CELF,
() -> estimationFacade.celf(configuration),
graph -> centralityAlgorithms.celf(graph, configuration),
Expand All @@ -114,6 +117,7 @@ public <RESULT> RESULT closenessCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
ClosenessCentrality,
() -> estimationFacade.closenessCentrality(configuration),
graph -> centralityAlgorithms.closenessCentrality(graph, configuration),
Expand All @@ -130,6 +134,7 @@ public <RESULT> RESULT degreeCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
DegreeCentrality,
() -> estimationFacade.degreeCentrality(configuration),
graph -> centralityAlgorithms.degreeCentrality(graph, configuration),
Expand All @@ -146,6 +151,7 @@ public <RESULT> RESULT eigenVector(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
EigenVector,
estimationFacade::pageRank,
graph -> centralityAlgorithms.eigenVector(graph, configuration),
Expand All @@ -162,6 +168,7 @@ public <RESULT> RESULT harmonicCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
HarmonicCentrality,
estimationFacade::harmonicCentrality,
graph -> centralityAlgorithms.harmonicCentrality(graph, configuration),
Expand All @@ -178,6 +185,7 @@ public <RESULT> RESULT pageRank(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
PageRank,
estimationFacade::pageRank,
graph -> centralityAlgorithms.pageRank(graph, configuration),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public <RESULT> RESULT articleRank(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
ArticleRank,
estimationFacade::pageRank,
graph -> centralityAlgorithms.articleRank(graph, configuration),
Expand All @@ -83,6 +84,7 @@ public <RESULT> RESULT betweennessCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
BetweennessCentrality,
() -> estimationFacade.betweennessCentrality(configuration),
graph -> centralityAlgorithms.betweennessCentrality(graph, configuration),
Expand All @@ -99,6 +101,7 @@ public <RESULT> RESULT celf(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
CELF,
() -> estimationFacade.celf(configuration),
graph -> centralityAlgorithms.celf(graph, configuration),
Expand All @@ -115,6 +118,7 @@ public <RESULT> RESULT closenessCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
ClosenessCentrality,
() -> estimationFacade.closenessCentrality(configuration),
graph -> centralityAlgorithms.closenessCentrality(graph, configuration),
Expand All @@ -131,6 +135,7 @@ public <RESULT> RESULT degreeCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
DegreeCentrality,
() -> estimationFacade.degreeCentrality(configuration),
graph -> centralityAlgorithms.degreeCentrality(graph, configuration),
Expand All @@ -147,6 +152,7 @@ public <RESULT> RESULT eigenvector(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
EigenVector,
estimationFacade::pageRank,
graph -> centralityAlgorithms.eigenVector(graph, configuration),
Expand All @@ -163,6 +169,7 @@ public <RESULT> RESULT harmonicCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
HarmonicCentrality,
estimationFacade::harmonicCentrality,
graph -> centralityAlgorithms.harmonicCentrality(graph, configuration),
Expand All @@ -179,6 +186,7 @@ public <RESULT> RESULT pageRank(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
PageRank,
estimationFacade::pageRank,
graph -> centralityAlgorithms.pageRank(graph, configuration),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ public <RESULT> RESULT articleRank(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
ArticleRank,
estimationFacade::pageRank,
graph -> centralityAlgorithms.articleRank(graph, configuration),
Expand All @@ -115,6 +116,7 @@ public <RESULT> RESULT betweennessCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
BetweennessCentrality,
() -> estimationFacade.betweennessCentrality(configuration),
graph -> centralityAlgorithms.betweennessCentrality(graph, configuration),
Expand All @@ -133,6 +135,7 @@ public <CONFIGURATION extends InfluenceMaximizationWriteConfig, RESULT> RESULT c
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
CELF,
() -> estimationFacade.celf(configuration),
graph -> centralityAlgorithms.celf(graph, configuration),
Expand All @@ -151,6 +154,7 @@ public <RESULT> RESULT closenessCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
ClosenessCentrality,
() -> estimationFacade.closenessCentrality(configuration),
graph -> centralityAlgorithms.closenessCentrality(graph, configuration),
Expand All @@ -169,6 +173,7 @@ public <RESULT> RESULT degreeCentrality(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
DegreeCentrality,
() -> estimationFacade.degreeCentrality(configuration),
graph -> centralityAlgorithms.degreeCentrality(graph, configuration),
Expand All @@ -187,6 +192,7 @@ public <RESULT> RESULT eigenvector(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
EigenVector,
estimationFacade::pageRank,
graph -> centralityAlgorithms.eigenVector(graph, configuration),
Expand All @@ -205,6 +211,7 @@ public <CONFIGURATION extends HarmonicCentralityWriteConfig, RESULT> RESULT harm
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
HarmonicCentrality,
estimationFacade::harmonicCentrality,
graph -> centralityAlgorithms.harmonicCentrality(graph, configuration),
Expand All @@ -223,6 +230,7 @@ public <RESULT> RESULT pageRank(
return algorithmProcessingTemplate.processAlgorithm(
graphName,
configuration,
Optional.empty(),
PageRank,
estimationFacade::pageRank,
graph -> centralityAlgorithms.pageRank(graph, configuration),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public <RESULT> RESULT approximateMaximumKCut(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
ApproximateMaximumKCut,
() -> estimation.approximateMaximumKCut(configuration),
graph -> algorithms.approximateMaximumKCut(graph, configuration),
Expand All @@ -112,6 +113,7 @@ public <RESULT> RESULT k1Coloring(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
K1Coloring,
estimation::k1Coloring,
graph -> algorithms.k1Coloring(graph, configuration),
Expand All @@ -130,6 +132,7 @@ public <RESULT> RESULT kCore(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
KCore,
estimation::kCore,
graph -> algorithms.kCore(graph, configuration),
Expand All @@ -148,6 +151,7 @@ public <RESULT> RESULT kMeans(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
KMeans,
() -> estimation.kMeans(configuration),
graph -> algorithms.kMeans(graph, configuration),
Expand All @@ -166,6 +170,7 @@ public <RESULT> RESULT labelPropagation(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
LabelPropagation,
estimation::labelPropagation,
graph -> algorithms.labelPropagation(graph, configuration),
Expand All @@ -184,6 +189,7 @@ public <RESULT> RESULT lcc(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
LCC,
() -> estimation.lcc(configuration),
graph -> algorithms.lcc(graph, configuration),
Expand All @@ -202,6 +208,7 @@ public <RESULT> RESULT leiden(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
Leiden,
() -> estimation.leiden(configuration),
graph -> algorithms.leiden(graph, configuration),
Expand All @@ -220,6 +227,7 @@ public <RESULT> RESULT louvain(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
Louvain,
() -> estimation.louvain(configuration),
graph -> algorithms.louvain(graph, configuration),
Expand All @@ -238,6 +246,7 @@ public <RESULT> RESULT modularityOptimization(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
ModularityOptimization,
estimation::modularityOptimization,
graph -> algorithms.modularityOptimization(graph, configuration),
Expand All @@ -256,6 +265,7 @@ public <RESULT> RESULT scc(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
SCC,
estimation::scc,
graph -> algorithms.scc(graph, configuration),
Expand All @@ -274,6 +284,7 @@ public <RESULT> RESULT triangleCount(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
TriangleCount,
estimation::triangleCount,
graph -> algorithms.triangleCount(graph, configuration),
Expand All @@ -292,6 +303,7 @@ public <RESULT> RESULT wcc(
return template.processAlgorithm(
graphName,
configuration,
Optional.empty(),
WCC,
() -> estimation.wcc(configuration),
graph -> algorithms.wcc(graph, configuration),
Expand Down
Loading

0 comments on commit 68ee9a6

Please sign in to comment.