From cfab6beb44fbc1322ffcc55b510f613afc39b276 Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Wed, 11 May 2022 20:50:59 +0200 Subject: [PATCH] Add from-registry job --- Jenkinsfile-predict-s444356-from-registry | 16 ++++++++++++++++ predict_s444356-from-registry.py | 14 ++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 Jenkinsfile-predict-s444356-from-registry create mode 100644 predict_s444356-from-registry.py diff --git a/Jenkinsfile-predict-s444356-from-registry b/Jenkinsfile-predict-s444356-from-registry new file mode 100644 index 0000000..595246d --- /dev/null +++ b/Jenkinsfile-predict-s444356-from-registry @@ -0,0 +1,16 @@ +pipeline { + agent { + docker { + image 's444409-create-dataset' + args '-v /mlruns:/mlruns' + } + } + + stages { + stage('Predict values using model from artifact') { + steps { + sh "python predict_s444356-from-registry.py" + } + } + } +} diff --git a/predict_s444356-from-registry.py b/predict_s444356-from-registry.py new file mode 100644 index 0000000..70214ee --- /dev/null +++ b/predict_s444356-from-registry.py @@ -0,0 +1,14 @@ +import json +import mlflow +import numpy as np + +logged_model = '/mlruns/13/da5c6167bb45403fa35569849a1fbc13/artifacts/model' +loaded_model = mlflow.pyfunc.load_model(logged_model) + + +with open(f'{logged_model}/input_example.json') as f: + data = json.load(f) + input_example = np.array([data['inputs'][0]], dtype=np.float64).reshape(-1, 2) + + +print(f'Prediction: {loaded_model.predict(input_example)}')