add parameter

This commit is contained in:
Alicja Szulecka 2024-04-29 21:21:21 +02:00
parent ac93029123
commit f883cd5e17
2 changed files with 6 additions and 4 deletions

5
Jenkinsfile vendored
View File

@ -1,11 +1,13 @@
pipeline { pipeline {
agent any agent any
}
parameters { parameters {
buildSelector ( buildSelector (
defaultSelector: lastSuccessful(), defaultSelector: lastSuccessful(),
description: 'Build for copying artifacts', description: 'Build for copying artifacts',
name: 'BUILD_SELECTOR' name: 'BUILD_SELECTOR'
) )
string(name: 'EPOCHS', defaultValue: '10', description: 'epochs')
} }
stages { stages {
stage('Git Checkout') { stage('Git Checkout') {
@ -23,11 +25,10 @@ pipeline {
script { script {
def customImage = docker.build("custom-image") def customImage = docker.build("custom-image")
customImage.inside { customImage.inside {
sh 'python3 ./model.py' sh 'python3 ./model.py ${params.EPOCHS}'
archiveArtifacts artifacts: 'model.pth, predictions.txt', onlyIfSuccessful: true archiveArtifacts artifacts: 'model.pth, predictions.txt', onlyIfSuccessful: true
} }
} }
} }
} }
} }
}

View File

@ -6,6 +6,7 @@ import pandas as pd
from sklearn.model_selection import train_test_split from sklearn.model_selection import train_test_split
from sklearn.preprocessing import LabelEncoder from sklearn.preprocessing import LabelEncoder
import torch.nn.functional as F import torch.nn.functional as F
import os
device = ( device = (
@ -59,7 +60,7 @@ def main():
val_loader = DataLoader(list(zip(X_val, y_val)), batch_size=64) val_loader = DataLoader(list(zip(X_val, y_val)), batch_size=64)
# Training loop # Training loop
epochs = 10 epochs = os.getenv("EPOCHS")
for epoch in range(epochs): for epoch in range(epochs):
model.train() # Set model to training mode model.train() # Set model to training mode
running_loss = 0.0 running_loss = 0.0