Skip to content
Snippets Groups Projects
Commit 68620c97 authored by a.croix's avatar a.croix
Browse files

Add progression track during evidences collection

parent b37c696f
No related branches found
No related tags found
1 merge request!1Include Wowa Training
Pipeline #5916 passed
......@@ -66,12 +66,15 @@ class WowaJob implements ShouldQueue
$processor = new LogProcessor();
$processor->setJobId($this->wowa->id);
$logg->pushProcessor($processor);
$logg->info("Begin find all related evidences");
try {
Feedback::chunk(100, function ($feedbacks) {
$cnt = 0;
$this->wowa->status = Wowa::STATE_COLLECTION;
$this->wowa->save();
Feedback::chunk(100, function ($feedbacks) use ($cnt) {
foreach ($feedbacks as $feed) {
$cnt++;
$evidence_references = $feed->report()->references;
$this->is_true_alert[] = $feed->is_true_alert;
$scores_references = [];
......@@ -79,6 +82,7 @@ class WowaJob implements ShouldQueue
$scores_references[] = Mark::get()->findEvidenceById($evidence_reference)->score;
}
$this->evidences[] = $scores_references;
\Log::info($cnt . " | Evidences collection");
}
});
} catch (\Exception $e) {
......@@ -86,7 +90,6 @@ class WowaJob implements ShouldQueue
$logg->error("Error during retrieving evidences");
$this->wowa->save();
}
$training_prameters = new TrainerParameters(
$logg,
$this->wowa->population,
......@@ -97,6 +100,8 @@ class WowaJob implements ShouldQueue
TrainerParameters::INITIAL_POPULATION_GENERATION_RANDOM
);
$trainer = new Trainer($training_prameters, new SolutionDistance(count($this->evidences[0])));
$this->wowa->status = Wowa::STATE_RUNNING;
$this->wowa->save();
try {
$solution = $trainer->run($this->evidences, $this->is_true_alert);
} catch (\Exception $e) {
......
......@@ -18,8 +18,15 @@ class Log extends Model
if (!is_object($logs)) {
return "Calculation in progress...";
}
$generation = $logs->generation + 1;
if ($wowa->status == Wowa::STATE_COLLECTION) {
$result = 'Evidences collection : ';
} elseif ($wowa->status == Wowa::STATE_RUNNING) {
$result = 'Training : ';
} else {
$result = 'Error';
}
$progression = $logs->progression + 1;
$generation_number = $wowa->generation_number;
return ($generation / $generation_number) * 100;
return $result . (($progression / $generation_number) * 100);
}
}
......@@ -23,8 +23,8 @@ class LogFormatter extends NormalizerFormatter
$el = $record['extra'];
$el['level'] = strtolower($record['level_name']);
$el['message'] = $record['message'];
$generation = substr($record['message'], 0, strpos($record['message'], ' | Fitness'));
$el['generation'] = (int)$generation;
$progression = substr($record['message'], 0, strpos($record['message'], ' | '));
$el['progression'] = (int)$progression;
return $el;
}
......
......@@ -8,6 +8,7 @@ class Wowa extends Model
{
const STATE_CREATED = "CREATED";
const STATE_QUEUED = "QUEUED";
const STATE_COLLECTION = "DATA COLLECTION";
const STATE_RUNNING = "RUNNING";
const STATE_SUCCESS = "SUCCESS";
const STATE_FAILED = "FAILED";
......@@ -15,7 +16,8 @@ class Wowa extends Model
public static $status_classes = [
self::STATE_SUCCESS => "btn-success",
self::STATE_FAILED => "btn-danger",
self::STATE_RUNNING => "btn-warning"
self::STATE_RUNNING => "btn-warning",
self::STATE_COLLECTION => "btn-warning"
];
......
......@@ -17,7 +17,7 @@ class CreateLogsTable extends Migration
$table->id();
$table->timestamps();
$table->enum('level', ['emergency', 'alert', 'critical', 'error', 'warning', 'notice', 'info', 'debug']);
$table->integer('generation')->nullable();
$table->integer('progression')->nullable();
$table->text('message')->nullable();
$table->text('user_id')->nullable();
$table->integer('job_id')->nullable();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment