Commit d158e13733226fe2ae2b57ef0ed4c1301376c692

Authored by Benjamin Renard
1 parent 2a4ea30c
Exists in mlplasmas and in 1 other branch cu2022

Config

.gitignore
... ... @@ -9,6 +9,7 @@ generic_data/help/
9 9 generic_data/SimuTemplate/TargetsSimu.xml*
10 10 generic_data/guest*
11 11 generic_data/HAPI/metadata/amda-catalog.json
  12 +update_amda/tree.xml
12 13 js/lib/ext
13 14 help/simu
14 15 help/auto
... ...
desktop.php
... ... @@ -53,9 +53,6 @@ if ($sessionID === FALSE) {
53 53 <!-- <script type="text/javascript" src="js/lib/ext/ext-all-dev.js"></script> -->
54 54 <script type="text/javascript" src="js/lib/ext-override.js"></script>
55 55 <script type="text/javascript" src="js/lib/showdown/showdown.min.js"></script>
56   -
57   -<!-- Direct API -->
58   - <script type="text/javascript" src="php/api.php"></script>
59 56  
60 57 <!-- Plotly module-->
61 58 <script src="js/lib/plotly/plotly-2.14.0.min.js"></script>
... ...
js/app/controllers/JobsMgr.js
... ... @@ -99,6 +99,7 @@ Ext.define(&#39;amdaDesktop.JobsMgr&#39;, {
99 99 break
100 100 case 'machinelearning':
101 101 type = 'Machine Learning '
  102 + break
102 103 default:
103 104 type = 'unknown'
104 105 }
... ...
js/app/views/MachineLearningUI.js
... ... @@ -31,7 +31,6 @@ Ext.define(&#39;amdaUI.MachineLearningUI&#39;, {
31 31 ),
32 32  
33 33 logs:"",
34   - debug:true,
35 34  
36 35 predLogsCmp :null,
37 36  
... ... @@ -140,6 +139,18 @@ Ext.define(&#39;amdaUI.MachineLearningUI&#39;, {
140 139 createModelUI: function() {
141 140 var me = this;
142 141  
  142 + this.predLogsCmp = new Ext.Component({
  143 + tpl:"<div>\
  144 + <h2 class='ml-pred-logs-titile'>PREDICTIONS: LOGS</h2>\
  145 + <div class='ml-pred-logs-content' id='prediction_logs'>{messages}</div>\
  146 + </div>",
  147 +
  148 + data: {
  149 + messages:""
  150 + },
  151 + hidden: true
  152 + });
  153 +
143 154 this.modelUI = Ext.create('Ext.panel.Panel', {
144 155 layout: 'border',
145 156 items: [
... ... @@ -241,6 +252,7 @@ Ext.define(&#39;amdaUI.MachineLearningUI&#39;, {
241 252 loadMask.show(false);
242 253 var me = this;
243 254 AmdaAction.runMLModel(this.runModelObj.getJsonValues(), function (result, e) {
  255 + console.log(e);
244 256 loadMask.hide();
245 257 if (!e.status){
246 258 myDesktopApp.errorMsg('Internal error during request');
... ... @@ -389,36 +401,44 @@ Ext.define(&#39;amdaUI.MachineLearningUI&#39;, {
389 401 this.createModelUI()
390 402 ]
391 403 }
392   - ]
  404 + ],
  405 + listeners: {
  406 + afterrender: function() {
  407 + me.setSocket();
  408 + }
  409 + }
393 410 };
394 411  
395   - if(this.debug){
396   - this.predLogsCmp = new Ext.Component({
397   - tpl:"<div>\
398   - <h2 class='ml-pred-logs-titile'>PREDICTIONS: LOGS</h2>\
399   - <div class='ml-pred-logs-content' id='prediction_logs'>{messages}</div>\
400   - </div>",
401   -
402   - data: {
403   - messages:""
404   - }
405   - });
406   - this.setSocket();
407   - }
  412 +
  413 +
408 414 Ext.apply (this, Ext.apply (arguments, myConf));
409 415 },
410 416  
411 417 setSocket: function(){
412   - const endPoint = "http://172.17.0.1:5000";
413   - const socket = io.connect(`${endPoint}`);
414   - const typeMsg = "running";
415 418 const me = this;
416   -
417   - socket.emit(typeMsg, "I'm connected");
418   - socket.on(typeMsg, (msg) => {
419   - const txt = msg.data;
420   - me.logs+= "<p>"+ txt+"</p>";
421   - me.predLogsCmp.update({messages:me.logs});
422   - });
  419 +
  420 + AmdaAction.getMLConfig(function (result, e) {
  421 + if (!e.status){
  422 + return;
  423 + }
  424 + if (!result.success){
  425 + return;
  426 + }
  427 +
  428 + if (result.entrypoint) {
  429 + me.predLogsCmp.setVisible(true);
  430 +
  431 + const endPoint = result.entrypoint;
  432 + const socket = io.connect(`${endPoint}`);
  433 + const typeMsg = "running";
  434 +
  435 + socket.emit(typeMsg, "I'm connected");
  436 + socket.on(typeMsg, (msg) => {
  437 + const txt = msg.data;
  438 + me.logs+= "<p>"+ txt+"</p>";
  439 + me.predLogsCmp.update({messages:me.logs});
  440 + });
  441 + }
  442 + });
423 443 },
424 444 });
... ...
js/app/views/TabResultUI.js
... ... @@ -35,7 +35,8 @@ Ext.define(&#39;amdaUI.TabResultUI&#39;, {
35 35 break;
36 36 case 'statistic': var title = 'Statistics Results';
37 37 break;
38   - case 'machinelearning': var title = 'Machine Learning Results'
  38 + case 'machinelearning': var title = 'Machine Learning Results';
  39 + break;
39 40 default:
40 41 }
41 42  
... ...
php/classes/AmdaAction.php
... ... @@ -1675,6 +1675,11 @@ class AmdaAction
1675 1675 return $this->executeRequest((Object) array('mode' => 'moduleslist'), FunctionTypeEnumClass::MACHINELEARNING);
1676 1676 }
1677 1677  
  1678 + public function getMLConfig()
  1679 + {
  1680 + return $this->executeRequest((Object) array('mode' => 'configinfo'), FunctionTypeEnumClass::MACHINELEARNING);
  1681 + }
  1682 +
1678 1683 public function getMLModelInfo($obj)
1679 1684 {
1680 1685 return $this->executeRequest((Object) array('mode' => 'moduleinfo', 'params' => array('id' => $obj->id)), FunctionTypeEnumClass::MACHINELEARNING);
... ...
php/config.php
... ... @@ -199,6 +199,7 @@ $API = array(
199 199 'getRequestByProcessId' => array('len'=>1),
200 200 'parseTemplatedParam' => array('len'=>1),
201 201 'readDefaultMLModels' => array('len'=>0),
  202 + 'getMLConfig' => array('len'=>0),
202 203 'getMLModelInfo' => array('len'=>1),
203 204 'runMLModel' => array('len'=>1),
204 205 'getMLResult' => array('len'=>3),
... ...