generated from Exabyte-io/template-definitions
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
376116a
commit 017418a
Showing
15 changed files
with
552 additions
and
510 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
import { allApplications, getAppData, getAppTree } from "@exabyte-io/application-flavors.js"; | ||
import { NamedDefaultableHashedInMemoryEntity } from "@exabyte-io/code.js/dist/entity"; | ||
import lodash from "lodash"; | ||
|
||
import { Executable } from "./executable"; | ||
import { getApplicationConfig, getExecutableConfig } from "./tree"; | ||
|
||
export type ApplicationConfig = { | ||
name: string; | ||
version?: string; | ||
build?: string; | ||
}; | ||
|
||
type ApplicationBaseEntity = InstanceType<typeof NamedDefaultableHashedInMemoryEntity>; | ||
|
||
export type ApplicationBaseEntityConstructor<T extends ApplicationBaseEntity = ApplicationBaseEntity> = new ( | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
...args: any[] | ||
) => T; | ||
|
||
export function ApplicationMixin< | ||
T extends ApplicationBaseEntityConstructor = ApplicationBaseEntityConstructor, | ||
>(superclass: T) { | ||
return class extends superclass { | ||
static Executable = Executable; | ||
|
||
constructor(...config: any[]) { | ||
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" }: {name: string, version?: string | null, build?: string}) { | ||
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: string[] = versions.map((v) => v.version); | ||
return lodash.uniq(these); | ||
} | ||
|
||
static getUniqueAvailableNames() { | ||
return allApplications; | ||
} | ||
|
||
getExecutableByName(name: string | null = null) { | ||
return new Application.Executable( | ||
getExecutableConfig({ | ||
appName: this.prop("name"), | ||
execName: name, | ||
}), | ||
); | ||
} | ||
|
||
getExecutableByConfig(config: {name: string} | null | undefined = null) { | ||
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 Application.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); | ||
} | ||
} | ||
} | ||
|
||
export const Application = ApplicationMixin( | ||
NamedDefaultableHashedInMemoryEntity, | ||
); | ||
|
||
export type Application = InstanceType<typeof Application>; |
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.