2023-05-10 14:47:19 +02:00
|
|
|
node {
|
|
|
|
stage('Preparation') {
|
|
|
|
properties([
|
2023-05-10 18:27:24 +02:00
|
|
|
// pipelineTriggers([
|
|
|
|
// // TODO change auto run after train
|
|
|
|
// upstream(
|
|
|
|
// threshold: hudson.model.Result.SUCCESS,
|
|
|
|
// upstreamProjects: 's424714-create-dataset'
|
|
|
|
// )
|
|
|
|
// ]),
|
|
|
|
// copyArtifactPermission('*'),
|
2023-05-10 14:47:19 +02:00
|
|
|
parameters([
|
2023-05-10 19:22:57 +02:00
|
|
|
gitParameter branchFilter: 'origin/(.*)', defaultValue: 'master', name: 'BRANCH', type: 'PT_BRANCH',
|
2023-05-10 14:47:19 +02:00
|
|
|
buildSelector(
|
|
|
|
defaultSelector: lastSuccessful(),
|
|
|
|
description: 'Which build to use for copying artifacts',
|
|
|
|
name: 'BUILD_SELECTOR'
|
|
|
|
),
|
2023-05-10 18:27:24 +02:00
|
|
|
buildSelector(
|
|
|
|
defaultSelector: lastSuccessful(),
|
|
|
|
description: 'Which build of train to use for copying artifacts',
|
|
|
|
name: 'BUILD_SELECTOR_TRAINING'
|
|
|
|
),
|
2023-05-10 14:47:19 +02:00
|
|
|
|
|
|
|
])
|
|
|
|
])
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Git clone') {
|
|
|
|
//cloning git repo
|
|
|
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], extensions: [], userRemoteConfigs: [[credentialsId: 's424714', url: 'https://git.wmi.amu.edu.pl/s424714/ium_424714']]])
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Dockerfile build') {
|
|
|
|
|
|
|
|
|
|
|
|
sh "chmod +x -R ${env.WORKSPACE}"
|
|
|
|
copyArtifacts fingerprintArtifacts: true, projectName: 's424714-create-dataset', selector: buildParameter('BUILD_SELECTOR')
|
|
|
|
//TODO from train
|
2023-05-10 18:27:24 +02:00
|
|
|
sh "echo git parameter: ${params.BRANCH}"
|
|
|
|
copyArtifacts filter: '*', projectName: 's424714-training/${params.BRANCH}' selector: buildParameter('BUILD_SELECTOR_TRAINING')
|
2023-05-10 16:41:42 +02:00
|
|
|
// copyArtifacts filter('*.csv') projectName: env.JOB_NAME, selector: specific(env.BUILD_NUMBER)
|
2023-05-10 14:47:19 +02:00
|
|
|
// copyArtifacts fingerprintArtifacts: true, projectName: 's424714-create-dataset', selector: buildParameter('BUILD_SELECTOR')
|
|
|
|
|
2023-05-10 17:01:33 +02:00
|
|
|
def dockerImage = docker.image("s424714-model:latest")
|
2023-05-10 14:47:19 +02:00
|
|
|
|
|
|
|
dockerImage.inside {
|
2023-05-10 17:29:47 +02:00
|
|
|
withEnv(["TRANSFORMERS_CACHE=./.cache","MPLCONFIGDIR=./.cache"]) {
|
2023-05-10 14:47:19 +02:00
|
|
|
stage("Docker: cloning artifacts"){
|
2023-05-10 16:41:42 +02:00
|
|
|
script {
|
|
|
|
if (currentBuild.previousBuild) {
|
|
|
|
try {
|
2023-05-10 17:01:33 +02:00
|
|
|
copyArtifacts(projectName: currentBuild.projectName,
|
2023-05-10 16:41:42 +02:00
|
|
|
selector: specific("${currentBuild.previousBuild.number}"))
|
|
|
|
|
|
|
|
echo("The current build is ${currentBuild.number}")
|
|
|
|
sh 'mkdir -p ./results/'
|
|
|
|
sh 'mv acc.csv ./results/acc.csv'
|
|
|
|
} catch(err) {
|
2023-05-10 16:54:21 +02:00
|
|
|
echo("NOT FOUND previos acc artifacts")
|
2023-05-10 16:41:42 +02:00
|
|
|
// ignore error
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-05-10 14:47:19 +02:00
|
|
|
sh 'mkdir -p ./data/dataset'
|
|
|
|
sh 'mv -t ./data/dataset train.csv test.csv val.csv'
|
|
|
|
sh 'mv -t ./data True.csv Fake.csv'
|
2023-05-10 15:28:58 +02:00
|
|
|
sh 'mkdir -p ./results/'
|
2023-05-10 14:47:19 +02:00
|
|
|
sh 'mv model.pt ./results/model.pt'
|
|
|
|
}
|
2023-05-10 16:57:59 +02:00
|
|
|
stage("Docker: Running evaluation model")
|
2023-05-10 14:47:19 +02:00
|
|
|
{
|
|
|
|
sh 'mkdir -p ./.cache'
|
2023-05-10 17:06:48 +02:00
|
|
|
sh "echo ${currentBuild.number}"
|
2023-05-10 17:10:42 +02:00
|
|
|
sh "python ./src/main.py --test --build_id=${currentBuild.number} "
|
2023-05-10 17:39:23 +02:00
|
|
|
sh "cat results/acc.csv"
|
2023-05-10 16:41:42 +02:00
|
|
|
sh 'python ./src/plot.py '
|
2023-05-10 14:47:19 +02:00
|
|
|
sh "cp ./results/*.csv ${WORKSPACE}"
|
2023-05-10 16:41:42 +02:00
|
|
|
sh "cp ./results/*.png ${WORKSPACE}"
|
2023-05-10 14:47:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Saving artefacts') {
|
|
|
|
echo 'Goodbye!'
|
|
|
|
sh 'ls'
|
2023-05-10 18:12:59 +02:00
|
|
|
archiveArtifacts artifacts: '*.csv, *.png'
|
2023-05-10 14:47:19 +02:00
|
|
|
}
|
|
|
|
}
|