Skip to content

Commit

Permalink
Merge branch 'main' into epic/SOF-4861
Browse files Browse the repository at this point in the history
  • Loading branch information
azech-hqs committed May 8, 2023
2 parents 497dc3f + 69c3249 commit 7905ea9
Show file tree
Hide file tree
Showing 19 changed files with 325 additions and 219 deletions.
58 changes: 1 addition & 57 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,60 +1,4 @@
{
"extends": ["airbnb", "prettier", "eslint:recommended"],
"settings": {
"import/resolver": {
"node": {
"paths": ["src"]
},
"exports": {}
}
},
"parser": "@babel/eslint-parser",
"env": {
"browser": true,
"node": true,
"mocha": true
},
"plugins": ["prettier", "simple-import-sort", "jsdoc"],
"rules": {
"prettier/prettier": "error",
"comma-dangle": ["error", "always-multiline"],
"array-element-newline": ["error", "consistent"],
"no-plusplus": ["error", { "allowForLoopAfterthoughts": true }],
"one-var": ["error", { "uninitialized": "always", "initialized": "never" }],
"brace-style": ["error", "1tbs", { "allowSingleLine": true }],
"prefer-template": "off",
"camelcase": "off",
"max-len": "off",
"no-console": "off",
"no-unused-expressions": "warn",
"no-confusing-arrow": "off",
"no-underscore-dangle": "off",
"no-return-assign": "off",
"consistent-return": "off",
"arrow-body-style": "off",
"import/prefer-default-export": "off",
"import/no-named-as-default-member": "warn",
"no-param-reassign": ["warn", { "props": false }],
"max-classes-per-file": "warn",
"simple-import-sort/imports": [
"warn",
{
"groups": [
// Side effect imports.
["^\\u0000"],
// Packages.
// Things that start with a letter (or digit or underscore), or `@` followed by a letter.
["^@?\\w"],
// Absolute imports
[
"^(components|configs|constants|containers|domain|enhancers|hocs|libs|pages|reducers|services|store|modules|dictionaries)(/.*|$)"
],
// Relative imports.
// Anything that starts with a dot.
["^\\."]
]
}
]
}
"extends": ["@exabyte-io/eslint-config"]
}

248 changes: 191 additions & 57 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 11 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,24 +36,25 @@
"@babel/preset-react": "7.16.7",
"@babel/register": "^7.16.0",
"@babel/runtime-corejs3": "7.16.8",
"@exabyte-io/ade.js": "2022.7.27-0",
"@exabyte-io/code.js": "2022.8.30-0",
"@exabyte-io/made.js": "2022.6.15-0",
"lodash": "^4.17.21",
"mixwith": "^0.1.1",
"underscore": "^1.13.3",
"underscore.string": "^3.3.4"
},
"devDependencies": {
"@exabyte-io/ade.js": "2022.8.31-0",
"@exabyte-io/code.js": "2022.10.11-0",
"@exabyte-io/eslint-config": "^2022.11.17-0",
"@exabyte-io/made.js": "2022.6.15-0",
"chai": "^4.3.4",
"eslint": "7.32.0",
"eslint-config-airbnb": "19.0.2",
"eslint-config-prettier": "8.3.0",
"eslint-config-prettier": "^8.5.0",
"eslint-import-resolver-exports": "^1.0.0-beta.2",
"eslint-plugin-import": "2.25.3",
"eslint-plugin-jsdoc": "37.1.0",
"eslint-plugin-jsx-a11y": "6.5.1",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "7.30.0",
"eslint-plugin-simple-import-sort": "7.0.0",
"husky": "^7.0.4",
Expand All @@ -62,6 +63,11 @@
"nyc": "^15.1.0",
"prettier": "^2.7.1"
},
"peerDependencies": {
"@exabyte-io/ade.js": "*",
"@exabyte-io/code.js": "*",
"@exabyte-io/made.js": "*"
},
"engines": {
"node": ">=12.0.0"
},
Expand Down
6 changes: 3 additions & 3 deletions src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { NEBFormDataProvider } from "./context/providers/NEBFormDataProvider";
import { PlanewaveCutoffsContextProvider } from "./context/providers/PlanewaveCutoffsContextProvider";
import { PointsGridFormDataProvider } from "./context/providers/PointsGridFormDataProvider";
import {
PointsPathFormDataProvider,
ExplicitPointsPath2PIBAFormDataProvider,
ExplicitPointsPathFormDataProvider,
ExplicitPointsPath2PIBAFormDataProvider
PointsPathFormDataProvider,
} from "./context/providers/PointsPathFormDataProvider";

export {
Expand All @@ -20,4 +20,4 @@ export {
PointsPathFormDataProvider,
ExplicitPointsPathFormDataProvider,
ExplicitPointsPath2PIBAFormDataProvider,
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { mix } from "mixwith";
export class BoundaryConditionsFormDataProvider extends mix(JSONSchemaFormDataProvider).with(
MaterialContextMixin,
) {
static materialCls = Made.Material;
static Material = Made.Material;

get boundaryConditions() {
return this.material.metadata.boundaryConditions || {};
Expand Down
2 changes: 1 addition & 1 deletion src/context/providers/MLSettingsContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { ApplicationContextMixin, ContextProvider } from "@exabyte-io/code.js/di
import { mix } from "mixwith";

export class MLSettingsContextProvider extends mix(ContextProvider).with(ApplicationContextMixin) {
static applicationCls = Application;
static Application = Application;

// eslint-disable-next-line class-methods-use-this
get uiSchema() {
Expand Down
2 changes: 1 addition & 1 deletion src/context/providers/MLTrainTestSplitContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { mix } from "mixwith";
export class MLTrainTestSplitContextProvider extends mix(ContextProvider).with(
ApplicationContextMixin,
) {
static applicationCls = Application;
static Application = Application;

// eslint-disable-next-line class-methods-use-this
get uiSchema() {
Expand Down
2 changes: 1 addition & 1 deletion src/context/providers/PlanewaveCutoffsContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const cutoffConfig = {
export class PlanewaveCutoffsContextProvider extends mix(ContextProvider).with(
ApplicationContextMixin,
) {
static applicationCls = Application;
static Application = Application;

// eslint-disable-next-line class-methods-use-this
get uiSchema() {
Expand Down
14 changes: 12 additions & 2 deletions src/context/providers/PointsGridFormDataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { mix } from "mixwith";
export class PointsGridFormDataProvider extends mix(JSONSchemaFormDataProvider).with(
MaterialContextMixin,
) {
static materialCls = Made.Material;
static Material = Made.Material;

constructor(config) {
super(config);
Expand Down Expand Up @@ -59,7 +59,7 @@ export class PointsGridFormDataProvider extends mix(JSONSchemaFormDataProvider).
return {
...vector,
items: {
type: "number",
type: this.isUsingJinjaVariables ? "string" : "number",
default: defaultValue,
},
};
Expand Down Expand Up @@ -154,7 +154,17 @@ export class PointsGridFormDataProvider extends mix(JSONSchemaFormDataProvider).
return grid.dimensions.reduce((a, b) => a * b) * nAtoms;
}

static _canTransform(data) {
return (
(data.preferKPPRA && data.KPPRA) ||
(!data.preferKPPRA && data.dimensions.every((d) => typeof d === "number"))
);
}

transformData(data) {
if (!PointsGridFormDataProvider._canTransform(data)) {
return data;
}
// 1. check if KPPRA is preferred
if (data.preferKPPRA) {
// 2. KPPRA is preferred => recalculate grid; NOTE: `data.KPPRA` is undefined at first
Expand Down
11 changes: 7 additions & 4 deletions src/context/providers/PointsPathFormDataProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ export class PointsPathFormDataProvider extends mix(JSONSchemaFormDataProvider).
ApplicationContextMixin,
MaterialContextMixin,
) {
static materialCls = Made.Material;
static Material = Made.Material;

static applicationCls = Application;
static Application = Application;

constructor(config) {
super(config);
Expand Down Expand Up @@ -92,8 +92,11 @@ export class PointsPathFormDataProvider extends mix(JSONSchemaFormDataProvider).
}
return {
// eslint-disable-next-line no-unused-vars
TitleField: ({ title, required }) =>
this.material.getBrillouinZoneImageComponent(title),
TitleField: ({
title,
// eslint-disable-next-line no-unused-vars
required,
}) => this.material.getBrillouinZoneImageComponent(title),
};
}

Expand Down
34 changes: 18 additions & 16 deletions src/default_methods.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,38 @@
import lodash from "lodash";

import {MODEL_TREE, MODEL_NAMES} from "./tree";
import { MODEL_NAMES, MODEL_TREE } from "./tree";

export const PseudopotentialMethodConfig = {
type: 'pseudopotential',
subtype: 'us',
type: "pseudopotential",
subtype: "us",
};

export const LocalOrbitalMethodConfig = {
type: 'localorbital',
subtype: 'pople',
type: "localorbital",
subtype: "pople",
};

export const UnknownMethodConfig = {
type: 'unknown',
subtype: 'unknown'
type: "unknown",
subtype: "unknown",
};

export function allowedTypes(model) {
return lodash.keys(lodash.get(MODEL_TREE, `${model.type}.${model.subtype}.methods`, [])).map(x => {
return {
slug: x,
name: lodash.get(MODEL_NAMES, x, x)
}
});
return lodash
.keys(lodash.get(MODEL_TREE, `${model.type}.${model.subtype}.methods`, []))
.map((x) => {
return {
slug: x,
name: lodash.get(MODEL_NAMES, x, x),
};
});
}

export function allowedSubtypes(model, type) {
return lodash.get(MODEL_TREE, `${model.type}.${model.subtype}.methods.${type}`, []).map(x => {
return lodash.get(MODEL_TREE, `${model.type}.${model.subtype}.methods.${type}`, []).map((x) => {
return {
slug: x,
name: lodash.get(MODEL_NAMES, x, x)
}
name: lodash.get(MODEL_NAMES, x, x),
};
});
}
8 changes: 4 additions & 4 deletions src/default_models.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export const DFTModelConfig = {
type: 'dft',
subtype: 'gga',
type: "dft",
subtype: "gga",
};

export const UnknownModelConfig = {
type: 'unknown',
subtype: 'unknown',
type: "unknown",
subtype: "unknown",
};
14 changes: 5 additions & 9 deletions src/method.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import lodash from "lodash";

import { InMemoryEntity } from "@exabyte-io/code.js/dist/entity";
import { InMemoryEntity } from "@exabyte-io/code.js/dist/entity";
import { deepClone } from "@exabyte-io/code.js/dist/utils";
import lodash from "lodash";

import { PseudopotentialMethodConfig } from "./default_methods";

Expand Down Expand Up @@ -50,7 +49,6 @@ export class Method extends InMemoryEntity {
// utilizing "data" field as a "blackbox" container for searchText
setSearchText(searchText) {
this.setData({ ...this.prop("data"), searchText });

}

setData(data = {}) {
Expand All @@ -64,18 +62,16 @@ export class Method extends InMemoryEntity {

// data without client-only fields
cleanData(fieldsToExclude = []) {
const filteredData = Object.assign({}, this.prop("data"));
fieldsToExclude.forEach(f => {
const filteredData = { ...this.prop("data") };
fieldsToExclude.forEach((f) => {
delete filteredData[f];
});
return filteredData;
}

// override in child class if needed
toJSONWithCleanData(fieldsToExclude = []) {
const json = Object.assign({}, this._json, {data: this.cleanData(fieldsToExclude)});
const json = { ...this._json, data: this.cleanData(fieldsToExclude) };
return deepClone(json);
}


}
8 changes: 5 additions & 3 deletions src/methods/factory.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import {Method} from "../method";
import {PseudopotentialMethod} from "./pseudopotential";
import { Method } from "../method";
import { PseudopotentialMethod } from "./pseudopotential";

export class MethodFactory {
static Method = Method;

static PseudopotentialMethod = PseudopotentialMethod;

static create(config) {
switch (config.type) {
case 'pseudopotential':
case "pseudopotential":
return new this.PseudopotentialMethod(config);
default:
return new this.Method(config);
Expand Down
1 change: 1 addition & 0 deletions src/methods/pseudopotential.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class PseudopotentialMethod extends Method {

// add new pseudopotentials to the list of all pseudopotentials
addToAllPseudos(pseudos) {
// eslint-disable-next-line no-param-reassign
pseudos = safeMakeArray(pseudos);
const allPseudos = this.allPseudopotentials;
allPseudos.push(...pseudos);
Expand Down
Loading

0 comments on commit 7905ea9

Please sign in to comment.