@@ -134,7 +134,22 @@ define([
134
134
}
135
135
136
136
// 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
+ }
138
153
this . mlAppList = libObj . library . item . filter ( x => x . id === 'pkg_ml' ) [ 0 ] . item ;
139
154
140
155
this . modelConfig = ML_LIBRARIES ;
@@ -280,7 +295,7 @@ define([
280
295
if ( useApp === true ) {
281
296
let mlObj = that . mlAppList . filter ( x => x . id === name ) [ 0 ] ;
282
297
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 } ) ;
284
299
} else {
285
300
appFileList . push ( { index : idx , name : name , file : 'vp_base/js/' + mlObj . file } ) ;
286
301
}
@@ -311,14 +326,15 @@ define([
311
326
// for lite and lab
312
327
if ( vpConfig . extensionType === 'lab' || vpConfig . extensionType === 'lite' ) {
313
328
appFileList . forEach ( ( obj , argIdx ) => {
314
- let MlComponent = require ( obj . file ) ;
329
+ let MlComponent = that . MlAppComponent [ obj . name ] ;
315
330
if ( MlComponent ) {
316
331
// DUP AREA: pp-1
317
332
let { name, label, index, file } = obj ;
318
333
let mlComponent = new MlComponent ( {
319
334
config : { id : name , name : label , path : file , category : 'Pipeline' , resizable : false } ,
320
335
...that . state . pipeline [ index ] . state
321
336
} ) ;
337
+ mlComponent . loadState ( ) ;
322
338
// mlComponent.open($(that.wrapSelector(`.vp-pp-step-page[data-name="${appId}"]`)));
323
339
that . state . pipeline [ index ] . app = mlComponent ;
324
340
@@ -350,6 +366,7 @@ define([
350
366
config : { id : name , name : label , path : file , category : 'Pipeline' , resizable : false } ,
351
367
...that . state . pipeline [ index ] . state
352
368
} ) ;
369
+ mlComponent . loadState ( ) ;
353
370
// mlComponent.open($(that.wrapSelector(`.vp-pp-step-page[data-name="${appId}"]`)));
354
371
that . state . pipeline [ index ] . app = mlComponent ;
355
372
@@ -466,6 +483,59 @@ define([
466
483
return optBox . toString ( ) ;
467
484
}
468
485
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
+
469
539
generateCodeForOptionPage ( appId ) {
470
540
let actions = this . modelEditor . getAction ( this . state . modelTypeName ) ;
471
541
let actObj = { } ;
@@ -514,7 +584,7 @@ define([
514
584
515
585
// check disabled
516
586
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' ;
518
588
if ( isVisible && isEnabled ) {
519
589
if ( code . toString ( ) !== '' ) {
520
590
code . appendLine ( ) ;
0 commit comments