From da4bd8e58c3239a5a0d325e645641257fa9d1e19 Mon Sep 17 00:00:00 2001 From: s444501 Date: Fri, 13 May 2022 03:21:39 +0200 Subject: [PATCH] mlflow --- s444356-reg.Jenkinsfile | 23 +++++++++++++++++++++++ s444356-reg.py | 12 ++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 s444356-reg.Jenkinsfile create mode 100644 s444356-reg.py diff --git a/s444356-reg.Jenkinsfile b/s444356-reg.Jenkinsfile new file mode 100644 index 0000000..f76693f --- /dev/null +++ b/s444356-reg.Jenkinsfile @@ -0,0 +1,23 @@ +pipeline { + agent { + docker { + image 'zadanie' + args '-v /mlruns:/mlruns' + } + } + parameters { + buildSelector( + defaultSelector: lastSuccessful(), + description: 'Which build to use for copying artifacts', + name: 'BUILD_SELECTOR' + ) + } + + stages { + stage('Prediction') { + steps { + sh 'python s444356-reg.py' + } + } + } +} \ No newline at end of file diff --git a/s444356-reg.py b/s444356-reg.py new file mode 100644 index 0000000..478ff79 --- /dev/null +++ b/s444356-reg.py @@ -0,0 +1,12 @@ +import json +import mlflow +import numpy as np + +path = '/mlruns/13/da5c6167bb45403fa35569849a1fbc13/artifacts/model' +model = mlflow.pyfunc.load_model(path) + +with open(f'{path}/input_example.json') as file: + data = json.load(file) + input_example = np.array([data['inputs']]).reshape(-1, 2) + print('Input:\n', input_example) + print('Predictions:\n', model.predict(input_example))