From 87bcdc7d4c1a6e34b3f410aa2be4608757e0972c Mon Sep 17 00:00:00 2001 From: s444417 Date: Sun, 15 May 2022 10:37:28 +0200 Subject: [PATCH] prediction registry --- lab8/Jenkinsfile.mlflow | 16 ++++++++++++++++ lab8/predictMlflow.py | 15 +++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 lab8/Jenkinsfile.mlflow create mode 100644 lab8/predictMlflow.py diff --git a/lab8/Jenkinsfile.mlflow b/lab8/Jenkinsfile.mlflow new file mode 100644 index 0000000..56e7bb7 --- /dev/null +++ b/lab8/Jenkinsfile.mlflow @@ -0,0 +1,16 @@ +pipeline { + agent { + docker { + image 'mikolajk/ium:latest' + args '-v /mlruns:/mlruns' + } + } + stages { + stage('Stage') { + steps { + sh 'cd lab8' + sh "python predictMlflow.py" + } + } + } +} \ No newline at end of file diff --git a/lab8/predictMlflow.py b/lab8/predictMlflow.py new file mode 100644 index 0000000..fe17266 --- /dev/null +++ b/lab8/predictMlflow.py @@ -0,0 +1,15 @@ +import mlflow +import numpy as np +import json + +logged_model = '/mlruns/14/80fe21a0804844088147d15a3cebb3e5/artifacts/lego-model' + +# Load model as a PyFuncModel. +loaded_model = mlflow.pyfunc.load_model(logged_model) + +with open(f'{loaded_model}/input_example.json') as f: + input_example_data = json.load(f) + + # Predictions + print(f'input: {input_example_data}') + print(f'predictions: {loaded_model.predict(input_example_data)}') \ No newline at end of file