update predict.py, jenkinsfile_predict
This commit is contained in:
parent
c3e2d8ed56
commit
5e9ae0997a
@ -4,13 +4,20 @@ pipeline {
|
||||
image 'maciejczajka'
|
||||
}
|
||||
}
|
||||
parameters {
|
||||
string(
|
||||
defaultValue: 'input_example.json',
|
||||
description: 'Input file name',
|
||||
name: 'INPUT',
|
||||
trim: false
|
||||
)
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Script') {
|
||||
steps {
|
||||
copyArtifacts projectName: 's444409-training/main', selector: lastSuccessful()
|
||||
sh 'ls -al'
|
||||
sh "python predict.py"
|
||||
sh "python predict.py $INPUT"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
11
predict.py
11
predict.py
@ -2,14 +2,13 @@ import json
|
||||
import mlflow
|
||||
import pandas as pd
|
||||
|
||||
input = sys.argv[1]
|
||||
|
||||
logged_model = 'mlruns/1/fa3e620f03e64d888c364827907fb6f5/artifacts/s444409'
|
||||
logged_model2 = 'mlruns/1/fa3e620f03e64d888c364827907fb6f5/artifacts/s444409/data/model.pth'
|
||||
loaded_model = mlflow.pyfunc.load_model(logged_model2)
|
||||
loaded_model = mlflow.pyfunc.load_model(logged_model)
|
||||
|
||||
|
||||
with open(f'{logged_model}/input_example.json') as f:
|
||||
with open(f'{logged_model}/'+input) as f:
|
||||
data = json.load(f)
|
||||
input_example = pd.DataFrame(data['inputs'][0])
|
||||
|
||||
|
||||
loaded_model.predict(input_example)
|
||||
loaded_model.predict(data['inputs'])
|
Loading…
Reference in New Issue
Block a user