Add mlflow prediction
Some checks failed
s434704-predict-s426206/pipeline/head There was a failure building this commit
Some checks failed
s434704-predict-s426206/pipeline/head There was a failure building this commit
This commit is contained in:
parent
c96da734b1
commit
d701d365ec
@ -6,12 +6,24 @@ pipeline {
|
|||||||
description: 'Last successfull artifact',
|
description: 'Last successfull artifact',
|
||||||
name: 'BUILD_SELECTOR'
|
name: 'BUILD_SELECTOR'
|
||||||
)
|
)
|
||||||
|
string(
|
||||||
|
defaultValue: 'input_example.json',
|
||||||
|
description: 'Input name',
|
||||||
|
name: 'INPUT_NAME',
|
||||||
|
trim: false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
stages {
|
stages {
|
||||||
stage('copyArtifacts') {
|
stage('Copy model artifacts from s426206') {
|
||||||
steps {
|
steps {
|
||||||
copyArtifacts fingerprintArtifacts: true, projectName: 's434705-training/master', selector: buildParameter('BUILD_SELECTOR')
|
copyArtifacts fingerprintArtifacts: true, projectName: 's426206-training/master', selector: buildParameter('BUILD_SELECTOR')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
stage('Run prediction') {
|
||||||
|
steps {
|
||||||
|
sh 'python3 mlflow_prediction.py $INPUT_NAME'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
18
mlflow_prediction.py
Normal file
18
mlflow_prediction.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
import json
|
||||||
|
import mlflow
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
arguments = sys.argv[1:]
|
||||||
|
|
||||||
|
input = str(arguments[0])
|
||||||
|
|
||||||
|
model = mlflow.keras.load_model("my_model")
|
||||||
|
|
||||||
|
with open('my_model/{input}', 'r') as file:
|
||||||
|
json_data = json.load(file)['inputs']
|
||||||
|
|
||||||
|
data_into_dict = {idx:x for idx, x in enumerate(json_data)}
|
||||||
|
print(model.predict(pd.DataFrame([data_into_dict])))
|
Loading…
Reference in New Issue
Block a user