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

Some small correction in web interface

parent 05efb997
No related branches found
No related tags found
No related merge requests found
Pipeline #6577 passed
stages:
- test
- build
- deploy
## Cache composer packages between all jobs and all branches
## of this project...
......@@ -12,24 +13,24 @@ cache:
before_script:
- cp env.gitlab-ci .env
- touch storage/app/db.sqlite
- COMPOSER_CACHE_DIR=composer-cache composer install
- COMPOSER_CACHE_DIR=composer-cache composer install --ignore-platform-reqs
- php artisan key:generate
- php artisan migrate
# Test with PHP7.4
test:php74:
image: cylab/php74
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/cylab/php74:latest
stage: test
script:
#- vendor/bin/phpunit --coverage-text --colors=never --coverage-html build/coverage
- vendor/bin/phpcs
artifacts:
paths:
- build/
- build/
expire_in: 1 month
build:
image: docker:19.03.1
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:19.03.1
stage: build
tags:
- dind
......@@ -42,11 +43,29 @@ build:
script:
- docker build -t cylab/ctf .
build:release:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:19.03.1
stage: build
tags:
- dind
services:
- docker:19.03.1-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
before_script:
- docker info
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t gitlab.cylab.be:8081/cylab/mark-web:$CI_COMMIT_REF_SLUG .
- docker tag gitlab.cylab.be:8081/cylab/mark-web:$CI_COMMIT_REF_SLUG gitlab.cylab.be:8081/cylab/mark-web:latest
- docker push gitlab.cylab.be:8081/cylab/mark-web:$CI_COMMIT_REF_SLUG
- docker push gitlab.cylab.be:8081/cylab/mark-web:latest
build:tagged:
only:
- tags
image: docker:19.03.1
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:19.03.1
stage: build
tags:
- dind
......@@ -62,3 +81,15 @@ build:tagged:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- docker push cylab/mark-web:$CI_COMMIT_TAG
- docker push cylab/mark-web:latest
deploy:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/cylab/php74
stage: deploy
script:
# import ssh private key
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
# in cylab/php72, envoy is already installed...
- ~/.composer/vendor/bin/envoy run deploy --commit="$CI_COMMIT_SHA"
stages:
- test
- build
- deploy
## Cache composer packages between all jobs and all branches
## of this project...
......@@ -13,24 +12,24 @@ cache:
before_script:
- cp env.gitlab-ci .env
- touch storage/app/db.sqlite
- COMPOSER_CACHE_DIR=composer-cache composer install --ignore-platform-reqs
- COMPOSER_CACHE_DIR=composer-cache composer install
- php artisan key:generate
- php artisan migrate
# Test with PHP7.4
test:php74:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/cylab/php74:latest
image: cylab/php74
stage: test
script:
#- vendor/bin/phpunit --coverage-text --colors=never --coverage-html build/coverage
- vendor/bin/phpcs
artifacts:
paths:
- build/
- build/
expire_in: 1 month
build:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:19.03.1
image: docker:19.03.1
stage: build
tags:
- dind
......@@ -43,29 +42,11 @@ build:
script:
- docker build -t cylab/ctf .
build:release:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:19.03.1
stage: build
tags:
- dind
services:
- docker:19.03.1-dind
variables:
DOCKER_TLS_CERTDIR: "/certs"
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
before_script:
- docker info
script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build -t gitlab.cylab.be:8081/cylab/mark-web:$CI_COMMIT_REF_SLUG .
- docker tag gitlab.cylab.be:8081/cylab/mark-web:$CI_COMMIT_REF_SLUG gitlab.cylab.be:8081/cylab/mark-web:latest
- docker push gitlab.cylab.be:8081/cylab/mark-web:$CI_COMMIT_REF_SLUG
- docker push gitlab.cylab.be:8081/cylab/mark-web:latest
build:tagged:
only:
- tags
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:19.03.1
image: docker:19.03.1
stage: build
tags:
- dind
......@@ -81,15 +62,3 @@ build:tagged:
- docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD
- docker push cylab/mark-web:$CI_COMMIT_TAG
- docker push cylab/mark-web:latest
deploy:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/cylab/php74
stage: deploy
script:
# import ssh private key
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
- mkdir -p ~/.ssh
- echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
# in cylab/php72, envoy is already installed...
- ~/.composer/vendor/bin/envoy run deploy --commit="$CI_COMMIT_SHA"
......@@ -42,7 +42,7 @@ class Wowa extends Model
//Display text in the status badge
public function statusBadge()
{
if ($this->status == self::STATE_RUNNING || $this->status == self::STATE_QUEUED) {
if ($this->status === self::STATE_RUNNING) {
return "<span class='btn btn-badge btn-sm "
. $this->getStatusBadgeClass() . "'>" . $this->status
. " : " . $this->getProgression() . "</span>";
......@@ -52,14 +52,14 @@ class Wowa extends Model
}
}
public function weightsP() : array
public function weightsP() : ?array
{
//$P = implode(',', $this->p_weights);
//return str_replace(array('[', ']'), '', $P);
return $this->p_weights;
}
public function weightsW() : array
public function weightsW() : ?array
{
//$W = implode(',', $this->w_weights);
//return str_replace(array('[', ']'), '', $W);
......@@ -79,32 +79,40 @@ class Wowa extends Model
//Read the last line of the log file, get the progression value
public function getProgression() : string
{
$line = '';
if (!file_exists($this->getLogPathOnDisk())) {
return "File not found";
}
$f = fopen($this->getLogPathOnDisk(), 'r');
$cursor = -1;
fseek($f, $cursor, SEEK_END);
$char = fgetc($f);
while ($char === "\n" || $char === "\r") {
fseek($f, $cursor--, SEEK_END);
$char = fgetc($f);
}
while ($char !== false && $char !== "\n" && $char !== "\r") {
$line = $char . $line;
fseek($f, $cursor--, SEEK_END);
if (env('LOG_CHANNEL') === 'stack') {
$line = '';
if (!file_exists($this->getLogPathOnDisk())) {
return "File not found";
}
$f = fopen($this->getLogPathOnDisk(), 'r');
$cursor = -1;
fseek($f, $cursor, SEEK_END);
$char = fgetc($f);
}
$generation = intval($this->getStringBetween($line, ': ', '|'));
if ($this->status === Wowa::STATE_COLLECTION) {
return $generation;
while ($char === "\n" || $char === "\r") {
fseek($f, $cursor--, SEEK_END);
$char = fgetc($f);
}
while ($char !== false && $char !== "\n" && $char !== "\r") {
$line = $char . $line;
fseek($f, $cursor--, SEEK_END);
$char = fgetc($f);
}
$generation = intval($this->getStringBetween($line, ': ', '|'));
if ($this->status === Wowa::STATE_COLLECTION) {
return $generation;
}
return (($generation + 1) / $this->generation_number) * 100;
} else {
$log = Log::where('job_id', $this->id)->where('training', 1)->latest()->first();
if (is_null($log)) {
return "Computation...";
}
}
return (($generation +1) / $this->generation_number) * 100;
return $log->progression;
}
//Method to return the value between : and | (progression)
......
......@@ -51,7 +51,13 @@
<div>
<b>Weights W Vector:</b>
<div class="input-group mb-3">
<input id="w_weights" type="text" class="form-control" readonly value="@json($wowa->weightsW())" style="overflow-x: scroll" onclick="this.focus();this.select()">
@if($wowa->status === \App\Wowa::STATE_QUEUED || $wowa->status === \App\Wowa::STATE_RUNNING || $wowa->status === \App\Wowa::STATE_COLLECTION)
<input id="w_weights" type="text" class="form-control" readonly disabled value="Computation in progress..." style="overflow-x: scroll">
@elseif($wowa->status === \App\Wowa::STATE_FAILED)
<input id="w_weights" type="text" class="form-control" readonly disabled value="Failed..." style="overflow-x: scroll">
@else
<input id="w_weights" type="text" class="form-control" readonly value="@json($wowa->weightsW())" style="overflow-x: scroll" onclick="this.focus();this.select()">
@endif
<div class="input-group-append">
<button type="button" id="w_weights_button" class="btn btn-info" title="Copy to clipboard">Copy</button>
</div>
......@@ -60,7 +66,13 @@
<div>
<b>Weights W Vector:</b>
<div class="input-group mb-3">
<input id="p_weights" type="text" class="form-control" readonly value="@json($wowa->weightsP())" style="overflow: scroll" onclick="this.focus();this.select()">
@if ($wowa->status === \App\Wowa::STATE_QUEUED || $wowa->status === \App\Wowa::STATE_RUNNING || $wowa->status === \App\Wowa::STATE_COLLECTION)
<input id="p_weights" type="text" class="form-control" readonly disabled value="Computation in progress..." style="overflow-x: scroll">
@elseif($wowa->status === \App\Wowa::STATE_FAILED)
<input id="p_weights" type="text" class="form-control" readonly disabled value="Computation in progress..." style="overflow-x: scroll">
@else
<input id="p_weights" type="text" class="form-control" readonly value="@json($wowa->weightsP())" style="overflow: scroll" onclick="this.focus();this.select()">
@endif
<div class="input-group-append">
<button id="p_weights_button" type="button" class="btn btn-info" title="Copy to clipboard">Copy</button>
</div>
......
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