From fad30cde27c54090149956016c692cd9e6ceca38 Mon Sep 17 00:00:00 2001 From: Adam Wojdyla Date: Mon, 16 May 2022 09:03:45 +0200 Subject: [PATCH] predict from registry --- Jenkinsfile_predict_registry | 16 ++++++++++++++++ lab08_deepLearining_mlflow.py | 2 +- lab08_predict_from_registry.py | 14 ++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 Jenkinsfile_predict_registry create mode 100644 lab08_predict_from_registry.py diff --git a/Jenkinsfile_predict_registry b/Jenkinsfile_predict_registry new file mode 100644 index 0000000..e827103 --- /dev/null +++ b/Jenkinsfile_predict_registry @@ -0,0 +1,16 @@ +pipeline { + agent { + docker { + image 's444507-create-dataset' + args '-v /mlruns:/mlruns' + } + } + + stages { + stage('Predict values using model from artifact') { + steps { + sh "python3 predict_from_registry.py" + } + } + } +} \ No newline at end of file diff --git a/lab08_deepLearining_mlflow.py b/lab08_deepLearining_mlflow.py index 370f435..be84002 100644 --- a/lab08_deepLearining_mlflow.py +++ b/lab08_deepLearining_mlflow.py @@ -20,7 +20,7 @@ import mlflow.pytorch logging.basicConfig(level=logging.WARN) logger = logging.getLogger(__name__) -# mlflow.set_tracking_uri("http://localhost:5000/") +mlflow.set_tracking_uri("http://172.17.0.1:5000") mlflow.set_experiment("s444507") diff --git a/lab08_predict_from_registry.py b/lab08_predict_from_registry.py new file mode 100644 index 0000000..70214ee --- /dev/null +++ b/lab08_predict_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)}')