s444409 prediction

This commit is contained in:
Sebastian 2022-06-25 15:26:56 +02:00
parent 4b58a2aed8
commit fcc3a2474d
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,36 @@
pipeline {
agent {
docker {
image 'sebastianwalesa/ium:1.0'
}
}
parameters {
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts for predict',
name: 'BUILD_SELECTOR')
string(
defaultValue: '{\\"inputs\\": [900.0]}',
description: 'Input file',
name: 'INPUT',
trim: true
)
}
stages {
stage('Copy Artifacts') {
steps {
copyArtifacts projectName: 's444409-training/main', selector: buildParameter('BUILD_SELECTOR')
sh "echo ${params.INPUT} > input_example.json"
sh "python predict.py"
}
}
stage('Prediction') {
steps {
sh "echo ${params.INPUT} > input_example.json"
sh "python prediction-s444409.py"
}
}
}
}

16
prediction-s444409.py Normal file
View File

@ -0,0 +1,16 @@
import json
import mlflow
import sys
import numpy as np
#input = sys.argv[1]
logged_model = 'mlruns/1/70439eb482b54d56b54b0ecc6f1ca96f/artifacts/s444409'
loaded_model = mlflow.pyfunc.load_model(logged_model)
with open('input_example.json') as f:
data = json.load(f)
input_example = np.array([data['inputs'][0]], dtype=np.float32)
print(f'Prediction: {loaded_model.predict(input_example)}')