mlflow
All checks were successful
s444501-training/pipeline/head This commit looks good
s444501-evaluation/pipeline/head This commit looks good

This commit is contained in:
s444501 2022-05-13 02:39:21 +02:00
parent f8025ad3fc
commit 0f5edfcc26
3 changed files with 47 additions and 1 deletions

View File

@ -5,12 +5,12 @@ import mlflow
import torch
import torch.nn as nn
import torch.nn.functional as F
from mlflow.experiments import restore_experiment
from sklearn.preprocessing import LabelEncoder
import pandas as pd
# MLFlow
mlflow.set_tracking_uri("http://172.17.0.1:5000")
# Niechcący usunąłem eksperyment s444501 i nie mogę go przywrócić dlatego stworzyłem drugi bez literki 's' na początku
mlflow.set_experiment("444501")

34
s444356.Jenkinsfile Normal file
View File

@ -0,0 +1,34 @@
pipeline {
agent {
docker {
image 'zadanie'
args '-v /mlruns:/mlruns'
}
}
parameters {
string(
defaultValue: '{\\"inputs\\": [[0.51, 0.86], [0.79, 0.79], [0.74, 0.77], [0.66, 0.73], [0.79, 0.47]]}',
description: 'Input example',
name: 'INPUT'
)
buildSelector(
defaultSelector: lastSuccessful(),
description: 'Which build to use for copying artifacts',
name: 'BUILD_SELECTOR'
)
}
stages {
stage('Copy artifacts') {
steps {
copyArtifacts fingerprintArtifacts: true, projectName: 's444356-training/master', selector: buildParameter('BUILD_SELECTOR')
}
}
stage('Prediction') {
steps {
sh 'echo ${params.INPUT} > input_example.json'
sh 'python s444356.py'
}
}
}
}

12
s444356.py Normal file
View File

@ -0,0 +1,12 @@
import json
import mlflow
import numpy as np
model = mlflow.pyfunc.load_model('mlruns/1/4b83e774512444188fb587288818c298/artifacts/model')
with open('input_example.json') as file:
data = json.load(file)
input_example = np.array([data['inputs'][0]]).reshape(-1, 2)
print('Predictions:')
for pred in model.predict(input_example):
print(pred)