MLFlow other models inference init
This commit is contained in:
parent
8ca9b73537
commit
b608875348
34
jenkins/predict_s444356.Jenkinsfile
Normal file
34
jenkins/predict_s444356.Jenkinsfile
Normal file
@ -0,0 +1,34 @@
|
||||
pipeline {
|
||||
agent {
|
||||
docker {
|
||||
image 's478841-image:latest'
|
||||
}
|
||||
}
|
||||
parameters {
|
||||
string(
|
||||
defaultValue: '{\\"inputs\\": [[0.76, 0.71], [0.6, 0.73], [0.75, 0.75], [0.91, 0.85]]}',
|
||||
description: 'Input data',
|
||||
name: 'INPUT',
|
||||
trim: true
|
||||
)
|
||||
buildSelector(
|
||||
defaultSelector: lastSuccessful(),
|
||||
description: 'Build used for artifacts copying',
|
||||
name: 'BUILD_SELECTOR'
|
||||
)
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Load artifacts') {
|
||||
steps {
|
||||
copyArtifacts projectName: 's444356-training/master', selector: buildParameter('BUILD_SELECTOR')
|
||||
}
|
||||
}
|
||||
stage('Predict using artifact') {
|
||||
steps {
|
||||
sh "echo ${params.INPUT} > scripts/input_example.json"
|
||||
sh 'python3 scripts/predict_s444356.py'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
jenkins/predict_s444356.registry.Jenkinsfile
Normal file
16
jenkins/predict_s444356.registry.Jenkinsfile
Normal file
@ -0,0 +1,16 @@
|
||||
pipeline {
|
||||
agent {
|
||||
docker {
|
||||
image 's478841-image:latest'
|
||||
args '-v /mlruns:/mlruns'
|
||||
}
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Predict using artifacts') {
|
||||
steps {
|
||||
sh 'python3 scripts/predict_s444356_registry.py'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
10
scripts/predict_s444356.py
Normal file
10
scripts/predict_s444356.py
Normal file
@ -0,0 +1,10 @@
|
||||
import mlflow
|
||||
import numpy as np
|
||||
import json
|
||||
|
||||
|
||||
model = mlflow.pyfunc.load_model(
|
||||
'mlruns/13/da5c6167bb45403fa35569849a1fbc13/artifacts/model')
|
||||
with open('input_example.json') as f:
|
||||
data = np.array([json.load(f)['inputs'][0]], dtype=np.float32)
|
||||
print(f"Predicted values: {model.predict(data.reshape(-1, 2))}")
|
10
scripts/predict_s444356_registry.py
Normal file
10
scripts/predict_s444356_registry.py
Normal file
@ -0,0 +1,10 @@
|
||||
import mlflow
|
||||
import numpy as np
|
||||
import json
|
||||
|
||||
|
||||
model = mlflow.pyfunc.load_model(
|
||||
'mlruns/13/da5c6167bb45403fa35569849a1fbc13/artifacts/model')
|
||||
with open('mlruns/13/da5c6167bb45403fa35569849a1fbc13/artifacts/model/input_example.json') as f:
|
||||
data = np.array([json.load(f)['inputs'][0]], dtype=np.float32)
|
||||
print(f"Predicted values: {model.predict(data.reshape(-1, 2))}")
|
Loading…
Reference in New Issue
Block a user