generating plots

This commit is contained in:
Yevheniia Tsapkova 2020-04-03 16:11:57 +02:00
parent 96eb91a91f
commit 6cc2dff872
4 changed files with 56 additions and 0 deletions

8
Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM python:3
WORKDIR /app
COPY ./requirements.txt .
COPY ./generate_plot.py .
RUN pip install matplotlib==3.2.1

20
Jenkinsfile vendored Normal file
View File

@ -0,0 +1,20 @@
pipeline {
agent { dockerfile true }
stages {
stage('Copy results'){
steps {
copyArtifacts filter: 'wer.txt, srr.txt',
fingerprintArtifacts: true, projectName: 's152203-metrics', selector: lastSuccessful()
}
}
stage('Generate and archive plots'){
steps {
sh 'chmod +x plot.sh'
sh label: '', script: './plot.sh'
archiveArtifacts 'wer.png'
archiveArtifacts 'srr.png'
}
}
}
}

22
plot.py Normal file
View File

@ -0,0 +1,22 @@
#!/usr/bin/env python3
import matplotlib.pyplot as plt
def read_into_file(file_name: str) -> list:
with open(file_name, 'r') as f:
return f.read().splitlines()
def generate_plot(data: list, label: str, file_name: str):
plt.plot(data)
plt.ylabel(label)
plt.savefig(file_name)
plt.close()
if __name__ == '__main__':
wer = [float(i) for i in read_into_file('wer-generate.txt')]
srr = [float(i) for i in read_into_file('srr-generate.txt')]
generate_plot(wer, 'WER', 'wer.png')
generate_plot(srr, 'SRR', 'srr.png')

6
plot.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
tail -50 wer.txt > wer-generate.txt
tail -50 srr.txt > srr-generate.txt
python3 plot.py