From e7cb37ad58faca3cc9d2d82ba5018c2f1b482817 Mon Sep 17 00:00:00 2001 From: Maciej Czajka Date: Wed, 11 May 2022 20:05:49 +0200 Subject: [PATCH] update predict.py, jenkinsfile_predict --- Jenkinsfile_predict | 2 +- predict.py | 25 ++++--------------------- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/Jenkinsfile_predict b/Jenkinsfile_predict index 3a8846c..e9dec85 100644 --- a/Jenkinsfile_predict +++ b/Jenkinsfile_predict @@ -16,7 +16,7 @@ pipeline { stages { stage('Script') { steps { - copyArtifacts projectName: 's444356-training/master', selector: lastSuccessful() + copyArtifacts projectName: 's444409-training/main', selector: lastSuccessful() sh 'python3 ./predict.py $INPUT' } } diff --git a/predict.py b/predict.py index 9f75883..3e03813 100644 --- a/predict.py +++ b/predict.py @@ -1,31 +1,14 @@ -#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 mlflow -import numpy as np +import sys input = sys.argv[1] -logged_model = 'mlruns/1/296d6f314bb2451885fb7ae58988301e/artifacts/model' +logged_model = 'mlruns/1/70439eb482b54d56b54b0ecc6f1ca96f/artifacts/s444409' loaded_model = mlflow.pyfunc.load_model(logged_model) -with open(f'{logged_model}/'+str(input)) as f: +with open(f'{logged_model}/'+input) 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)}') \ No newline at end of file +loaded_model.predict(data['inputs']) \ No newline at end of file