Predict registry own model.
This commit is contained in:
parent
8934d2a07e
commit
5f572f039b
1
.gitignore
vendored
1
.gitignore
vendored
@ -8,3 +8,4 @@ my_runs
|
|||||||
mlruns
|
mlruns
|
||||||
my_model
|
my_model
|
||||||
1/
|
1/
|
||||||
|
mydb.sqlite
|
@ -1,9 +1,5 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent any
|
agent any
|
||||||
// triggers {
|
|
||||||
// upstream(upstreamProjects: "s426206-train/master",
|
|
||||||
// threshold: hudson.model.Result.SUCCESS)
|
|
||||||
// }
|
|
||||||
parameters {
|
parameters {
|
||||||
buildSelector(
|
buildSelector(
|
||||||
defaultSelector: lastSuccessful(),
|
defaultSelector: lastSuccessful(),
|
||||||
|
26
Jenkinsfile_predict_registry
Normal file
26
Jenkinsfile_predict_registry
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
stages {
|
||||||
|
stage('checkout') {
|
||||||
|
steps {
|
||||||
|
checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[url: 'https://git.wmi.amu.edu.pl/s426206/ium_426206.git']]])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('Copy artifact') {
|
||||||
|
steps {
|
||||||
|
copyArtifacts filter: 'my_model/input_example.json', fingerprintArtifacts: false, projectName: 's426206-training/master', selector: buildParameter('BUILD_SELECTOR_PREDICT')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage('docker') {
|
||||||
|
steps {
|
||||||
|
script {
|
||||||
|
def img = docker.build('rokoch/ium:01')
|
||||||
|
img.inside {
|
||||||
|
sh 'chmod +x mlflow_predict_registry.py'
|
||||||
|
sh 'python3 ./mlflow_predict_registry.py'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
mlflow_predict_registry.py
Normal file
24
mlflow_predict_registry.py
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import mlflow
|
||||||
|
import mlflow.pytorch
|
||||||
|
from mlflow.tracking import MlflowClient
|
||||||
|
import numpy as np
|
||||||
|
import torch
|
||||||
|
import json
|
||||||
|
|
||||||
|
#mlflow.set_tracking_uri("http://127.0.0.1:5000")
|
||||||
|
mlflow.set_tracking_uri("http://172.17.0.1:5000")
|
||||||
|
client = MlflowClient()
|
||||||
|
version = 0
|
||||||
|
model_name = "s426206"
|
||||||
|
for mv in client.search_model_versions("name='s426206'"):
|
||||||
|
if int(mv.version) > version:
|
||||||
|
version = int(mv.version)
|
||||||
|
|
||||||
|
model = mlflow.pytorch.load_model(
|
||||||
|
model_uri=f"models:/{model_name}/{version}"
|
||||||
|
)
|
||||||
|
|
||||||
|
with open('my_model/input_example.json') as json_file:
|
||||||
|
data = json.load(json_file)
|
||||||
|
#print(np.array(data['inputs']))
|
||||||
|
print(model(torch.tensor(np.array(data['inputs'])).float()))
|
Loading…
Reference in New Issue
Block a user