update registry.py, jenkinsfile_registry
This commit is contained in:
parent
defc9740dd
commit
e45315a8ed
@ -1,20 +1,13 @@
|
|||||||
pipeline {
|
pipeline {
|
||||||
agent {
|
agent {
|
||||||
dockerfile {
|
image 'maciejczajka'
|
||||||
additionalBuildArgs "--build-arg KAGGLE_USERNAME=${params.KAGGLE_USERNAME} --build-arg KAGGLE_KEY=${params.KAGGLE_KEY} --build-arg CUTOFF=${params.CUTOFF} -t maciejczajka"
|
args '-v /mlruns:/mlruns'
|
||||||
}
|
|
||||||
}
|
|
||||||
parameters {
|
|
||||||
buildSelector(
|
|
||||||
defaultSelector: lastSuccessful(),
|
|
||||||
description: 'Which build to use for copying artifacts for predict',
|
|
||||||
name: 'BUILD_SELECTOR')
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Script') {
|
stage('Script') {
|
||||||
steps {
|
steps {
|
||||||
copyArtifacts projectName: 's444409-training/main', selector: buildParameter('BUILD_SELECTOR')
|
copyArtifacts projectName: 's444409-training/main'
|
||||||
sh 'python3 ./registry.py'
|
sh 'python3 ./registry.py'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,15 @@
|
|||||||
import mlflow
|
import mlflow
|
||||||
|
import json
|
||||||
|
import numpy as np
|
||||||
logged_model = '/mlruns/12/1c2b9737c0204b0ca825811c35fb6c64/artifacts/s444409'
|
logged_model = '/mlruns/12/1c2b9737c0204b0ca825811c35fb6c64/artifacts/s444409'
|
||||||
|
|
||||||
# Load model as a PyFuncModel.
|
# Load model as a PyFuncModel.
|
||||||
loaded_model = mlflow.pyfunc.load_model(logged_model)
|
loaded_model = mlflow.pyfunc.load_model(logged_model)
|
||||||
|
|
||||||
|
with open(f'{logged_model}/input_example.json') as f:
|
||||||
|
data = json.load(f)
|
||||||
|
input_example = np.array([data['inputs'][0]], dtype=np.float32)
|
||||||
|
|
||||||
# Predict on a Pandas DataFrame.
|
# Predict on a Pandas DataFrame.
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
print(f'Prediction: {loaded_model.predict(pd.DataFrame(data))}')
|
print(f'Prediction: {loaded_model.predict(input_example)}')
|
Loading…
Reference in New Issue
Block a user