Skip to content

Commit e866081

Browse files
Mats-SXvnickolov
authored andcommitted
Add DocTest for ModelStore procs
- tests are no-result and invisible setup because alpha
1 parent 07d11be commit e866081

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ The `gds.model.store_location` parameter must be configured for this feature.
2323
[[catalog-model-store]]
2424
== Storing models from the catalog on disk
2525

26+
[role=query-example, no-result=true]
27+
--
2628
.Store a model on disk:
2729
[source,cypher]
2830
----
@@ -31,6 +33,7 @@ YIELD
3133
modelName,
3234
storeMillis
3335
----
36+
--
3437

3538
.Results
3639
* `modelName`: The name of the stored model.
@@ -45,6 +48,8 @@ GDS will discover available models from the configured store location upon datab
4548
During discovery, only model metadata is loaded, not the actual model data.
4649
In order to use a stored model, it has to be explicitly loaded.
4750

51+
[role=query-example, no-result=true]
52+
--
4853
.Store a model on disk:
4954
[source,cypher]
5055
----
@@ -53,6 +58,7 @@ YIELD
5358
modelName,
5459
loadMillis
5560
----
61+
--
5662

5763
.Results
5864
* `modelName`: The name of the stored model.
@@ -71,6 +77,8 @@ This is different from dropping a model.
7177
Dropping a model will remove it from the in-memory model catalog, but not from disk.
7278
Deleting a model will remove it from disk, but keep it in the in-memory model catalog if it was already loaded.
7379

80+
[role=query-example, no-result=true]
81+
--
7482
.Store a model on disk:
7583
[source,cypher]
7684
----
@@ -79,6 +87,7 @@ YIELD
7987
modelName,
8088
deleteMillis
8189
----
90+
--
8291

8392
.Results
8493
* `modelName`: The name of the stored model.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (c) "Neo4j"
3+
* Neo4j Sweden AB [http://neo4j.com]
4+
*
5+
* This file is part of Neo4j.
6+
*
7+
* Neo4j is free software: you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation, either version 3 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License
18+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
19+
*/
20+
package org.neo4j.graphalgo.doc;
21+
22+
import org.junit.jupiter.api.AfterEach;
23+
import org.junit.jupiter.api.BeforeEach;
24+
import org.junit.jupiter.api.io.TempDir;
25+
import org.neo4j.configuration.Config;
26+
import org.neo4j.gds.embeddings.graphsage.Layer;
27+
import org.neo4j.gds.embeddings.graphsage.ModelData;
28+
import org.neo4j.gds.embeddings.graphsage.SingleLabelFeatureFunction;
29+
import org.neo4j.gds.embeddings.graphsage.algo.GraphSage;
30+
import org.neo4j.gds.embeddings.graphsage.algo.ImmutableGraphSageTrainConfig;
31+
import org.neo4j.graphalgo.api.schema.GraphSchema;
32+
import org.neo4j.graphalgo.compat.GraphDatabaseApiProxy;
33+
import org.neo4j.graphalgo.core.GdsEdition;
34+
import org.neo4j.graphalgo.core.ModelStoreSettings;
35+
import org.neo4j.graphalgo.core.model.Model;
36+
import org.neo4j.graphalgo.core.model.ModelCatalog;
37+
import org.neo4j.graphalgo.model.catalog.ModelDeleteProc;
38+
import org.neo4j.graphalgo.model.catalog.ModelLoadProc;
39+
import org.neo4j.graphalgo.model.catalog.ModelStoreProc;
40+
41+
import java.nio.file.Path;
42+
import java.util.List;
43+
44+
class ModelCatalogStoreDocTest extends DocTestBase {
45+
46+
@TempDir
47+
Path modelStoreLocation;
48+
49+
@Override
50+
@BeforeEach
51+
void setUp() throws Exception {
52+
super.setUp();
53+
GraphDatabaseApiProxy
54+
.resolveDependency(db, Config.class)
55+
.set(ModelStoreSettings.model_store_location, modelStoreLocation);
56+
GdsEdition.instance().setToEnterpriseEdition();
57+
ModelCatalog.set(Model.of(
58+
getUsername(),
59+
"my-model",
60+
GraphSage.MODEL_TYPE,
61+
GraphSchema.empty(),
62+
ModelData.of(new Layer[0], new SingleLabelFeatureFunction()),
63+
ImmutableGraphSageTrainConfig.builder().modelName("my-model").degreeAsProperty(true).build(),
64+
Model.Mappable.EMPTY
65+
));
66+
}
67+
68+
@AfterEach
69+
void tearDown() {
70+
ModelCatalog.drop(getUsername(), "my-model");
71+
GdsEdition.instance().setToCommunityEdition();
72+
}
73+
74+
@Override
75+
List<Class<?>> procedures() {
76+
return List.of(
77+
ModelStoreProc.class,
78+
ModelDeleteProc.class,
79+
ModelLoadProc.class
80+
);
81+
}
82+
83+
@Override
84+
String adocFile() {
85+
return "model-catalog/model-catalog-store.adoc";
86+
}
87+
}

0 commit comments

Comments
 (0)