This commit is contained in:
Anna Nowak 2021-05-24 01:40:00 +02:00
parent c7bba29b1a
commit ced9c9dc25
3 changed files with 52 additions and 1 deletions

View File

@ -10,4 +10,5 @@ COPY ["Zadanie 1.py", "."]
COPY ["stats.py", "."]
COPY ["train.py", "."]
COPY ["evaluate.py", "."]
COPY ["MLProject", "."]
COPY ["MLProject", "."]
COPY ["try_model.py", "."]

40
Jenkinsfile-trymodel Normal file
View File

@ -0,0 +1,40 @@
pipeline {
agent {
docker { image 'adnovac/ium_s434760:4' }
}
parameters{
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'WHICH_BUILD'
)
string(
defaultValue: '',
description: 'json input',
name: 'json_input'
)
}
stages {
stage('copy artifacts')
{
steps
{
copyArtifacts(fingerprintArtifacts: true, projectName: 's434788-training', selector: buildParameter('WHICH_BUILD'))
}
}
stage('test')
{
steps
{
catchError {
sh 'python3.8 try_model.py'
}
}
}
stage('archive artifacts') {
steps {
archiveArtifacts 'result.txt'
}
}
}
}

10
try_model.py Normal file
View File

@ -0,0 +1,10 @@
import mlflow
import pandas as pd
import json
model = mlflow.keras.load_model("my_model")
with open('my_model/input_example.json') as json_file:
data = json.load(json_file)
with open('result.txt', 'w+', encoding="UTF-8") as f:
f.write(str(model.predict([data["inputs"]])))