feat: add jenkins for evaluate pipeline, create saving accuracy in file
This commit is contained in:
parent
7df11da81d
commit
d66f44a3dc
84
Jenkinsfile-eval
Normal file
84
Jenkinsfile-eval
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
node {
|
||||||
|
stage('Preparation') {
|
||||||
|
properties([
|
||||||
|
pipelineTriggers([
|
||||||
|
// TODO change auto run after train
|
||||||
|
upstream(
|
||||||
|
threshold: hudson.model.Result.SUCCESS,
|
||||||
|
upstreamProjects: 's424714-create-dataset'
|
||||||
|
)
|
||||||
|
]),
|
||||||
|
copyArtifactPermission('*'),
|
||||||
|
parameters([
|
||||||
|
buildSelector(
|
||||||
|
defaultSelector: lastSuccessful(),
|
||||||
|
description: 'Which build to use for copying artifacts',
|
||||||
|
name: 'BUILD_SELECTOR'
|
||||||
|
),
|
||||||
|
|
||||||
|
])
|
||||||
|
])
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
// copyArtifacts fingerprintArtifacts: true, projectName: 's424714-create-dataset', selector: buildParameter('BUILD_SELECTOR')
|
||||||
|
|
||||||
|
def dockerImage = docker.build("s424714-model")
|
||||||
|
|
||||||
|
dockerImage.inside {
|
||||||
|
withEnv(["TRANSFORMERS_CACHE=./.cache"]) {
|
||||||
|
stage("Docker: cloning artifacts"){
|
||||||
|
sh 'mkdir -p ./data/dataset'
|
||||||
|
sh 'mv -t ./data/dataset train.csv test.csv val.csv'
|
||||||
|
sh 'mv -t ./data True.csv Fake.csv'
|
||||||
|
sh 'mv model.pt ./results/model.pt'
|
||||||
|
}
|
||||||
|
stage("Docker: Running training model")
|
||||||
|
{
|
||||||
|
sh 'mkdir -p ./.cache'
|
||||||
|
// sh ""
|
||||||
|
sh 'python ./src/main.py --test '
|
||||||
|
sh "cp ./results/*.csv ${WORKSPACE}"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
stage('Saving artefacts') {
|
||||||
|
echo 'Goodbye!'
|
||||||
|
sh 'ls'
|
||||||
|
archiveArtifacts artifacts: '*.csv'
|
||||||
|
}
|
||||||
|
stage('Drawing plot') {
|
||||||
|
plot csvFileName: 'plot-accuracy.csv',
|
||||||
|
csvSeries: [[
|
||||||
|
file: 'acc.csv',
|
||||||
|
exclusionValues: '',
|
||||||
|
displayTableFlag: false,
|
||||||
|
inclusionFlag: 'OFF',
|
||||||
|
url: '']],
|
||||||
|
group: 'Plot Group',
|
||||||
|
title: 'Accuracy',
|
||||||
|
style: 'line',
|
||||||
|
exclZero: false,
|
||||||
|
keepRecords: false,
|
||||||
|
logarithmic: false,
|
||||||
|
numBuilds: '',
|
||||||
|
useDescr: false,
|
||||||
|
yaxis: '',
|
||||||
|
yaxisMaximum: '',
|
||||||
|
yaxisMinimum: ''
|
||||||
|
}
|
||||||
|
}
|
@ -44,5 +44,6 @@ def evaluate(
|
|||||||
results.extend(output.argmax(dim=1).tolist())
|
results.extend(output.argmax(dim=1).tolist())
|
||||||
total_acc_test += acc
|
total_acc_test += acc
|
||||||
|
|
||||||
print(f"Test Accuracy: {total_acc_test / len(test_data): .3f}")
|
accuracy = round(total_acc_test / len(test_data), 3)
|
||||||
return results
|
print(f"Test Accuracy: {accuracy: .3f}")
|
||||||
|
return results, accuracy
|
||||||
|
@ -75,9 +75,10 @@ if __name__ == "__main__":
|
|||||||
# evaluating model
|
# evaluating model
|
||||||
if args.test:
|
if args.test:
|
||||||
model = utils.load_model(model=BertClassifier(), model_path=args.model_path) # loading model from model.pt file
|
model = utils.load_model(model=BertClassifier(), model_path=args.model_path) # loading model from model.pt file
|
||||||
results = evaluate(
|
results, accuracy = evaluate(
|
||||||
model=model,
|
model=model,
|
||||||
test_data=test_data,
|
test_data=test_data,
|
||||||
batch_size=BATCH_SIZE,
|
batch_size=BATCH_SIZE,
|
||||||
)
|
)
|
||||||
utils.save_results(labels=test_data["label"], results=results, file_path=args.results_path)
|
utils.save_results(labels=test_data["label"], results=results, file_path=args.results_path)
|
||||||
|
utils.save_data_to_csv("./results/acc.csv", accuracy)
|
||||||
|
@ -32,3 +32,15 @@ class utils:
|
|||||||
|
|
||||||
df = pd.DataFrame({"labels": labels, "results": results})
|
df = pd.DataFrame({"labels": labels, "results": results})
|
||||||
df.to_csv(file_path, index=False)
|
df.to_csv(file_path, index=False)
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def save_data_to_csv(file_path: str, data: float) -> None:
|
||||||
|
file_path = Path(file_path)
|
||||||
|
|
||||||
|
df = pd.DataFrame([data])
|
||||||
|
df.to_csv(file_path, mode="a", header=False, index=False)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
x = 1.2
|
||||||
|
utils.save_data_to_csv("./results/eval.csv", x)
|
||||||
|
Loading…
Reference in New Issue
Block a user