update jenkinsfile_predict, predict.py
All checks were successful
s444356-evaluation/pipeline/head This commit looks good
s444356-training/pipeline/head This commit looks good

This commit is contained in:
Maciej Czajka 2022-05-11 19:59:53 +02:00
parent 245aa17202
commit 035b4245e6
2 changed files with 21 additions and 6 deletions

View File

@ -16,7 +16,7 @@ pipeline {
stages { stages {
stage('Script') { stage('Script') {
steps { steps {
copyArtifacts projectName: 's444409-training/main', selector: lastSuccessful() copyArtifacts projectName: 's444356-training/main', selector: lastSuccessful()
sh 'python3 ./predict.py $INPUT' sh 'python3 ./predict.py $INPUT'
} }
} }

View File

@ -1,14 +1,29 @@
#import json
#import mlflow
#import sys
#input = sys.argv[1]
#logged_model = 'mlruns/1/3630068c31924c05a9a04e70ef35e0b8/artifacts/s444409'
#loaded_model = mlflow.pyfunc.load_model(logged_model)
#with open(f'{logged_model}/'+input) as f:
# data = json.load(f)
#loaded_model.predict(data['inputs'])
import json import json
import mlflow import mlflow
import sys import numpy as np
input = sys.argv[1] logged_model = 'mlruns/1/296d6f314bb2451885fb7ae58988301e/artifacts/model'
logged_model = 'mlruns/1/3630068c31924c05a9a04e70ef35e0b8/artifacts/s444409'
loaded_model = mlflow.pyfunc.load_model(logged_model) loaded_model = mlflow.pyfunc.load_model(logged_model)
with open(f'{logged_model}/'+input) as f: with open(f'{logged_model}/'+input) as f:
data = json.load(f) data = json.load(f)
input_example = np.array([data['inputs'][0]], dtype=np.float64).reshape(-1, 2)
loaded_model.predict(data['inputs'])
print(f'Prediction: {loaded_model.predict(input_example)}')