Skip to content

Commit 73f4696

Browse files
author
minjk-bl
committed
Fix pipeline for lab and lite
1 parent 35c7b81 commit 73f4696

File tree

1 file changed

+74
-4
lines changed

1 file changed

+74
-4
lines changed

visualpython/js/m_ml/Pipeline.js

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,22 @@ define([
134134
}
135135

136136
// menu libraries for ml
137-
let libObj = JSON.parse(librariesJson);
137+
let libObj = {};
138+
if (vpConfig.extensionType === 'lab' || vpConfig.extensionType === 'lite') {
139+
libObj = librariesJson;
140+
141+
this.MlAppComponent = {};
142+
this.MlAppComponent['ml_dataSplit'] = require('./dataSplit');
143+
this.MlAppComponent['ml_dataPrep'] = require('./DataPrep');
144+
this.MlAppComponent['ml_regression'] = require('./Regression');
145+
this.MlAppComponent['ml_classification'] = require('./Classification');
146+
this.MlAppComponent['ml_clustering'] = require('./Clustering');
147+
this.MlAppComponent['ml_dimensionReduction'] = require('./DimensionReduction');
148+
this.MlAppComponent['ml_gridSearch'] = require('./GridSearch');
149+
this.MlAppComponent['ml_evaluation'] = require('./evaluation');
150+
} else {
151+
libObj = JSON.parse(librariesJson);
152+
}
138153
this.mlAppList = libObj.library.item.filter(x => x.id === 'pkg_ml')[0].item;
139154

140155
this.modelConfig = ML_LIBRARIES;
@@ -280,7 +295,7 @@ define([
280295
if (useApp === true) {
281296
let mlObj = that.mlAppList.filter(x => x.id === name)[0];
282297
if (vpConfig.extensionType === 'lab' || vpConfig.extensionType === 'lite') {
283-
appFileList.push({ index: idx, name: name, file: './' + mlObj.file});
298+
appFileList.push({ index: idx, name: name, file: 'vp_base/js/' + mlObj.file});
284299
} else {
285300
appFileList.push({ index: idx, name: name, file: 'vp_base/js/' + mlObj.file});
286301
}
@@ -311,14 +326,15 @@ define([
311326
// for lite and lab
312327
if (vpConfig.extensionType === 'lab' || vpConfig.extensionType === 'lite') {
313328
appFileList.forEach((obj, argIdx) => {
314-
let MlComponent = require(obj.file);
329+
let MlComponent = that.MlAppComponent[obj.name];
315330
if (MlComponent) {
316331
// DUP AREA: pp-1
317332
let { name, label, index, file } = obj;
318333
let mlComponent = new MlComponent({
319334
config: { id: name, name: label, path: file, category: 'Pipeline', resizable: false },
320335
...that.state.pipeline[index].state
321336
});
337+
mlComponent.loadState();
322338
// mlComponent.open($(that.wrapSelector(`.vp-pp-step-page[data-name="${appId}"]`)));
323339
that.state.pipeline[index].app = mlComponent;
324340

@@ -350,6 +366,7 @@ define([
350366
config: { id: name, name: label, path: file, category: 'Pipeline', resizable: false },
351367
...that.state.pipeline[index].state
352368
});
369+
mlComponent.loadState();
353370
// mlComponent.open($(that.wrapSelector(`.vp-pp-step-page[data-name="${appId}"]`)));
354371
that.state.pipeline[index].app = mlComponent;
355372

@@ -466,6 +483,59 @@ define([
466483
return optBox.toString();
467484
}
468485

486+
checkBeforeRun() {
487+
let that = this;
488+
var result = true;
489+
for (let idx = 0; idx < this.state.pipeline.length; idx++) {
490+
let ppObj = this.state.pipeline[idx];
491+
var { name, label, useApp, app } = ppObj;
492+
let requiredList = [];
493+
result = true;
494+
let isVisible = $(that.wrapSelector(`.vp-pp-item[data-seq="${idx}"]`)).is(':visible') === true;
495+
let isEnabled = $(that.wrapSelector(`.vp-pp-item[data-seq="${idx}"]`)).attr('data-flag') === 'enabled';
496+
if (isVisible && isEnabled) {
497+
switch (name) {
498+
case 'ml_dataSplit':
499+
requiredList = ['featureData', 'targetData'];
500+
// check required data
501+
for (let i = 0; i < requiredList.length; i++) {
502+
let reqKey = requiredList[i];
503+
result = that._checkIsEmpty($(app.wrapSelector('#' + reqKey)));
504+
if (result === false) {
505+
// show page and focus it
506+
$(that.wrapSelector(`.vp-pp-item[data-name="${name}"]`)).click();
507+
$(app.wrapSelector('#' + reqKey)).focus();
508+
break;
509+
}
510+
}
511+
break;
512+
case 'ml_gridSearch':
513+
result = app.checkBeforeRun();
514+
if (result === false) {
515+
// show page
516+
$(that.wrapSelector(`.vp-pp-item[data-name="${name}"]`)).click();
517+
break;
518+
}
519+
break;
520+
}
521+
}
522+
if (result === false) {
523+
break;
524+
}
525+
}
526+
return result;
527+
528+
}
529+
530+
_checkIsEmpty(tag) {
531+
let requiredFilled = true;
532+
// if it's empty, focus on it
533+
if (tag && $(tag) && $(tag).val() == '') {
534+
requiredFilled = false;
535+
}
536+
return requiredFilled;
537+
}
538+
469539
generateCodeForOptionPage(appId) {
470540
let actions = this.modelEditor.getAction(this.state.modelTypeName);
471541
let actObj = {};
@@ -514,7 +584,7 @@ define([
514584

515585
// check disabled
516586
let isVisible = $(that.wrapSelector(`.vp-pp-item[data-seq="${idx}"]`)).is(':visible') === true;
517-
let isEnabled = $(that.wrapSelector(`.vp-pp-item[data-seq="${idx}"]`)).data('flag') === 'enabled';
587+
let isEnabled = $(that.wrapSelector(`.vp-pp-item[data-seq="${idx}"]`)).attr('data-flag') === 'enabled';
518588
if (isVisible && isEnabled) {
519589
if (code.toString() !== '') {
520590
code.appendLine();

0 commit comments

Comments
 (0)