From 599b1be807b7d82e998af7b4e9de66b21f4f2ff6 Mon Sep 17 00:00:00 2001 From: Kamila Date: Tue, 3 May 2022 18:41:33 +0200 Subject: [PATCH] Task 2 Part 2 --- Jenkinsfile_eval | 22 +++++++++++++++------- Jenkinsfile_train | 10 +++++----- nn_train_eval.py | 4 ++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/Jenkinsfile_eval b/Jenkinsfile_eval index be7e509..7b0b141 100644 --- a/Jenkinsfile_eval +++ b/Jenkinsfile_eval @@ -3,11 +3,12 @@ pipeline { dockerfile true } parameters { - string( - defaultValue: '200', - description: 'number of epochs', - name: 'EPOCH' - ) + gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'BRANCH', type: 'PT_BRANCH' + buildSelector( + defaultSelector: lastSuccessful(), + description: 'Which build to use for copying artifacts', + name: 'BUILD_SELECTOR' + ) } stages { @@ -20,7 +21,7 @@ pipeline { stage('Copy from different Pipeline') { steps { copyArtifacts fingerprintArtifacts: true, projectName: 's444517-create-dataset', selector: lastSuccessful() - copyArtifacts fingerprintArtifacts: true, projectName: 's444517-training/master', selector: lastSuccessful() + copyArtifacts fingerprintArtifacts: true, projectName: 's444517-training/${BRANCH}', selector: buildParameter('BUILD_SELECTOR') copyArtifacts fingerprintArtifacts: true, projectName: 's444517-evaluation/master', selector: lastSuccessful(), optional: true } } @@ -28,10 +29,17 @@ pipeline { stage('Get data save artifacts') { steps { sh 'python3 ./nn_train_eval.py' - archiveArtifacts artifacts: 'my_model/saved_model.pb, metrics.txt, output.jpg' + archiveArtifacts artifacts: 'my_model/saved_model.pb, metrics.txt, output.jpg, current_results.txt' } } } + post { + + always { + def metrics = readFile(file: 'current_results.txt') + emailext body: "${currentBuild.currentResult} ${metrics}", subject: 's444517_build_status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms' + } + } } diff --git a/Jenkinsfile_train b/Jenkinsfile_train index 23a74b5..8b9b70f 100644 --- a/Jenkinsfile_train +++ b/Jenkinsfile_train @@ -31,10 +31,10 @@ pipeline { } } } - //post { - // always { - // emailext body: "${currentBuild.currentResult}", subject: 's444517_build_status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms' - // } - //} + post { + always { + emailext body: "${currentBuild.currentResult}", subject: 's444517_build_status', to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms' + } + } } diff --git a/nn_train_eval.py b/nn_train_eval.py index 3fa623f..38548b0 100644 --- a/nn_train_eval.py +++ b/nn_train_eval.py @@ -19,6 +19,10 @@ def new_metrics(): acc = accuracy_score(y_true, y_pred) recc = recall_score(y_true, y_pred, average='macro') + with open("current_results.txt", 'w') as f: + f.write(f"accuracy: {acc} recall: {recc}") + f.close() + with open("metrics.txt", 'a') as f: f.write(f"{acc},{recc}\n") f.close()