Add model fetching from mlflow registry
Some checks failed
s434704-predict-s426206-from-registry/pipeline/head There was a failure building this commit
Some checks failed
s434704-predict-s426206-from-registry/pipeline/head There was a failure building this commit
This commit is contained in:
parent
8c94666b25
commit
b3e254c3a5
19
Jenkinsfile_coop_registry
Normal file
19
Jenkinsfile_coop_registry
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
pipeline {
|
||||||
|
agent {dockerfile true, args '-v /tmp/mlruns:/tmp/mlruns'}
|
||||||
|
parameters {
|
||||||
|
string(
|
||||||
|
defaultValue: 'input_example.json',
|
||||||
|
description: 'Input name',
|
||||||
|
name: 'INPUT_NAME',
|
||||||
|
trim: false
|
||||||
|
)
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage('Load model and run prediction') {
|
||||||
|
steps {
|
||||||
|
sh 'python3 mlflow_prediction_registry.py $INPUT_NAME'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
28
mlflow_prediction_registry.py
Normal file
28
mlflow_prediction_registry.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
import json
|
||||||
|
import mlflow
|
||||||
|
from mlflow.tracking import MlflowClient
|
||||||
|
import mlflow.pyfunc
|
||||||
|
import torch
|
||||||
|
import numpy as np
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
arguments = sys.argv[1:]
|
||||||
|
|
||||||
|
mlflow.set_tracking_uri("http://172.17.0.1:5000")
|
||||||
|
client = MlflowClient()
|
||||||
|
version = 1
|
||||||
|
model_name = "s434704"
|
||||||
|
|
||||||
|
input = str(arguments[0])
|
||||||
|
|
||||||
|
model = mlflow.pyfunc.load_model(
|
||||||
|
model_uri=f"models:/{model_name}/{model_version}"
|
||||||
|
)
|
||||||
|
|
||||||
|
with open(f'{model_name}/{input}', 'r') as file:
|
||||||
|
json_data = json.load(file)
|
||||||
|
|
||||||
|
print(model(torch.tensor(np.array(json_data['inputs'])).float()))
|
Loading…
Reference in New Issue
Block a user