generated from Exabyte-io/template-definitions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
application.js
124 lines (102 loc) · 3.38 KB
/
application.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { allApplications, getAppData, getAppTree } from "@exabyte-io/application-flavors.js";
import { NamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity";
import lodash from "lodash";
import { Executable } from "./executable";
import { getApplicationConfig, getExecutableConfig } from "./tree";
export class Application extends NamedDefaultableInMemoryEntity {
static Executable = Executable;
constructor(config) {
const staticConfig = getApplicationConfig(config);
super({ ...staticConfig, ...config });
}
// TODO: extract this from application-flavors "global" default config for espresso 5.4.0
static get defaultConfig() {
return {
name: "espresso",
shortName: "qe",
version: "6.3",
summary: "Quantum Espresso",
build: "Default",
};
}
static create(config) {
return this.createFromNameVersionBuild(config);
}
static createFromNameVersionBuild({ name, version = null, build = "Default" }) {
return new Application({ name, version, build });
}
getExecutables() {
return this.executables;
}
getBuilds() {
const data = getAppData(this.prop("name"));
const { versions } = data;
const builds = ["Default"];
versions.map((v) => v.build && builds.push(v.build));
return lodash.uniq(builds);
}
getVersions() {
const data = getAppData(this.prop("name"));
const { versions } = data;
const these = versions.map((v) => v.version);
return lodash.uniq(these);
}
static getUniqueAvailableNames() {
return allApplications;
}
getExecutableByName(name = null) {
return new this.constructor.Executable(
getExecutableConfig({
appName: this.prop("name"),
execName: name,
}),
);
}
getExecutableByConfig(config) {
return config ? this.getExecutableByName(config.name) : this.defaultExecutable;
}
get defaultExecutable() {
return this.getExecutableByName();
}
// override upon inheritance
// eslint-disable-next-line class-methods-use-this
get allowedModelTypes() {
return [];
}
get summary() {
return this.prop("summary");
}
get version() {
return this.prop("version");
}
get build() {
return this.prop("build");
}
get shortName() {
return this.prop("shortName", this.prop("name"));
}
get executables() {
const tree = getAppTree(this.prop("name"));
return Object.keys(tree)
.filter((key) => {
const { supportedApplicationVersions } = tree[key];
return (
!supportedApplicationVersions ||
supportedApplicationVersions.includes(this.prop("version"))
);
})
.map((key) => {
return new this.constructor.Executable({ ...tree[key], name: key });
});
}
get hasAdvancedComputeOptions() {
return this.prop("hasAdvancedComputeOptions");
}
get isLicensed() {
return this.prop("isLicensed");
}
get isUsingMaterial() {
const materialUsingApplications = ["vasp", "nwchem", "espresso", "exabyteml"];
return materialUsingApplications.includes(this.name);
}
}