diff --git a/Jenkinsfile_coop b/Jenkinsfile_coop index 24e45dc..6a79f2a 100644 --- a/Jenkinsfile_coop +++ b/Jenkinsfile_coop @@ -6,12 +6,24 @@ pipeline { description: 'Last successfull artifact', name: 'BUILD_SELECTOR' ) + string( + defaultValue: 'input_example.json', + description: 'Input name', + name: 'INPUT_NAME', + trim: false + ) } stages { - stage('copyArtifacts') { + stage('Copy model artifacts from s426206') { steps { - copyArtifacts fingerprintArtifacts: true, projectName: 's434705-training/master', selector: buildParameter('BUILD_SELECTOR') + copyArtifacts fingerprintArtifacts: true, projectName: 's426206-training/master', selector: buildParameter('BUILD_SELECTOR') } } + stage('Run prediction') { + steps { + sh 'python3 mlflow_prediction.py $INPUT_NAME' + } + } + } } \ No newline at end of file diff --git a/mlflow_prediction.py b/mlflow_prediction.py new file mode 100644 index 0000000..8ddb490 --- /dev/null +++ b/mlflow_prediction.py @@ -0,0 +1,18 @@ + +import json +import mlflow +import pandas as pd + +import sys + +arguments = sys.argv[1:] + +input = str(arguments[0]) + +model = mlflow.keras.load_model("my_model") + +with open('my_model/{input}', 'r') as file: + json_data = json.load(file)['inputs'] + +data_into_dict = {idx:x for idx, x in enumerate(json_data)} +print(model.predict(pd.DataFrame([data_into_dict]))) \ No newline at end of file