working on lab8

This commit is contained in:
Kacper 2022-05-14 13:03:16 +02:00
parent 88e235de42
commit 0559fd6038
6 changed files with 111 additions and 0 deletions

View File

@ -0,0 +1,32 @@
pipeline {
agent {
docker {
image 's449288/ium:lab8.1'
}
}
parameters {
string(
defaultValue: '{\\"inputs\\": [[]]}',
description: 'Input example in json format',
name: 'INPUT'
)
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'BUILD_SELECTOR'
)
}
stages {
stage('Stage 1') {
steps {
echo 'Copying model from s444417-training...'
copyArtifacts projectName: 's444417-training/master', selector: buildParameter('BUILD_SELECTOR')
echo 'Model copied'
echo 'Making a prediction...'
sh 'echo ${params.INPUT} > input_example.json'
sh 'python3 predict_s444356.py'
echo 'Prediction made'
}
}
}
}

View File

@ -0,0 +1,17 @@
pipeline {
agent {
docker {
image 's449288/ium:lab8.1'
args '-v /mlruns:/mlruns'
}
}
stages {
stage('Stage 1') {
steps {
echo 'Making a prediction with a model from experiment s444417...'
sh "python3 predict_registry.py"
echo 'Prediction made'
}
}
}
}

17
lab8/predict_artifact.py Normal file
View File

@ -0,0 +1,17 @@
import mlflow
import numpy as np
import json
artifact_path = 'mlruns/1//artifacts/model' #
model = mlflow.pyfunc.load_model(artifact_path) #
with open(f'{model}/input_example.json') as f:
input_example_data = json.load(f)
input_example = np.array() #
print(f'Input example: {input_example}')
print(f'Model prediction: {model.predict(input_example)}')

14
lab8/predict_registry.py Normal file
View File

@ -0,0 +1,14 @@
import mlflow
import numpy as np
import json
regsistry_path = '/mlruns/17/ /artifacts/model' #
model = mlflow.pyfunc.load_model(registry_path) #
with open(f'{model}/input_example.json') as f:
input_example_data = json.load(f)
input_example = np.array() #
print(f'Input example: {input_example}')
print(f'Model prediction: {model.predict(input_example)}')

17
predict_artifact.py Normal file
View File

@ -0,0 +1,17 @@
import mlflow
import numpy as np
import json
artifact_path = 'mlruns/1//artifacts/model' #
model = mlflow.pyfunc.load_model(artifact_path) #
with open(f'{model}/input_example.json') as f:
input_example_data = json.load(f)
input_example = np.array() #
print(f'Input example: {input_example}')
print(f'Model prediction: {model.predict(input_example)}')

14
predict_registry.py Normal file
View File

@ -0,0 +1,14 @@
import mlflow
import numpy as np
import json
regsistry_path = '/mlruns/17/ /artifacts/model' #
model = mlflow.pyfunc.load_model(registry_path) #
with open(f'{model}/input_example.json') as f:
input_example_data = json.load(f)
input_example = np.array() #
print(f'Input example: {input_example}')
print(f'Model prediction: {model.predict(input_example)}')