update predict.py, jenkinsfile_predict
This commit is contained in:
parent
c3e2d8ed56
commit
5e9ae0997a
@ -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"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
predict.py
11
predict.py
@ -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)
|
|
Loading…
Reference in New Issue
Block a user