Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
224c7ce
chore: move tests from code
k0stik Jun 18, 2025
24a61c9
fix: tests
k0stik Jun 18, 2025
8ddcb6d
chore: cleanup
k0stik Jun 19, 2025
6960879
chore: introduce context providers settings
k0stik Jun 19, 2025
3efccc0
chore: introduce context providers settings
k0stik Jun 19, 2025
1477c63
fix: atomicPositions in NWChemTotalEnergyContextProvider
k0stik Jun 20, 2025
353e1f7
fix: atomicPositions in NWChemTotalEnergyContextProvider
k0stik Jun 20, 2025
cc97ae3
chore: cleanup
k0stik Jun 23, 2025
68a4f0e
chore: fix TaggableMixin usage
k0stik Jun 24, 2025
5e2e3de
chore: new ade
k0stik Jun 25, 2025
46194f0
chore: new ade
k0stik Jun 26, 2025
4508df3
chore: new ade
k0stik Jun 27, 2025
83e35c4
fix: default entities
k0stik Jul 1, 2025
3128c72
fix: default entities
k0stik Jul 1, 2025
d739b10
fix: default entities
k0stik Jul 1, 2025
e9428f5
chore: remove HashedInputArrayMixin usage
k0stik Jul 2, 2025
41266de
fix: ExecutionUnitConfigBuilder
k0stik Jul 3, 2025
2508199
fix: ExecutionUnitConfigBuilder
k0stik Jul 3, 2025
bafcb52
chore: docstring
k0stik Jul 3, 2025
442c846
chore: use AdeFactory in createSubworkflow
k0stik Jul 3, 2025
db8b5c8
chore: add 'properties are not empty' test
k0stik Jul 3, 2025
3f0a0df
chore: update ade
k0stik Jul 15, 2025
a18f766
chore: resolve conflicts
k0stik Jul 15, 2025
1774d3e
chore: update ade
k0stik Jul 15, 2025
4d876e8
chore: update code/made/ade
k0stik Jul 15, 2025
dd6c429
chore: update code/made/ade
k0stik Jul 15, 2025
be8965d
chore: resolve conflicts
k0stik Jul 15, 2025
4a5a788
chore: resolve conflicts
k0stik Jul 15, 2025
d4bebdb
Merge pull request #95 from Exabyte-io/chore/SOF-7640
k0stik Jul 15, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
{
"extends": ["@exabyte-io/eslint-config"]
"extends": [
"@exabyte-io/eslint-config"
],
"ignorePatterns": [
"dist/",
"src/workflows/workflows.js"
],
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".jsx",
".ts",
".tsx"
]
}
}
}
}

4,580 changes: 2,401 additions & 2,179 deletions package-lock.json

Large diffs are not rendered by default.

12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
"@babel/preset-react": "7.16.7",
"@babel/register": "^7.16.0",
"@babel/runtime-corejs3": "7.16.8",
"@exabyte-io/periodic-table.js": "2022.6.8-0",
"crypto-js": "^4.2.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"mixwith": "^0.1.1",
Expand All @@ -47,14 +49,14 @@
"v20": "^0.1.0"
},
"devDependencies": {
"@exabyte-io/ade.js": "2025.5.5-0",
"@exabyte-io/ade.js": "2025.7.15-1",
"@exabyte-io/application-flavors.js": "2025.7.8-0",
"@exabyte-io/eslint-config": "^2022.11.17-0",
"@exabyte-io/eslint-config": "2025.5.13-0",
"@exabyte-io/ide.js": "2024.3.26-0",
"@exabyte-io/mode.js": "2024.4.28-0",
"@mat3ra/code": "2025.4.27-0",
"@mat3ra/esse": "2025.4.26-0",
"@mat3ra/made": "2025.4.30-0",
"@mat3ra/code": "2025.7.15-0",
"@mat3ra/esse": "2025.7.15-0",
"@mat3ra/made": "2025.7.15-0",
"chai": "^4.3.4",
"eslint": "7.32.0",
"eslint-config-airbnb": "19.0.2",
Expand Down
10 changes: 10 additions & 0 deletions src/context/context.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { BoundaryConditionsFormDataProvider } from "./providers/BoundaryConditionsFormDataProvider";
import QENEBContextProvider from "./providers/by_application/espresso/QENEBContextProvider";
import QEPWXContextProvider from "./providers/by_application/espresso/QEPWXContextProvider";
import NWChemTotalEnergyContextProvider from "./providers/by_application/nwchem/NWChemTotalEnergyContextProvider";
import VASPContextProvider from "./providers/by_application/vasp/VASPContextProvider";
import VASPNEBContextProvider from "./providers/by_application/vasp/VASPNEBContextProvider";
import { CollinearMagnetizationContextProvider } from "./providers/CollinearMagnetizationContextProvider";
import { HubbardContextProviderLegacy } from "./providers/HubbardContextProviderLegacy";
import { HubbardJContextProvider } from "./providers/HubbardJContextProvider";
Expand Down Expand Up @@ -34,4 +39,9 @@ export default {
IonDynamicsContextProvider,
CollinearMagnetizationContextProvider,
NonCollinearMagnetizationContextProvider,
VASPContextProvider,
VASPNEBContextProvider,
QEPWXContextProvider,
QENEBContextProvider,
NWChemTotalEnergyContextProvider,
};
19 changes: 19 additions & 0 deletions src/context/mixins/ApplicationContextMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { globalSettings } from "../providers/settings";

export function applicationContextMixin(item) {
const properties = {
_application: undefined,

initApplicationContextMixin() {
this._application =
(this.config.context && this.config.context.application) ||
globalSettings.Application.createDefault();
},

get application() {
return this._application;
},
};

Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
}
36 changes: 36 additions & 0 deletions src/context/mixins/JobContextMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const defaultJob = {
workflow: {
subworkflows: [],
units: [],
},
status: "pre-submission",
compute: {
queue: "D",
nodes: 1,
ppn: 1,
timeLimit: "3600",
},
_project: {
_id: "",
},
};

export function jobContextMixin(item) {
const properties = {
isEdited: false,

_job: defaultJob,

get job() {
return this._job;
},

initJobContextMixin() {
const { config } = this;
this._job = (config.context && config.context.job) || defaultJob;
this.isEdited = false; // we always get the `defaultData` (recalculated from scratch, not persistent)
},
};

Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
}
41 changes: 41 additions & 0 deletions src/context/mixins/MaterialContextMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { globalSettings } from "../providers/settings";

export function materialContextMixin(item) {
const properties = {
_material: undefined,

updateMaterialHash() {
if (this.isEditedIsSetToFalseOnMaterialUpdate) this.isEdited = false;
this.extraData = { materialHash: this.material.hash };
},

// Workaround: Material.createDefault() used to initiate workflow reducer and hence here too
// does not have an id. Here we catch when such material is used and avoid resetting isEdited
get isMaterialCreatedDefault() {
return !this.material.id;
},

get isMaterialUpdated() {
return Boolean(this.extraData && this.extraData.materialHash !== this.material.hash);
},

get material() {
if (!this._material) {
throw new Error("Material is not set");
}
return this._material;
},

initMaterialContextMixin() {
this._material = this.config.context && this.config.context.material;

if (!this._material) {
this._material = globalSettings.Material.createDefault();
}

this.updateMaterialHash();
},
};

Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
}
18 changes: 18 additions & 0 deletions src/context/mixins/MaterialsContextMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { globalSettings } from "../providers/settings";

export function materialsContextMixin(item) {
const properties = {
get materials() {
return this._materials;
},
initMaterialsContextMixin() {
const materials = this.config.context?.materials;
this._materials =
materials && materials.length
? materials
: [globalSettings.Material.createDefault()];
},
};

Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
}
24 changes: 24 additions & 0 deletions src/context/mixins/MaterialsSetContextMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { compareEntitiesInOrderedSetForSorting } from "@mat3ra/code/dist/js/entity/set/ordered/utils";

export function materialsSetContextMixin(item) {
const properties = {
_materialsSet: undefined,

get materialsSet() {
return this._materialsSet;
},

initMaterialsSetContextMixin() {
this._materialsSet = this.config.context?.materialsSet;
},

sortMaterialsByIndexInSet(materials = []) {
// DO NOT SORT IN PLACE AS IT CHANGES THE ORDER IN `this.materials` AND HAS SIDE EFFECTS (MaterialViewer).
return materials.concat().sort((a, b) => {
return compareEntitiesInOrderedSetForSorting(a, b, this.materialsSet._id, false);
});
},
};

Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
}
48 changes: 48 additions & 0 deletions src/context/mixins/MethodDataContextMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import CryptoJS from "crypto-js";

export function methodDataContextMixin(item) {
const properties = {
_methodData: undefined,

isEdited: false,

methodDataHash: undefined,

extraData: undefined,

initMethodDataContextMixin() {
this._methodData = (this.config.context && this.config.context.methodData) || {};
this.isEdited = Boolean(this.config.isEdited);
},

/* @summary Replace the logic in constructor with this in order to enable passing `methodDataHash` between
* subsequent initializations of the derived class. Not used at present and kept for the record.
*/
_initMethodDataHash() {
this.methodDataHash = CryptoJS.MD5(JSON.stringify(this.methodData)).toString();
this.extraData = { methodDataHash: this.methodDataHash };
if (!this._methodData) {
this._methodData = {};
this.isEdited = false;
// Commented out to reduce effect on performance. Uncomment for debugging purposes.
// TODO: remove on next refactoring or convert to log
// console.warn("MethodDataContextMixin: methodData is undefined or null");
} else if (this.isMethodDataUpdated) {
this.isEdited = false;
} else {
// eslint-disable-next-line no-undef
this.isEdited = config.isEdited;
}
},

get methodData() {
return this._methodData;
},

get isMethodDataUpdated() {
return Boolean(this.extraData && this.extraData.methodDataHash !== this.methodDataHash);
},
};

Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
}
25 changes: 25 additions & 0 deletions src/context/mixins/WorkflowContextMixin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const defaultWorkflow = {
subworkflows: [],
units: [],
hasRelaxation: false,
};

export function workflowContextMixin(item) {
const properties = {
isEdited: false,

_workflow: defaultWorkflow,

get workflow() {
return this._workflow;
},

initWorkflowContextMixin() {
const { config } = this; // as WorkflowConfig;
this._workflow = (config.context && config.context.workflow) || defaultWorkflow;
this.isEdited = false; // we always get the `defaultData` (recalculated from scratch, not persistent)
},
};

Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
}
25 changes: 25 additions & 0 deletions src/context/providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ const {
IonDynamicsContextProvider,
CollinearMagnetizationContextProvider,
NonCollinearMagnetizationContextProvider,
VASPContextProvider,
VASPNEBContextProvider,
QEPWXContextProvider,
QENEBContextProvider,
NWChemTotalEnergyContextProvider,
} = context;

const CONTEXT_DOMAINS = {
Expand Down Expand Up @@ -112,4 +117,24 @@ export const wodeProviders = {
providerCls: NonCollinearMagnetizationContextProvider,
config: _makeImportant({ name: "nonCollinearMagnetization" }),
},
QEPWXInputDataManager: {
providerCls: QEPWXContextProvider,
config: { name: "input" },
},
QENEBInputDataManager: {
providerCls: QENEBContextProvider,
config: { name: "input" },
},
VASPInputDataManager: {
providerCls: VASPContextProvider,
config: { name: "input" },
},
VASPNEBInputDataManager: {
providerCls: VASPNEBContextProvider,
config: { name: "input" },
},
NWChemInputDataManager: {
providerCls: NWChemTotalEnergyContextProvider,
config: { name: "input" },
},
};
16 changes: 10 additions & 6 deletions src/context/providers/BoundaryConditionsFormDataProvider.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { JSONSchemaFormDataProvider, MaterialContextMixin } from "@mat3ra/code/dist/js/context";
import JSONSchemaFormDataProvider from "@exabyte-io/ade.js/dist/js/context/JSONSchemaFormDataProvider";
import { deepClone } from "@mat3ra/code/dist/js/utils";
import { Made } from "@mat3ra/made";
import { mix } from "mixwith";

export class BoundaryConditionsFormDataProvider extends mix(JSONSchemaFormDataProvider).with(
MaterialContextMixin,
) {
static Material = Made.Material;
import { materialContextMixin } from "../mixins/MaterialContextMixin";

export class BoundaryConditionsFormDataProvider extends JSONSchemaFormDataProvider {
constructor(config) {
super(config);
this.initMaterialContextMixin();
}

get boundaryConditions() {
return this.material.metadata.boundaryConditions || {};
Expand Down Expand Up @@ -74,3 +76,5 @@ export class BoundaryConditionsFormDataProvider extends mix(JSONSchemaFormDataPr
};
}
}

materialContextMixin(BoundaryConditionsFormDataProvider.prototype);
15 changes: 8 additions & 7 deletions src/context/providers/CollinearMagnetizationContextProvider.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { JSONSchemaFormDataProvider, MaterialContextMixin } from "@mat3ra/code/dist/js/context";
import { Made } from "@mat3ra/made";
import JSONSchemaFormDataProvider from "@exabyte-io/ade.js/dist/js/context/JSONSchemaFormDataProvider";
import lodash from "lodash";
import { mix } from "mixwith";

export class CollinearMagnetizationContextProvider extends mix(JSONSchemaFormDataProvider).with(
MaterialContextMixin,
) {
static Material = Made.Material;
import { materialContextMixin } from "../mixins/MaterialContextMixin";

export class CollinearMagnetizationContextProvider extends JSONSchemaFormDataProvider {
constructor(config) {
super(config);

this.initMaterialContextMixin();

this.firstElement =
this.uniqueElementsWithLabels?.length > 0 ? this.uniqueElementsWithLabels[0] : "";
this.isTotalMagnetization = lodash.get(this.data, "isTotalMagnetization", false);
Expand Down Expand Up @@ -114,3 +113,5 @@ export class CollinearMagnetizationContextProvider extends mix(JSONSchemaFormDat
};
}
}

materialContextMixin(CollinearMagnetizationContextProvider.prototype);
Loading