Skip to content

Commit

Permalink
Revert "Improved classifier, new rocrate modal functionality, new but…
Browse files Browse the repository at this point in the history
…tons in history view"
  • Loading branch information
zagganas authored Mar 5, 2021
1 parent c02e524 commit 6b2bda6
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 117 deletions.
26 changes: 22 additions & 4 deletions components/RoCrateModal.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

class ROCrateModal
{
public static function addModal($result,$model, $fields, $software, $soft_type)
public static function addModal($jobid)
{
$software_icon='<i class="fas fa-question-circle" title="Software url to a public repository like dockerhub"></i>';
$publication_icon='<i class="fas fa-question-circle" title="Include the DOI of the publication that describes the experiment"></i>';
Expand All @@ -50,14 +50,32 @@ public static function addModal($result,$model, $fields, $software, $soft_type)
$download_icon='<i class="fas fa-download"></i>';
$required='<span style="color:red">*</span>';

$history=RunHistory::find()->where(['jobid'=>$jobid])->one();
$software_id=$history->software_id;

$public_url='';
$image_url='';

$history=$result;
$jobid=$history->jobid;
if($history->type=='job')
{
$software=Software::find()->where(['id'=>$software_id])->one();
$soft_type='Software';
$fields=SoftwareInput::find()->where(['softwareid'=>$software_id])->orderBy(['position'=> SORT_ASC])->all();
$fields=Software::getRerunFieldValues($jobid,$fields);
}
elseif ($history->type=='workflow')
{
$workflow=Workflow::find()->where(['id'=>$software_id])->one();
$soft_type='Workflow';
$fields=WorkflowInput::find()->where(['workflow_id'=>$software_id])->orderBy(['position'=> SORT_ASC])->all();
$fields=Workflow::getRerunFieldValues($jobid,$fields);

}

$software_id=$history->software_id;

$model=RoCrate::find()->where(['jobid'=>$jobid])->one();

//print_r($history->jobid);
$disabled_fields=false;
if(!empty($model))
{
Expand Down
47 changes: 2 additions & 45 deletions controllers/SoftwareController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1053,10 +1053,6 @@ public function actionHistory($crate_id='')
$user=User::getCurrentUser()['username'];






// $inactiveJobs=Software::getInactiveJobs();
// print_r($inactiveJobs);
// exit(0);
Expand All @@ -1076,44 +1072,8 @@ public function actionHistory($crate_id='')
->limit($pagination->limit)
->all();

$rocrates=[];
$softwares=[];
$field_matrix=[];
$soft_types=[];
$job_ids=array_column($results, 'jobid');


foreach ($results as $result)
{
if($result->type=='job')
{
$software=Software::find()->where(['id'=>$result->software_id])->one();
$soft_type='Software';
$fields=SoftwareInput::find()->where(['softwareid'=>$result->software_id])->orderBy(['position'=> SORT_ASC])->all();
$fields=Software::getRerunFieldValues($result->jobid,$fields);


}
elseif ($result->type=='workflow')
{
$workflow=Workflow::find()->where(['id'=>$result->software_id])->one();
$soft_type='Workflow';
$fields=WorkflowInput::find()->where(['workflow_id'=>$result->software_id])->orderBy(['position'=> SORT_ASC])->all();
$fields=Workflow::getRerunFieldValues($result->jobid,$fields);
}

if ($result->type=='job' || $result->type=='workflow')
{

$rocrates[$result->jobid]=RoCrate::find()->where(['jobid'=>$result->jobid])->one();
$softwares[$result->jobid]=$software;
$field_matrix[$result->jobid]=$fields;
$soft_types[$result->jobid]=$soft_type;
}

}

return $this->render('history',['results'=>$results,'pagination'=>$pagination,'available'=>$available,'available_workflows'=>$available_workflows,'crate_id'=>$crate_id, 'rocrates'=>$rocrates, 'softwares'=>$softwares, 'field_matrix'=>$field_matrix, 'soft_types'=>$soft_types]);

return $this->render('history',['results'=>$results,'pagination'=>$pagination,'available'=>$available,'available_workflows'=>$available_workflows,'crate_id'=>$crate_id]);
}

public function actionRerun($jobid)
Expand Down Expand Up @@ -1238,9 +1198,6 @@ public function actionRerun($jobid)
->count();
$type=1;




return $this->render('run', ['form_params'=>$form_params, 'name'=>$name,
'version'=>$version, 'jobid'=>'',
'errors'=>'', 'runErrors'=>'', 'podid'=>'', 'machineType'=>'',
Expand Down
3 changes: 0 additions & 3 deletions models/RunHistory.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
use Yii;
use yii\db\Query;



/**
* This is the model class for table "run_history".
*
Expand All @@ -47,7 +45,6 @@
*/
class RunHistory extends \yii\db\ActiveRecord
{
public $rocrate_fields=[];
/**
* {@inheritdoc}
*/
Expand Down
16 changes: 3 additions & 13 deletions scheduler_files/classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
from sklearn import preprocessing
from sklearn.preprocessing import MinMaxScaler
from sklearn import svm
from sklearn.feature_selection import VarianceThreshold
from sklearn.feature_selection import SelectKBest
from sklearn.feature_selection import chi2

import csv
import sys
Expand Down Expand Up @@ -103,7 +100,7 @@
if has_header:
next(reader)

print("=> Reading samples file ("+bsamples_file.name+")")
print("=> Reading benign samples file ("+bsamples_file.name+")")
bsamples_read = 0
for bsample in bsamples_it:
if len(bsample)!=0: #avoid empty lines (separators between different benchmarks)
Expand Down Expand Up @@ -157,9 +154,7 @@
print("=> Normalizing inputs...")
min_max_scaler = preprocessing.MinMaxScaler()
X = min_max_scaler.fit_transform(X)
# X= SelectKBest(chi2, k=1).fit_transform(X, y)
print("\t- Done.")
print(X)

# data set split
print("=> Splitting dataset...")
Expand All @@ -168,7 +163,7 @@

# selecting classification method

class_approaches=["log_regression", "log_regression_cs","svm","random_forest", "random_forest_cs"]
class_approaches=["log_regression", "log_regression_cs", "random_forest", "random_forest_cs", "svm"]


# # grid search for optimal hyperparameters
Expand All @@ -181,7 +176,7 @@
if class_approach == "log_regression" or class_approach == "log_regression_cs": # logistic regression / logistic regression cost sensitive
# params for cross-validation
tuned_parameters = {
"max_iter": [2000,3000,10000],
"max_iter": [60, 80, 100, 120, 140, 160, 180, 200, 220, 240],
"solver": ['newton-cg', 'lbfgs', 'liblinear', 'sag', 'saga']
}
# determine classifier
Expand Down Expand Up @@ -227,12 +222,7 @@
best_params[i]=clf.best_params_
best_scores[i]=clf.best_score_

predictions=clf.predict(testX)
i=i+1

for row_index, (input, prediction, label) in enumerate(zip (testX, predictions, testy)):
if prediction != label:
print('Row', row_index, 'has been classified as ', prediction, 'and should be ', label)

best_score=0
best_clf=''
Expand Down
2 changes: 1 addition & 1 deletion scheduler_files/node-selector.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
X_std = (X - scaler['min']) / (scaler['max'] - scaler['min'])
X= X_std * (1 - 0) + 0


result=model.predict(X)
nodeType=classes[result[0]]

print(nodeType)


Expand Down
69 changes: 30 additions & 39 deletions views/software/history.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,9 @@
use app\components\Headers;
use app\components\RoCrateModal;
use app\models\RoCrate;
use app\components\SoftIndexButton;

$this->title="Job history";

echo Html::cssFile('@web/css/software/history.css');
$this->registerJsFile('@web/js/software/history.js', ['depends' => [\yii\web\JqueryAsset::className()]]);
/*
* Users are able to view the name, version, start date, end date, mountpoint
Expand Down Expand Up @@ -104,7 +102,7 @@
*/

$play_icon='<i class="fas fa-play"></i>';
$experiment_icon='<i class="fa fa-flask" aria-hidden="true"></i>';
$experiment_icon='<i class="fa fa-flask" aria-hidden="true" style="color:white"></i>';
$details_icon='<i class="fas fa-eye"></i>';


Expand All @@ -113,11 +111,11 @@
{
if ($res->status=='Complete')
{
$completed=true;
$completed='';
}
else
{
$completed=false;
$completed='hidden';
}
$key=$res['software_id'];
?>
Expand Down Expand Up @@ -167,33 +165,32 @@
<?php
if (empty($res->status))
{

?>
<?= Html::a("$play_icon",[$controller . '/reattach','jobid'=>$res->jobid],['class'=>'btn btn-run', 'title'=>'Re-attach' ])?>
<?= Html::a("$details_icon",['software/job-details', 'jobid'=>$res->jobid],['class'=>'btn btn-details', 'title'=>'Details'])?>
<?= Html::a("$play_icon",[$controller . '/reattach','jobid'=>$res->jobid],['class'=>'btn btn-success btn-md', 'title'=>'Re-attach' ])?>
<?= Html::a("$details_icon",['software/job-details', 'jobid'=>$res->jobid],['class'=>'btn btn-secondary btn-md', 'title'=>'Details'])?>

<?php
}
else
{
?> <?= Html::a("$play_icon",[$controller . '/rerun','jobid'=>$res->jobid],
['class'=>'btn btn-run', 'title'=>'Re-run'])?>
<?= Html::a("$details_icon",['software/job-details', 'jobid'=>$res->jobid],['class'=>'btn btn-details', 'title'=>'Details'])?>
['class'=>'btn btn-success btn-md', 'title'=>'Re-run'])?>
<?= Html::a("$details_icon",['software/job-details', 'jobid'=>$res->jobid],['class'=>'btn btn-secondary btn-md', 'title'=>'Details'])?>
<?php
$experiment=$rocrates[$res->jobid];

if (!empty($experiment) && $completed)
$experiment=RoCrate::find()->where(['jobid'=>$res->jobid])->one();
if (!empty($experiment))
{
echo Html::a("$experiment_icon", null,
['class'=>"btn btn-experiment-exists experiment", 'data-target'=>"#experiment-modal-$res->jobid", 'title'=>'Edit the RO-crate object of this run', 'id'=>"$res->jobid", ]);
$experiment_icon='<i class="fa fa-flask" aria-hidden="true" style="color:rgb(127, 255, 0)"></i>';
$title='Edit the RO-crate object of this run';
}
elseif (empty($experiment) && $completed)
else
{
echo Html::a("$experiment_icon", null,
['class'=>"btn btn-experiment-new experiment", 'data-target'=>"#experiment-modal-$res->jobid", 'title'=>'Save the run in an RO-crate object, to facilitate the reproducibility of the corresponding experiment', 'id'=>"$res->jobid", ]);
$experiment_icon='<i class="fa fa-flask" aria-hidden="true" style="color:white"></i>';
$title='Save the run in an RO-crate object, to facilitate the reproducibility of the corresponding experiment';
}
?>

<?= Html::a("$experiment_icon", null,
['class'=>"btn btn-secondary btn-md experiment $completed", 'data-target'=>"#experiment-modal-$res->jobid", 'title'=>"$title", 'id'=>"$res->jobid", ])?>
<?php
}
?>
Expand Down Expand Up @@ -222,33 +219,32 @@
if (empty($res->status))
{
?>
<?= Html::a("$play_icon",['workflow/reattach','jobid'=>$res->jobid],['class'=>'btn btn-run', 'title'=>'Re-attach'])?>
<?= Html::a("$details_icon",['software/job-details', 'jobid'=>$res->jobid],['class'=>'btn btn-details', 'title'=>'Details'])?>
<?= Html::a("$play_icon",['workflow/reattach','jobid'=>$res->jobid],['class'=>'btn btn-success btn-md', 'title'=>'Re-attach'])?>
<?= Html::a("$details_icon",['software/job-details', 'jobid'=>$res->jobid],['class'=>'btn btn-secondary btn-md', 'title'=>'Details'])?>

<?php
}
else
{

?> <?= Html::a("$play_icon",['workflow/rerun','jobid'=>$res->jobid],
['class'=>'btn btn-run', 'title'=>'Re-run'])?>
<?= Html::a("$details_icon",['software/job-details', 'jobid'=>$res->jobid],['class'=>' btn btn-details', 'title'=>'Details'])?>
['class'=>'btn btn-success btn-md', 'title'=>'Re-run'])?>
<?= Html::a("$details_icon",['software/job-details', 'jobid'=>$res->jobid],['class'=>' btn btn-secondary btn-md', 'title'=>'Details'])?>
<?php

$experiment=$rocrates[$res->jobid];

if (!empty($experiment) && $completed)
$experiment=RoCrate::find()->where(['jobid'=>$res->jobid])->one();
if (!empty($experiment))
{
echo Html::a("$experiment_icon", null,
['class'=>"btn btn-experiment-exists experiment", 'data-target'=>"#experiment-modal-$res->jobid", 'title'=>'Edit the RO-crate object of this run', 'id'=>"$res->jobid", ]);
$experiment_icon='<i class="fa fa-flask" aria-hidden="true" style="color:rgb(127, 255, 0)"></i>';
$title='Edit the RO-crate object of this run';
}
elseif (empty($experiment) && $completed)
else
{
echo Html::a("$experiment_icon", null,
['class'=>"btn btn-experiment-new experiment", 'data-target'=>"#experiment-modal-$res->jobid", 'title'=>'Save the run in an RO-crate object, to facilitate the reproducibility of the corresponding experiment', 'id'=>"$res->jobid", ]);
$experiment_icon='<i class="fa fa-flask" aria-hidden="true" style="color:white"></i>';
$title='Save the run in an RO-crate object, to facilitate the reproducibility of the corresponding experiment';
}
?>

<?= Html::a("$experiment_icon", null,
['class'=>"btn btn-secondary btn-md experiment $completed", 'data-target'=>"#experiment-modal-$res->jobid", 'title'=>"$title", 'id'=>"$res->jobid", ])?>
<?php
}
?>
Expand Down Expand Up @@ -287,14 +283,9 @@
<?php
foreach ($results as $result)
{

if ($result->type=='job' || $result->type=='workflow')
{
$software=$softwares[$result->jobid];
$soft_type=$soft_types[$result->jobid];
$model=$rocrates[$result->jobid];
$fields=$field_matrix[$result->jobid];
RoCrateModal::addModal($result, $model, $fields, $software, $soft_type);
RoCrateModal::addModal($result->jobid);
}
}

Expand Down
12 changes: 0 additions & 12 deletions web/css/software/history.css

This file was deleted.

0 comments on commit 6b2bda6

Please sign in to comment.