diff --git a/Jenkinsfile_predict b/Jenkinsfile_predict index d52e959..910aa34 100644 --- a/Jenkinsfile_predict +++ b/Jenkinsfile_predict @@ -4,13 +4,20 @@ pipeline { image 'maciejczajka' } } + parameters { + string( + defaultValue: 'input_example.json', + description: 'Input file name', + name: 'INPUT', + trim: false + ) + } stages { stage('Script') { steps { copyArtifacts projectName: 's444409-training/main', selector: lastSuccessful() - sh 'ls -al' - sh "python predict.py" + sh "python predict.py $INPUT" } } } diff --git a/predict.py b/predict.py index fc14ee0..760b4ca 100644 --- a/predict.py +++ b/predict.py @@ -2,14 +2,13 @@ import json import mlflow import pandas as pd +input = sys.argv[1] + logged_model = 'mlruns/1/fa3e620f03e64d888c364827907fb6f5/artifacts/s444409' -logged_model2 = 'mlruns/1/fa3e620f03e64d888c364827907fb6f5/artifacts/s444409/data/model.pth' -loaded_model = mlflow.pyfunc.load_model(logged_model2) +loaded_model = mlflow.pyfunc.load_model(logged_model) -with open(f'{logged_model}/input_example.json') as f: +with open(f'{logged_model}/'+input) as f: data = json.load(f) - input_example = pd.DataFrame(data['inputs'][0]) - -loaded_model.predict(input_example) \ No newline at end of file +loaded_model.predict(data['inputs']) \ No newline at end of file