mlflow attempt task 2 prediction
This commit is contained in:
parent
7ab7456488
commit
eb7d9635b5
@ -18,6 +18,7 @@ RUN pip3 install sklearn
|
||||
RUN pip3 install pymongo
|
||||
RUN pip3 install sacred
|
||||
RUN pip3 install mlflow
|
||||
RUN pip3 install tarfile
|
||||
|
||||
CMD python3 data_expl.py
|
||||
CMD python3 nn_train.py
|
41
Jenkinsfile_pred
Normal file
41
Jenkinsfile_pred
Normal file
@ -0,0 +1,41 @@
|
||||
pipeline {
|
||||
agent {
|
||||
dockerfile true
|
||||
}
|
||||
parameters {
|
||||
buildSelector(
|
||||
defaultSelector: lastSuccessful(),
|
||||
description: 'Which build to use for copying artifacts',
|
||||
name: 'BUILD_SELECTOR'
|
||||
)
|
||||
string(
|
||||
defaultValue: 'input_example.json',
|
||||
description: 'Input file name',
|
||||
name: 'INPUT_FILE_NAME',
|
||||
trim: false
|
||||
)
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Stage 1') {
|
||||
steps {
|
||||
echo 'Hello world!'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Copy from different Pipeline') {
|
||||
steps {
|
||||
copyArtifacts fingerprintArtifacts: false, projectName: 's449288-training/master', selector: buildParameter('BUILD_SELECTOR')
|
||||
}
|
||||
}
|
||||
|
||||
stage('Prediction') {
|
||||
steps {
|
||||
sh 'python3 predict.py $INPUT_FILE_NAME'
|
||||
sh 'rm -r ml'
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
18
predict.py
Normal file
18
predict.py
Normal file
@ -0,0 +1,18 @@
|
||||
import json
|
||||
import mlflow
|
||||
import numpy as np
|
||||
import sys
|
||||
import tarfile
|
||||
|
||||
file = tarfile.open('mlruns.tar.gz')
|
||||
file.extractall('./ml')
|
||||
|
||||
input = str((sys.argv[1:])[0])
|
||||
PATH = "ml/mlruns/1/f65f936936024133a2c03e1e486ba9cf/artifacts/model/"
|
||||
model = mlflow.pytorch.load_model(f"{PATH}/MLmodel")
|
||||
|
||||
with open(f'[PATH]/{input}', 'r') as file:
|
||||
json_data = json.load(file)
|
||||
|
||||
print(f"Input: {json_data['inputs'][0]}")
|
||||
print(f"Prediction: {model.predict(np.array([json_data['inputs'][0]], dtype=np.float32))}")
|
Loading…
Reference in New Issue
Block a user