Skip to content

Commit 08ad32e

Browse files
Mats-SXvnickolov
authored andcommitted
Inline test setup to avoid polluting the manual
I would really like to rewrite the page to follow the algorithm template, with a syntax section and a proper example section with real setup and a nice image. Deferring that to productising these procs.
1 parent 9800adc commit 08ad32e

File tree

2 files changed

+36
-39
lines changed

2 files changed

+36
-39
lines changed

doc/asciidoc/model-catalog/model-catalog.adoc

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,6 @@ Training, using, listing, and dropping named models are management operations bo
3636
Models trained by a different Neo4j user are not accessible at any time.
3737
====
3838

39-
== Example setup
40-
41-
In the below code examples, we assume that a graph exists in Neo4j like this:
42-
43-
[source, cypher, role=setup-query]
44-
----
45-
CREATE (:Node)-[:T]->(:Node)
46-
----
47-
48-
And that a graph projection has been made and a model trained and inserted in the Model Catalog.
49-
In this case we use a GraphSage model, but any model will work the same.
50-
51-
[source, cypher, role=setup-query]
52-
----
53-
CALL gds.graph.create('myGraph', 'Node', 'T') YIELD graphName
54-
CALL gds.beta.graphSage.train('myGraph', {
55-
modelName: 'my-model', degreeAsProperty: true
56-
}) YIELD trainMillis
57-
RETURN *
58-
----
59-
6039

6140
[.beta]
6241
[[catalog-model-exists]]
@@ -94,17 +73,16 @@ Once we have trained models in the catalog we can see information about either a
9473
CALL gds.beta.model.list()
9574
YIELD
9675
modelInfo,
97-
graphSchema,
9876
loaded,
9977
stored,
10078
shared
10179
----
10280

10381
.Results
104-
[opts="header",cols="1m,1m,1m,1m,1m"]
82+
[opts="header",cols="1m,1m,1m,1m"]
10583
|===
106-
| modelInfo | graphSchema | loaded | stored | shared
107-
| {modelName=my-model, modelType=graphSage} | {relationships={T={}}, nodes={Node={}}} | true | false | false
84+
| modelInfo | loaded | stored | shared
85+
| {modelName=my-model, modelType=example-model-type} | true | false | false
10886
|===
10987
--
11088

@@ -116,17 +94,16 @@ YIELD
11694
CALL gds.beta.model.list('my-model')
11795
YIELD
11896
modelInfo,
119-
graphSchema,
12097
loaded,
12198
stored,
12299
shared
123100
----
124101

125102
.Results
126-
[opts="header",cols="1m,1m,1m,1m,1m"]
103+
[opts="header",cols="1m,1m,1m,1m"]
127104
|===
128-
| modelInfo | graphSchema | loaded | stored | shared
129-
| {modelName=my-model, modelType=graphSage} | {relationships={T={}}, nodes={Node={}}} | true | false | false
105+
| modelInfo | loaded | stored | shared
106+
| {modelName=my-model, modelType=example-model-type} | true | false | false
130107
|===
131108
--
132109

@@ -158,17 +135,16 @@ If we no longer need a trained model we can remove it from the catalog.
158135
CALL gds.beta.model.drop('my-model')
159136
YIELD
160137
modelInfo,
161-
graphSchema,
162138
loaded,
163139
stored,
164140
shared
165141
----
166142

167143
.Results
168-
[opts="header",cols="1m,1m,1m,1m,1m"]
144+
[opts="header",cols="1m,1m,1m,1m"]
169145
|===
170-
| modelInfo | graphSchema | loaded | stored | shared
171-
| {modelName=my-model, modelType=graphSage} | {relationships={T={}}, nodes={Node={}}} | true | false | false
146+
| modelInfo | loaded | stored | shared
147+
| {modelName=my-model, modelType=example-model-type} | true | false | false
172148
|===
173149
--
174150

doc/src/test/java/org/neo4j/graphalgo/doc/ModelCatalogDocTest.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,43 @@
1919
*/
2020
package org.neo4j.graphalgo.doc;
2121

22-
import org.neo4j.gds.embeddings.graphsage.GraphSageTrainProc;
23-
import org.neo4j.graphalgo.catalog.GraphCreateProc;
22+
import org.junit.jupiter.api.AfterEach;
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.neo4j.graphalgo.api.schema.GraphSchema;
25+
import org.neo4j.graphalgo.config.ModelConfig;
26+
import org.neo4j.graphalgo.core.model.Model;
27+
import org.neo4j.graphalgo.core.model.ModelCatalog;
2428
import org.neo4j.graphalgo.model.catalog.ModelDropProc;
2529
import org.neo4j.graphalgo.model.catalog.ModelExistsProc;
2630
import org.neo4j.graphalgo.model.catalog.ModelListProc;
2731

28-
import java.util.Arrays;
2932
import java.util.List;
3033

3134
class ModelCatalogDocTest extends DocTestBase {
3235

36+
@Override
37+
@BeforeEach
38+
void setUp() throws Exception {
39+
super.setUp();
40+
ModelCatalog.set(Model.of(
41+
getUsername(),
42+
"my-model",
43+
"example-model-type",
44+
GraphSchema.empty(),
45+
new Object(),
46+
(ModelConfig) () -> "my-model",
47+
Model.Mappable.EMPTY
48+
));
49+
}
50+
51+
@AfterEach
52+
void tearDown() {
53+
ModelCatalog.removeAllLoadedModels();
54+
}
55+
3356
@Override
3457
List<Class<?>> procedures() {
35-
return Arrays.asList(
36-
GraphCreateProc.class,
37-
GraphSageTrainProc.class,
58+
return List.of(
3859
ModelListProc.class,
3960
ModelExistsProc.class,
4061
ModelDropProc.class

0 commit comments

Comments
 (0)