diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..17fcfe0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,8 @@ +FROM python:3 + +WORKDIR /app + +COPY ./requirements.txt . +COPY ./generate_plot.py . + +RUN pip install matplotlib==3.2.1 \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..92b44eb --- /dev/null +++ b/Jenkinsfile @@ -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' + } + } + } +} \ No newline at end of file diff --git a/plot.py b/plot.py new file mode 100644 index 0000000..57a0dd9 --- /dev/null +++ b/plot.py @@ -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') \ No newline at end of file diff --git a/plot.sh b/plot.sh new file mode 100644 index 0000000..b6c8ff1 --- /dev/null +++ b/plot.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +tail -50 wer.txt > wer-generate.txt +tail -50 srr.txt > srr-generate.txt + +python3 plot.py \ No newline at end of file