ium_444452/Jenkins/Jenkinsfile.evaluation

101 lines
3.9 KiB
Plaintext
Raw Normal View History

2022-05-03 00:04:19 +02:00
node {
checkout scm
try {
2022-05-15 23:23:56 +02:00
docker.image('s444452/ium:1.4').inside('-v /mlruns:/mlruns') {
2022-05-03 00:04:19 +02:00
stage('Preparation') {
properties([
parameters([
2022-05-04 18:57:18 +02:00
gitParameter(
branchFilter: 'origin/(.*)',
defaultValue: 'master',
description: 'Select branch',
name: 'BRANCH',
type: 'PT_BRANCH'
),
2022-05-04 19:27:40 +02:00
buildSelector(
defaultSelector: upstream(),
description: 'Which build to use for copying artifacts',
name: 'BUILD_SELECTOR'
2022-05-04 18:08:52 +02:00
),
2022-05-04 20:05:40 +02:00
string(
defaultValue: "0",
description: 'Build number',
name: 'BUILD_NR'
2022-05-08 13:35:38 +02:00
),
string(
defaultValue: ".",
description: 'Data path',
name: 'DATA_PATH'
),
string(
defaultValue: "1",
description: 'EPOCHS',
name: 'EPOCHS'
),
string(
defaultValue: "20000",
description: 'Num words',
name: 'NUM_WORDS'
),
string(
2022-05-08 13:57:52 +02:00
defaultValue: "150",
2022-05-08 13:35:38 +02:00
description: 'Batch size',
name: 'BATCH_SIZE'
),
string(
2022-05-08 13:57:52 +02:00
defaultValue: "300",
2022-05-08 13:35:38 +02:00
description: 'Pad length',
name: 'PAD_LENGTH'
2022-05-03 00:04:19 +02:00
)
])
])
}
stage('Copy artifacts') {
copyArtifacts filter: 'train_data.csv', fingerprintArtifacts: true, projectName: 's444452-create-dataset'
copyArtifacts filter: 'test_data.csv', fingerprintArtifacts: true, projectName: 's444452-create-dataset'
2022-05-04 23:00:44 +02:00
copyArtifacts filter: 'neural_network_evaluation.csv', projectName: "s444452-evaluation/${params.BRANCH}", optional: true
copyArtifacts filter: 'model/neural_net', projectName: "s444452-training/${params.BRANCH}", selector: buildParameter('BUILD_SELECTOR')
2022-05-03 00:04:19 +02:00
}
stage('Run script') {
2022-05-08 13:35:38 +02:00
withEnv(["BUILD_NR=${params.BUILD_NR}","DATA_PATH=${params.DATA_PATH}","EPOCHS=${params.EPOCHS}",
"NUM_WORDS=${params.NUM_WORDS}", "BATCH_SIZE=${params.BATCH_SIZE}","PAD_LENGTH=${params.PAD_LENGTH}"]) {
2022-05-16 08:29:22 +02:00
sh "chmod u+x Scripts/evaluate_neural_network.py"
2022-05-08 13:35:38 +02:00
sh "python3 Scripts/evaluate_neural_network.py $BUILD_NR $DATA_PATH $EPOCHS $NUM_WORDS $BATCH_SIZE $PAD_LENGTH"
2022-05-03 00:04:19 +02:00
}
}
stage('Archive artifacts') {
2022-05-04 19:32:49 +02:00
archiveArtifacts "neural_network_evaluation.csv, evaluation.png"
2022-05-08 13:35:38 +02:00
archiveArtifacts "my_runs/**"
2022-05-16 08:29:22 +02:00
archiveArtifacts "mlruns/**"
2022-05-03 00:04:19 +02:00
}
}
} catch (e) {
currentBuild.result = "FAILED"
throw e
} finally {
notifyBuild(currentBuild.result)
}
}
def notifyBuild(String buildStatus = 'STARTED') {
buildStatus = buildStatus ?: 'SUCCESS'
def subject = "Job: ${env.JOB_NAME}"
2022-05-04 22:23:17 +02:00
def lastline = ""
2022-05-04 22:16:28 +02:00
try {
def filePath = readFile "${WORKSPACE}/neural_network_evaluation.csv"
def lines = filePath.readLines()
2022-05-04 22:23:17 +02:00
lastline = lines.get(lines.size()-1)
2022-05-04 22:16:28 +02:00
}
catch (e) {
2022-05-04 22:23:17 +02:00
println(e.toString())
2022-05-04 22:16:28 +02:00
}
2022-05-04 20:29:38 +02:00
2022-05-08 13:44:57 +02:00
def build_params = "Path: ${params.DATA_PATH}, Epochs: ${params.EPOCHS}, Num_words: ${params.NUM_WORDS}, Batch_size: ${params.BATCH_SIZE}, Pad_length: ${params.PAD_LENGTH}"
def details = "Build nr: ${env.BUILD_NUMBER}, status: ${buildStatus} \n url: ${env.BUILD_URL} \n build params: ${build_params} \n metrics: ${lastline}"
2022-05-03 00:04:19 +02:00
emailext (
subject: subject,
body: details,
to: 'e19191c5.uam.onmicrosoft.com@emea.teams.ms'
)
}