From fbb9ac6a2694a5cf903a825ab8b3defbcb757496 Mon Sep 17 00:00:00 2001 From: Anna Nowak Date: Mon, 24 May 2021 01:48:11 +0200 Subject: [PATCH] =?UTF-8?q?Pr=C3=B3ba=20z=20pliku?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Jenkinsfile-trymodel | 7 +++---- try_model.py | 9 +++++++-- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Jenkinsfile-trymodel b/Jenkinsfile-trymodel index 5f93b2a..7d07a5f 100644 --- a/Jenkinsfile-trymodel +++ b/Jenkinsfile-trymodel @@ -1,6 +1,6 @@ pipeline { agent { - docker { image 'adnovac/ium_s434760:4' } + docker { image 'adnovac/ium_s434760:4.1' } } parameters{ buildSelector( @@ -20,15 +20,14 @@ pipeline { steps { copyArtifacts(fingerprintArtifacts: true, projectName: 's434788-training/mlflow', selector: buildParameter('WHICH_BUILD')) + sh "echo ${json_input} >> input.json" } } stage('test') { steps { - catchError { - sh 'python3.8 try_model.py' - } + sh 'python3.8 try_model.py' } } stage('archive artifacts') { diff --git a/try_model.py b/try_model.py index fc80bb7..8014433 100644 --- a/try_model.py +++ b/try_model.py @@ -3,8 +3,13 @@ import pandas as pd import json model = mlflow.keras.load_model("my_model") -with open('my_model/input_example.json') as json_file: - data = json.load(json_file) +data = None +try: + with open('input.json') as json_file: + data = json.load(json_file) +except: + with open('my_model/input_example.json') as json_file: + data = json.load(json_file) with open('result.txt', 'w+', encoding="UTF-8") as f: f.write(str(model.predict([data["inputs"]]))) \ No newline at end of file