added model to registry, prediction on s434704
Some checks failed
s434742-training/pipeline/head There was a failure building this commit
s434742-evaluation/pipeline/head This commit looks good

This commit is contained in:
patrycjalazna 2021-05-23 23:01:50 +02:00
parent a788238e58
commit 00fcfd4d1c
3 changed files with 62 additions and 1 deletions

View File

@ -14,6 +14,7 @@ from tensorflow.keras.models import Model
from tensorflow.keras.callbacks import EarlyStopping
from keras.models import Sequential
import mlflow
from mlflow.tracking import MlflowClient
@ -62,6 +63,11 @@ def my_main(epochs, batch_size):
epochs = int(sys.argv[1]) if len(sys.argv) > 1 else 15
batch_size = int(sys.argv[2]) if len(sys.argv) > 2 else 16
mlflow.set_tracking_uri("http://172.17.0.1:5000")
mlflow.set_experiment("s434742")
client = MlflowClient()
with mlflow.start_run():
@ -71,4 +77,6 @@ with mlflow.start_run():
mlflow.log_param("batch_size", batch_size)
mlflow.log_metric("rmse", rmse)
#mlflow.keras.log_model(model, 'avocado_model.h5')
mlflow.keras.log_model(keras_model=model, path='avocado_model', signature=infer_signature(X_train, y_train), input_example=X_train.iloc[0])
mlflow.keras.log_model(keras_model=model, path='avocado_model', registered_model_name="s434742", signature=infer_signature(X_train, y_train), input_example=X_train.iloc[0])
mlflow.keras.save_model(keras_model=model, path='avocado_model', signature=infer_signature(X_train, y_train), input_example=X_train.iloc[0])

View File

@ -0,0 +1,40 @@
pipeline {
agent {
dockerfile true
}
parameters {
string(
defaultValue: 'input_example.json',
description: 'Input name',
name: 'INPUT_EXAMPLE',
trim: false
)
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts for predict',
name: 'BUILD_SELECTOR_s434704')
}
stages{
stage('copy artifacts from s434704') {
steps {
copyArtifacts filter: 'movies_on_streaming_platforms_model/**/*', fingerprintArtifacts: false, projectName: 's434704-training/master', selector: buildParameter('BUILD_SELECTOR_s434704')
}
}
stage('predict data from s434704') {
steps {
script {
sh 'chmod +x predict-s434704.py'
sh 'python3 predict-s434704.py $INPUT_EXAMPLE'
}
}
}
}
}

13
predict-s434704.py Normal file
View File

@ -0,0 +1,13 @@
import json
import sys
import mlflow
filename = sys.argv[1]
model = mlflow.keras.load_model("movies_on_streaming_platforms_model")
path = 'movies_on_streaming_platforms_model/' + filename
with open(path) as f:
data = json.load(f)
model.predict(data['inputs'])