update predict.py, jenkinsfile_predict
Some checks reported errors
s444356-evaluation/pipeline/head This commit looks good
s444356-training/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
Maciej Czajka 2022-05-11 19:33:00 +02:00
parent c3e2d8ed56
commit 5e9ae0997a
2 changed files with 14 additions and 8 deletions

View File

@ -4,13 +4,20 @@ pipeline {
image 'maciejczajka' image 'maciejczajka'
} }
} }
parameters {
string(
defaultValue: 'input_example.json',
description: 'Input file name',
name: 'INPUT',
trim: false
)
}
stages { stages {
stage('Script') { stage('Script') {
steps { steps {
copyArtifacts projectName: 's444409-training/main', selector: lastSuccessful() copyArtifacts projectName: 's444409-training/main', selector: lastSuccessful()
sh 'ls -al' sh "python predict.py $INPUT"
sh "python predict.py"
} }
} }
} }

View File

@ -2,14 +2,13 @@ import json
import mlflow import mlflow
import pandas as pd import pandas as pd
input = sys.argv[1]
logged_model = 'mlruns/1/fa3e620f03e64d888c364827907fb6f5/artifacts/s444409' logged_model = 'mlruns/1/fa3e620f03e64d888c364827907fb6f5/artifacts/s444409'
logged_model2 = 'mlruns/1/fa3e620f03e64d888c364827907fb6f5/artifacts/s444409/data/model.pth' loaded_model = mlflow.pyfunc.load_model(logged_model)
loaded_model = mlflow.pyfunc.load_model(logged_model2)
with open(f'{logged_model}/input_example.json') as f: with open(f'{logged_model}/'+input) as f:
data = json.load(f) data = json.load(f)
input_example = pd.DataFrame(data['inputs'][0])
loaded_model.predict(data['inputs'])
loaded_model.predict(input_example)