Skip to content

Commit

Permalink
Remove dependency to :opengds-procedure-facade where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
vnickolov committed Oct 22, 2024
1 parent cfa69e3 commit 29c165a
Show file tree
Hide file tree
Showing 16 changed files with 51 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
package org.neo4j.gds.catalog;

import org.junit.jupiter.api.Test;
import org.neo4j.gds.procedures.LocalGraphDataScienceProcedures;
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
import org.neo4j.gds.procedures.catalog.GraphCatalogProcedureFacade;
import org.neo4j.gds.procedures.catalog.GraphInfo;
import org.neo4j.gds.procedures.catalog.LocalGraphCatalogProcedureFacade;

import java.util.stream.Stream;

Expand All @@ -33,11 +33,11 @@
class GraphDropProcTest {
@Test
void shouldDelegateToFacade() {
var facade = mock(LocalGraphDataScienceProcedures.class);
var facade = mock(GraphDataScienceProcedures.class);
var procedure = new GraphDropProc(facade);

var expectedResult = Stream.<GraphInfo>of();
var catalogFacade = mock(LocalGraphCatalogProcedureFacade.class);
var catalogFacade = mock(GraphCatalogProcedureFacade.class);
when(facade.graphCatalog()).thenReturn(catalogFacade);
when(catalogFacade.dropGraph("my graph", true, "some database", "some user")).thenReturn(expectedResult);
var actualResult = procedure.dropGraph("my graph", true, "some database", "some user");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
package org.neo4j.gds.catalog;

import org.junit.jupiter.api.Test;
import org.neo4j.gds.procedures.LocalGraphDataScienceProcedures;
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
import org.neo4j.gds.procedures.catalog.GraphCatalogProcedureFacade;
import org.neo4j.gds.procedures.catalog.GraphInfoWithHistogram;
import org.neo4j.gds.procedures.catalog.LocalGraphCatalogProcedureFacade;

import java.util.stream.Stream;

Expand All @@ -33,11 +33,11 @@
class GraphListProcTest {
@Test
void shouldDelegateToFacade() {
var facade = mock(LocalGraphDataScienceProcedures.class);
var facade = mock(GraphDataScienceProcedures.class);
var procedure = new GraphListProc(facade);

var expectedResultStream = Stream.of(mock(GraphInfoWithHistogram.class));
var catalogFacade = mock(LocalGraphCatalogProcedureFacade.class);
var catalogFacade = mock(GraphCatalogProcedureFacade.class);
when(facade.graphCatalog()).thenReturn(catalogFacade);
when(catalogFacade.listGraphs("some graph")).thenReturn(expectedResultStream);
var actualResultStream = procedure.listGraphs("some graph");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
package org.neo4j.gds.catalog;

import org.junit.jupiter.api.Test;
import org.neo4j.gds.procedures.LocalGraphDataScienceProcedures;
import org.neo4j.gds.procedures.catalog.LocalGraphCatalogProcedureFacade;
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
import org.neo4j.gds.procedures.catalog.GraphCatalogProcedureFacade;
import org.neo4j.gds.projection.GraphProjectNativeResult;

import java.util.Map;
Expand All @@ -35,7 +35,7 @@
class NativeProjectProcedureTest {
@Test
void shouldDelegateToFacade() {
var facade = mock(LocalGraphDataScienceProcedures.class);
var facade = mock(GraphDataScienceProcedures.class);
var procedure = new GraphProjectProc(facade);

// perhaps a bit elaborate to type these out in detail;
Expand All @@ -62,7 +62,7 @@ void shouldDelegateToFacade() {
87,
117
));
var catalogFacade = mock(LocalGraphCatalogProcedureFacade.class);
var catalogFacade = mock(GraphCatalogProcedureFacade.class);
when(facade.graphCatalog()).thenReturn(catalogFacade);
when(catalogFacade.nativeProject(
"some graph",
Expand Down
2 changes: 1 addition & 1 deletion proc/common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dependencies {
implementation project(':neo4j-api')
implementation project(':neo4j-log-adapter')
// this is needed because of `TransactionNodeLookup` 🙈
implementation project(':opengds-procedure-facade')
// implementation project(':opengds-procedure-facade')
implementation project(':open-licensing')
implementation project(':pregel')
implementation project(':procedure-integration')
Expand Down
2 changes: 1 addition & 1 deletion proc/common/src/main/java/org/neo4j/gds/BaseProc.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.neo4j.gds.metrics.Metrics;
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
import org.neo4j.gds.procedures.ProcedureCallContextReturnColumns;
import org.neo4j.gds.procedures.TransactionCloseableResourceRegistry;
import org.neo4j.gds.transaction.TransactionCloseableResourceRegistry;
import org.neo4j.gds.transaction.TransactionNodeLookup;
import org.neo4j.gds.termination.TransactionTerminationMonitor;
import org.neo4j.gds.transaction.DatabaseTransactionContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import org.neo4j.gds.metrics.algorithms.AlgorithmMetricsService;
import org.neo4j.gds.metrics.procedures.DeprecatedProceduresMetricService;
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
import org.neo4j.gds.procedures.GraphDataScienceProceduresBuilder;
import org.neo4j.gds.procedures.algorithms.AlgorithmsProcedureFacade;
import org.neo4j.gds.procedures.algorithms.community.LocalCommunityProcedureFacade;
import org.neo4j.gds.procedures.algorithms.configuration.ConfigurationParser;
Expand All @@ -98,6 +97,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.neo4j.gds.ElementProjection.PROJECT_ALL;
import static org.neo4j.gds.NodeLabel.ALL_NODES;
import static org.neo4j.gds.TestSupport.assertGraphEquals;
Expand Down Expand Up @@ -549,9 +549,11 @@ private GraphDataScienceProcedures constructFacade() {
)
);

return new GraphDataScienceProceduresBuilder(Log.noOpLog())
.with(new AlgorithmsProcedureFacade(null, communityProcedureFacade, null, null, null, null, null))
.with(DeprecatedProceduresMetricService.DISABLED)
.build();
var graphDataScienceProceduresMock = mock(GraphDataScienceProcedures.class);
var algorithmsProcedureFacade = new AlgorithmsProcedureFacade(null, communityProcedureFacade, null, null, null, null, null);
when(graphDataScienceProceduresMock.algorithms())
.thenReturn(algorithmsProcedureFacade);
when(graphDataScienceProceduresMock.deprecatedProcedures()).thenReturn(DeprecatedProceduresMetricService.DISABLED);
return graphDataScienceProceduresMock;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
import org.neo4j.gds.metrics.procedures.DeprecatedProceduresMetricService;
import org.neo4j.gds.metrics.projections.ProjectionMetricsService;
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
import org.neo4j.gds.procedures.GraphDataScienceProceduresBuilder;
import org.neo4j.gds.procedures.algorithms.AlgorithmsProcedureFacade;
import org.neo4j.gds.procedures.algorithms.community.LocalCommunityProcedureFacade;
import org.neo4j.gds.procedures.algorithms.configuration.ConfigurationParser;
Expand All @@ -98,6 +97,7 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.neo4j.gds.ElementProjection.PROJECT_ALL;
import static org.neo4j.gds.GdsCypher.ExecutionModes.MUTATE;
import static org.neo4j.gds.NodeLabel.ALL_NODES;
Expand Down Expand Up @@ -561,9 +561,11 @@ private GraphDataScienceProcedures createFacade() {
)
);

return new GraphDataScienceProceduresBuilder(logMock)
.with(new AlgorithmsProcedureFacade(null, communityProcedureFacade, null, null, null, null, null))
.with(DeprecatedProceduresMetricService.DISABLED)
.build();
var graphDataScienceProceduresMock = mock(GraphDataScienceProcedures.class);
var algorithmsProcedureFacade = new AlgorithmsProcedureFacade(null, communityProcedureFacade, null, null, null, null, null);
when(graphDataScienceProceduresMock.algorithms())
.thenReturn(algorithmsProcedureFacade);
when(graphDataScienceProceduresMock.deprecatedProcedures()).thenReturn(DeprecatedProceduresMetricService.DISABLED);
return graphDataScienceProceduresMock;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
import org.neo4j.gds.metrics.procedures.DeprecatedProceduresMetricService;
import org.neo4j.gds.metrics.projections.ProjectionMetricsService;
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
import org.neo4j.gds.procedures.GraphDataScienceProceduresBuilder;
import org.neo4j.gds.procedures.algorithms.AlgorithmsProcedureFacade;
import org.neo4j.gds.procedures.algorithms.community.LocalCommunityProcedureFacade;
import org.neo4j.gds.procedures.algorithms.community.WccMutateResult;
Expand Down Expand Up @@ -105,6 +104,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.neo4j.gds.ElementProjection.PROJECT_ALL;
import static org.neo4j.gds.NodeLabel.ALL_NODES;
import static org.neo4j.gds.TestSupport.assertGraphEquals;
Expand Down Expand Up @@ -633,9 +633,11 @@ private GraphDataScienceProcedures constructGraphDataScienceProcedures() {
)
);

return new GraphDataScienceProceduresBuilder(Log.noOpLog())
.with(new AlgorithmsProcedureFacade(null, communityProcedureFacade, null, null, null, null, null))
.with(DeprecatedProceduresMetricService.DISABLED)
.build();
var graphDataScienceProceduresMock = mock(GraphDataScienceProcedures.class);
var algorithmsProcedureFacade = new AlgorithmsProcedureFacade(null, communityProcedureFacade, null, null, null, null, null);
when(graphDataScienceProceduresMock.algorithms())
.thenReturn(algorithmsProcedureFacade);
when(graphDataScienceProceduresMock.deprecatedProcedures()).thenReturn(DeprecatedProceduresMetricService.DISABLED);
return graphDataScienceProceduresMock;
}
}
2 changes: 2 additions & 0 deletions proc/machine-learning/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ dependencies {
testCompileOnly openGds.immutables.builder
testCompileOnly openGds.jetbrains.annotations

testImplementation project(':algorithms-procedure-facade')
testImplementation project(':logging')
testImplementation project(':opengds-procedure-facade')
testImplementation project(':open-model-catalog')
testImplementation project(':proc-test')
testImplementation project(':proc-common')
Expand Down
5 changes: 3 additions & 2 deletions proc/pregel/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ dependencies {

implementation project(':annotations')
implementation project(':algo-common')
// implementation project(':algorithms-procedure-facade')
implementation project(':algorithms-facade-api')
implementation project(':config-api')
implementation project(':core')
implementation project(':core-write')
Expand All @@ -32,10 +32,11 @@ dependencies {

testCompileOnly openGds.immutables.builder

testImplementation project(':algorithms-machinery')
testImplementation project(':memory-usage')
testImplementation project(':licensing')
testImplementation project(':logging')
testImplementation project(':opengds-procedure-facade')
testImplementation project(':procedures-facade-api')
testImplementation project(':open-licensing')
testImplementation project(':test-utils')
testImplementation project(':proc-catalog')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
import org.neo4j.gds.metrics.Metrics;
import org.neo4j.gds.procedures.algorithms.configuration.NewConfigFunction;
import org.neo4j.gds.executor.ProcedureExecutor;
import org.neo4j.gds.procedures.LocalGraphDataScienceProcedures;
import org.neo4j.gds.procedures.GraphDataScienceProcedures;
import org.neo4j.internal.kernel.api.procs.ProcedureCallContext;
import org.neo4j.logging.NullLog;
import org.neo4j.procedure.Context;
Expand Down Expand Up @@ -215,7 +215,7 @@ void cleanupTaskRegistryWhenTheAlgorithmFailsInStreamMode() {
proc.callContext = ProcedureCallContext.EMPTY;

proc.metrics = Metrics.DISABLED;
proc.graphDataScienceProcedures = mock(LocalGraphDataScienceProcedures.class);
proc.graphDataScienceProcedures = mock(GraphDataScienceProcedures.class);

Map<String, Object> config = Map.of(
"maxIterations", 20,
Expand Down Expand Up @@ -244,7 +244,7 @@ void cleanupTaskRegistryWhenTheAlgorithmFailsInWriteMode() {
proc.callContext = ProcedureCallContext.EMPTY;

proc.metrics = Metrics.DISABLED;
proc.graphDataScienceProcedures = mock(LocalGraphDataScienceProcedures.class);
proc.graphDataScienceProcedures = mock(GraphDataScienceProcedures.class);

Map<String, Object> config = Map.of(
"maxIterations", 20,
Expand Down Expand Up @@ -272,7 +272,7 @@ void cleanupTaskRegistryWhenTheAlgorithmFailsInMutateMode() {
proc.callContext = ProcedureCallContext.EMPTY;

proc.metrics = Metrics.DISABLED;
proc.graphDataScienceProcedures = mock(LocalGraphDataScienceProcedures.class);
proc.graphDataScienceProcedures = mock(GraphDataScienceProcedures.class);

Map<String, Object> config = Map.of(
"maxIterations", 20,
Expand Down
3 changes: 3 additions & 0 deletions procedures/algorithms-facade/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ dependencies {
testImplementation openGds.mockito.junit.jupiter
testImplementation openGds.assertj.core

testImplementation group: 'org.neo4j', name: 'neo4j-graphdb-api', version: ver.'neo4j'
testImplementation group: 'org.neo4j', name: 'neo4j-kernel-api', version: ver.'neo4j'

testRuntimeOnly openGds.junit5.jupiter.engine


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.gds.paths.traverse;
package org.neo4j.gds.procedures.algorithms.pathfinding;

import org.junit.jupiter.api.Test;
import org.neo4j.gds.collections.ha.HugeLongArray;
import org.neo4j.gds.procedures.algorithms.pathfinding.PathFactoryFacade;
import org.neo4j.gds.procedures.algorithms.pathfinding.TraverseStreamComputationResultConsumer;
import org.neo4j.graphdb.Path;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.kernel.impl.coreapi.InternalTransaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.neo4j.gds.procedures.algorithms.pathfinding.LocalPathFindingProcedureFacade;
import org.neo4j.gds.procedures.algorithms.similarity.LocalSimilarityProcedureFacade;
import org.neo4j.gds.procedures.algorithms.stubs.GenericStub;
import org.neo4j.gds.transaction.TransactionCloseableResourceRegistry;
import org.neo4j.gds.transaction.TransactionNodeLookup;
import org.neo4j.kernel.api.KernelTransaction;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
import org.neo4j.gds.procedures.pipelines.PipelineRepository;
import org.neo4j.gds.procedures.pipelines.PipelinesProcedureFacade;
import org.neo4j.gds.termination.TerminationMonitor;
import org.neo4j.gds.transaction.TransactionCloseableResourceRegistry;
import org.neo4j.gds.transaction.TransactionNodeLookup;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.Transaction;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.gds.procedures;
package org.neo4j.gds.transaction;

import org.neo4j.gds.api.CloseableResourceRegistry;
import org.neo4j.kernel.api.KernelTransaction;
Expand Down

0 comments on commit 29c165a

Please sign in to comment.