Skip to content

Commit 974c51b

Browse files
committed
Handle stored models in backup/shutdown_new and restore
This also underlines the problem of the old shutdown dropping resources. We also always load the stored models for convenience (and avoid unexpectedly unloaded models inside Aura)
1 parent 501adff commit 974c51b

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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.gds.core.model;
21+
22+
import org.neo4j.gds.annotation.ValueClass;
23+
import org.neo4j.gds.model.ModelConfig;
24+
25+
import java.time.ZonedDateTime;
26+
27+
@ValueClass
28+
public
29+
interface ModelHash {
30+
String user();
31+
32+
String name();
33+
34+
ZonedDateTime timestamp();
35+
36+
static ModelHash of(ModelMetaData<? extends ModelConfig, ?> modelMetaData) {
37+
return ImmutableModelHash.of(
38+
modelMetaData.creator(),
39+
modelMetaData.name(),
40+
modelMetaData.creationTime()
41+
);
42+
}
43+
44+
static ModelHash of(Model<?, ?, ?> model) {
45+
return ImmutableModelHash.of(
46+
model.creator(),
47+
model.name(),
48+
model.creationTime()
49+
);
50+
}
51+
}

model-catalog-api/src/main/java/org/neo4j/gds/core/model/ModelMetaData.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020
package org.neo4j.gds.core.model;
2121

22+
import org.immutables.value.Value;
2223
import org.neo4j.gds.annotation.ValueClass;
2324
import org.neo4j.gds.api.schema.GraphSchema;
2425
import org.neo4j.gds.config.ToMapConvertible;
@@ -27,6 +28,8 @@
2728
import java.time.ZonedDateTime;
2829
import java.util.List;
2930

31+
import static org.neo4j.gds.core.model.Model.ALL_USERS;
32+
3033
@ValueClass
3134
public interface ModelMetaData<CONFIG extends ModelConfig, INFO extends ToMapConvertible> {
3235

@@ -45,4 +48,9 @@ public interface ModelMetaData<CONFIG extends ModelConfig, INFO extends ToMapCon
4548
ZonedDateTime creationTime();
4649

4750
INFO customInfo();
51+
52+
@Value.Derived
53+
default boolean isPublished() {
54+
return sharedWith().contains(ALL_USERS);
55+
}
4856
}

0 commit comments

Comments
 (0)