From af6518f064caff812923751cf2d471b403f47341 Mon Sep 17 00:00:00 2001 From: Szymon Bartanowicz Date: Tue, 14 May 2024 19:21:17 +0200 Subject: [PATCH] 06-training --- Jenkinsfile | 39 ++++++++++++++++++++------------------- model.py | 4 +++- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 678883c..3fa2373 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,36 +1,37 @@ pipeline { agent any + triggers { + upstream(upstreamProjects: 'z-s464937-create-dataset', threshold: hudson.model.Result.SUCCESS) + } + parameters { - string(name: 'CUTOFF', defaultValue: '100', description: 'Ilość wierszy do odcięcia') - string(name: 'KAGGLE_USERNAME', defaultValue: '', description: 'Kaggle username') - password(name: 'KAGGLE_KEY', defaultValue: '', description: 'Kaggle API key') + string(name: 'EPOCHS', defaultValue: '10', description: 'Epochs') + buildSelector(defaultSelector: lastSuccessful(), description: 'Build no', name: 'BUILD_SELECTOR') } stages { - stage('Clone repo') { + stage('Clone Repository') { steps { - git branch: "main", url: "https://git.wmi.amu.edu.pl/s464937/ium_464937" + git branch: 'training', url: "https://git.wmi.amu.edu.pl/s464937/ium_464937.git" } } - - stage('Download and preprocess') { - environment { - KAGGLE_USERNAME = "szymonbartanowicz" - KAGGLE_KEY = "4692239eb65f20ec79f9a59ef30e67eb" - } + stage('Copy Artifacts') { steps { - withEnv([ - "KAGGLE_USERNAME=${env.KAGGLE_USERNAME}", - "KAGGLE_KEY=${env.KAGGLE_KEY}" - ]) { - sh "bash ./script1.sh ${params.CUTOFF}" - } + copyArtifacts filter: 'openpowerlifting.csv', projectName: 'z-s464937-create-dataset', selector: buildParameter('BUILD_SELECTOR') } } - stage('Archive') { + stage("Run") { + agent { + dockerfile { + filename 'Dockerfile' + reuseNode true + } + } steps { - archiveArtifacts artifacts: 'data/*', onlyIfSuccessful: true + sh "chmod +x ./model.py" + sh "python3 ./model.py ${params.EPOCHS}" + archiveArtifacts artifacts: 'powerlifting_model.h5', onlyIfSuccessful: true } } } diff --git a/model.py b/model.py index dad53bd..a7b1369 100644 --- a/model.py +++ b/model.py @@ -1,3 +1,5 @@ +import sys + import pandas as pd from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler, OneHotEncoder @@ -34,6 +36,6 @@ pipeline = Pipeline(steps=[ pipeline['model'].compile(optimizer='adam', loss='mse', metrics=['mae']) -pipeline.fit(X_train, y_train, model__epochs=10, model__validation_split=0.1) +pipeline.fit(X_train, y_train, model__epochs=int(sys.argv[1]), model__validation_split=0.1) pipeline['model'].save('powerlifting_model.h5')