Skip to content

Commit fa83d7e

Browse files
authored
Merge pull request #20 from Exabyte-io/feat/SOF-6398-1
SOF-6398-1: reformat eslint issues
2 parents c501e01 + e50b401 commit fa83d7e

32 files changed

+319
-313
lines changed

package.json

+1-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"lint:fix": "eslint --fix --cache src tests",
99
"transpile": "babel --out-dir dist src; node build_workflows.js",
1010
"postinstall": "npm run transpile",
11-
"prettier": "prettier --check src tests",
1211
"prepare": "husky install || exit 0"
1312
},
1413
"repository": {
@@ -76,7 +75,6 @@
7675
"node": ">=12.0.0"
7776
},
7877
"lint-staged": {
79-
"*.js": "eslint --cache --fix",
80-
"*.{js,css}": "prettier --write"
78+
"*.js": "eslint --cache --fix"
8179
}
8280
}

src/enums.js

+18-18
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,31 @@ export const IO_ID_COLUMN = "exabyteId";
77

88
export const UNIT_TYPES = {
99
// not currently used
10-
convergence: 'convergence',
11-
exit: 'exit',
10+
convergence: "convergence",
11+
exit: "exit",
1212
// actively used
13-
execution: 'execution',
14-
map: 'map',
15-
reduce: 'reduce',
16-
assignment: 'assignment',
17-
condition: 'condition',
18-
subworkflow: 'subworkflow',
19-
processing: 'processing',
20-
io: 'io',
21-
assertion: 'assertion',
13+
execution: "execution",
14+
map: "map",
15+
reduce: "reduce",
16+
assignment: "assignment",
17+
condition: "condition",
18+
subworkflow: "subworkflow",
19+
processing: "processing",
20+
io: "io",
21+
assertion: "assertion",
2222
};
2323

2424
export const UNIT_STATUSES = {
25-
idle: 'idle',
26-
active: 'active',
27-
finished: 'finished',
28-
error: 'error',
29-
warning: 'warning'
25+
idle: "idle",
26+
active: "active",
27+
finished: "finished",
28+
error: "error",
29+
warning: "warning",
3030
};
3131

3232
export const WORKFLOW_STATUSES = {
3333
"up-to-date": "up-to-date",
34-
"outdated": "outdated",
34+
outdated: "outdated",
3535
};
3636

3737
export const TAB_NAVIGATION_CONFIG = {
@@ -57,4 +57,4 @@ export const TAB_NAVIGATION_CONFIG = {
5757
},
5858
};
5959

60-
export const UNIT_NAME_INVALID_CHARS = '/';
60+
export const UNIT_NAME_INVALID_CHARS = "/";

src/subworkflows/convergence.js

+106-109
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,122 @@
11
import { UNIT_TYPES } from "../enums";
22

3-
export const ConvergenceMixin = (superclass) =>
4-
class extends superclass {
5-
addConvergence({
6-
parameter,
7-
parameterInitial,
8-
result,
9-
resultInitial,
10-
condition,
11-
operator,
12-
tolerance,
13-
maxOccurrences,
14-
}) {
15-
// RF: added TODO comments for future improvements
3+
export const ConvergenceMixin = (superclass) => class extends superclass {
4+
addConvergence({
5+
parameter,
6+
parameterInitial,
7+
result,
8+
resultInitial,
9+
condition,
10+
operator,
11+
tolerance,
12+
maxOccurrences,
13+
}) {
14+
// RF: added TODO comments for future improvements
1615

17-
const { units } = this;
18-
// Find unit to converge: should contain passed result in its results list
19-
// TODO: make user to select unit for convergence explicitly
20-
const unitForConvergence = units.find((x) =>
21-
x.resultNames.find((name) => name === result),
22-
);
16+
const { units } = this;
17+
// Find unit to converge: should contain passed result in its results list
18+
// TODO: make user to select unit for convergence explicitly
19+
const unitForConvergence = units.find((x) => x.resultNames.find((name) => name === result));
2320

24-
if (!unitForConvergence) {
25-
// eslint-disable-next-line no-undef
26-
sAlert.error(
21+
if (!unitForConvergence) {
22+
// eslint-disable-next-line no-undef
23+
sAlert.error(
2724
`Subworkflow does not contain unit with '${result}' as extracted property.`,
28-
);
29-
throw new Error("There is no result to converge");
30-
}
25+
);
26+
throw new Error("There is no result to converge");
27+
}
3128

32-
// Replace kgrid to be ready for convergence
33-
// TODO: kgrid should be abstracted and selected by user
34-
unitForConvergence.updateContext({
35-
kgrid: {
36-
dimensions: [`{{${parameter}}}`, `{{${parameter}}}`, `{{${parameter}}}`],
37-
shifts: [0, 0, 0],
38-
},
39-
isKgridEdited: true,
40-
isUsingJinjaVariables: true,
41-
});
29+
// Replace kgrid to be ready for convergence
30+
// TODO: kgrid should be abstracted and selected by user
31+
unitForConvergence.updateContext({
32+
kgrid: {
33+
dimensions: [`{{${parameter}}}`, `{{${parameter}}}`, `{{${parameter}}}`],
34+
shifts: [0, 0, 0],
35+
},
36+
isKgridEdited: true,
37+
isUsingJinjaVariables: true,
38+
});
4239

43-
const prevResult = "prev_result";
40+
const prevResult = "prev_result";
4441

45-
// Assignment with result's initial value
46-
const prevResultInit = this._UnitFactory.create({
47-
type: UNIT_TYPES.assignment,
48-
head: true,
49-
operand: prevResult,
50-
value: resultInitial,
51-
});
42+
// Assignment with result's initial value
43+
const prevResultInit = this._UnitFactory.create({
44+
type: UNIT_TYPES.assignment,
45+
head: true,
46+
operand: prevResult,
47+
value: resultInitial,
48+
});
5249

53-
// Assignment with initial value of convergence parameter
54-
const paramInit = this._UnitFactory.create({
55-
type: UNIT_TYPES.assignment,
56-
operand: parameter,
57-
value: parameterInitial,
58-
});
50+
// Assignment with initial value of convergence parameter
51+
const paramInit = this._UnitFactory.create({
52+
type: UNIT_TYPES.assignment,
53+
operand: parameter,
54+
value: parameterInitial,
55+
});
5956

60-
// Assignment for storing iteration result: extracts 'result' from convergence unit scope
61-
const storePrevResult = this._UnitFactory.create({
62-
type: UNIT_TYPES.assignment,
63-
input: [
64-
{
65-
scope: unitForConvergence.flowchartId,
66-
name: result,
67-
},
68-
],
69-
operand: prevResult,
70-
value: result,
71-
});
57+
// Assignment for storing iteration result: extracts 'result' from convergence unit scope
58+
const storePrevResult = this._UnitFactory.create({
59+
type: UNIT_TYPES.assignment,
60+
input: [
61+
{
62+
scope: unitForConvergence.flowchartId,
63+
name: result,
64+
},
65+
],
66+
operand: prevResult,
67+
value: result,
68+
});
7269

73-
// Assignment for convergence param increase
74-
const nextStep = this._UnitFactory.create({
75-
type: UNIT_TYPES.assignment,
76-
input: [],
77-
operand: parameter,
78-
value: `${parameter} + 1`,
79-
next: unitForConvergence.flowchartId,
80-
});
70+
// Assignment for convergence param increase
71+
const nextStep = this._UnitFactory.create({
72+
type: UNIT_TYPES.assignment,
73+
input: [],
74+
operand: parameter,
75+
value: `${parameter} + 1`,
76+
next: unitForConvergence.flowchartId,
77+
});
8178

82-
// Final step of convergence
83-
const exit = this._UnitFactory.create({
84-
type: UNIT_TYPES.assignment,
85-
name: "exit",
86-
input: [],
87-
operand: parameter,
88-
value: `${parameter} + 0`,
89-
});
79+
// Final step of convergence
80+
const exit = this._UnitFactory.create({
81+
type: UNIT_TYPES.assignment,
82+
name: "exit",
83+
input: [],
84+
operand: parameter,
85+
value: `${parameter} + 0`,
86+
});
9087

91-
// Final step of convergence
92-
const storeResult = this._UnitFactory.create({
93-
type: UNIT_TYPES.assignment,
94-
input: [
95-
{
96-
scope: unitForConvergence.flowchartId,
97-
name: result,
98-
},
99-
],
100-
operand: result,
101-
value: result,
102-
});
88+
// Final step of convergence
89+
const storeResult = this._UnitFactory.create({
90+
type: UNIT_TYPES.assignment,
91+
input: [
92+
{
93+
scope: unitForConvergence.flowchartId,
94+
name: result,
95+
},
96+
],
97+
operand: result,
98+
value: result,
99+
});
103100

104-
// Convergence condition unit
105-
const conditionUnit = this._UnitFactory.create({
106-
type: UNIT_TYPES.condition,
107-
statement: `${condition} ${operator} ${tolerance}`,
108-
then: exit.flowchartId,
109-
else: storePrevResult.flowchartId,
110-
maxOccurrences,
111-
next: storePrevResult.flowchartId,
112-
});
101+
// Convergence condition unit
102+
const conditionUnit = this._UnitFactory.create({
103+
type: UNIT_TYPES.condition,
104+
statement: `${condition} ${operator} ${tolerance}`,
105+
then: exit.flowchartId,
106+
else: storePrevResult.flowchartId,
107+
maxOccurrences,
108+
next: storePrevResult.flowchartId,
109+
});
113110

114-
this.addUnit(prevResultInit, true);
115-
this.addUnit(paramInit, true);
116-
this.addUnit(storeResult);
117-
this.addUnit(conditionUnit);
118-
this.addUnit(storePrevResult);
119-
this.addUnit(nextStep);
120-
this.addUnit(exit);
111+
this.addUnit(prevResultInit, true);
112+
this.addUnit(paramInit, true);
113+
this.addUnit(storeResult);
114+
this.addUnit(conditionUnit);
115+
this.addUnit(storePrevResult);
116+
this.addUnit(nextStep);
117+
this.addUnit(exit);
121118

122-
// `addUnit` adjusts the `next` field, hence the below.
123-
nextStep.next = unitForConvergence.flowchartId;
124-
}
125-
};
119+
// `addUnit` adjusts the `next` field, hence the below.
120+
nextStep.next = unitForConvergence.flowchartId;
121+
}
122+
};

src/subworkflows/create.js

+18-6
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,16 @@ function createMethod({ config, methodFactoryCls }) {
6868
* @param methodFactoryCls {any} method factory class
6969
* @returns {{application: *, method: *, model: (DFTModel|Model), setSearchText: String|null}}
7070
*/
71-
function createTopLevel({ subworkflowData, applicationCls, modelFactoryCls, methodFactoryCls }) {
71+
function createTopLevel({
72+
subworkflowData, applicationCls, modelFactoryCls, methodFactoryCls,
73+
}) {
7274
const { application: appConfig, model: modelConfig, method: methodConfig } = subworkflowData;
7375
const application = createApplication({ config: appConfig, applicationCls });
7476
const model = createModel({ config: modelConfig, modelFactoryCls });
7577
const { method, setSearchText } = createMethod({ config: methodConfig, methodFactoryCls });
76-
return { application, model, method, setSearchText };
78+
return {
79+
application, model, method, setSearchText,
80+
};
7781
}
7882

7983
/**
@@ -86,10 +90,14 @@ function createTopLevel({ subworkflowData, applicationCls, modelFactoryCls, meth
8690
* @param unitFactoryCls {*} workflow unit class factory
8791
* @returns {*|{head: boolean, preProcessors: [], postProcessors: [], name: *, flowchartId: *, type: *, results: [], monitors: []}}
8892
*/
89-
function createUnit({ config, application, unitBuilders, unitFactoryCls }) {
93+
function createUnit({
94+
config, application, unitBuilders, unitFactoryCls,
95+
}) {
9096
const { type, config: unitConfig } = config;
9197
if (type === "executionBuilder") {
92-
const { name, execName, flavorName, flowchartId } = unitConfig;
98+
const {
99+
name, execName, flavorName, flowchartId,
100+
} = unitConfig;
93101
const builder = new unitBuilders.ExecutionUnitConfigBuilder(
94102
name,
95103
application,
@@ -145,15 +153,19 @@ function createSubworkflow({
145153
unitFactoryCls = UnitFactory,
146154
unitBuilders = builders,
147155
}) {
148-
const { application, model, method, setSearchText } = createTopLevel({
156+
const {
157+
application, model, method, setSearchText,
158+
} = createTopLevel({
149159
subworkflowData,
150160
applicationCls,
151161
modelFactoryCls,
152162
methodFactoryCls,
153163
});
154164

155165
let units = [];
156-
const { name, units: unitConfigs, config = {}, dynamicSubworkflow = null } = subworkflowData;
166+
const {
167+
name, units: unitConfigs, config = {}, dynamicSubworkflow = null,
168+
} = subworkflowData;
157169
unitConfigs.forEach((_config) => {
158170
units.push(
159171
createUnit({

src/subworkflows/dynamic/espresso/getQpointIrrep.js

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,27 @@ import { UNIT_TYPES } from "../../../enums";
77
* @param application {*} application instance
88
* @returns {[{head: boolean, preProcessors: [], postProcessors: [], name: *, flowchartId: *, type: *, results: [], monitors: []},*]}
99
*/
10-
const getQpointIrrep = function ({ unitBuilders, unitFactoryCls, application }) {
11-
10+
function getQpointIrrep({ unitBuilders, unitFactoryCls, application }) {
1211
const { ExecutionUnitConfigBuilder } = unitBuilders;
1312

14-
const pythonUnit = new ExecutionUnitConfigBuilder(
15-
"python", application, "python", "espresso_xml_get_qpt_irr",
16-
).build();
13+
const pythonUnit = new ExecutionUnitConfigBuilder("python", application, "python", "espresso_xml_get_qpt_irr").build();
1714

1815
const assignmentUnit = unitFactoryCls.create({
1916
type: UNIT_TYPES.assignment,
2017
input: [
2118
{
2219
scope: pythonUnit.flowchartId,
23-
name: "STDOUT"
24-
}
20+
name: "STDOUT",
21+
},
2522
],
2623
operand: "Q_POINTS",
27-
value: "json.loads(STDOUT)"
24+
value: "json.loads(STDOUT)",
2825
});
2926

3027
return [
3128
pythonUnit,
3229
assignmentUnit,
3330
];
34-
3531
}
3632

3733
export { getQpointIrrep };

0 commit comments

Comments
 (0)