update jenkinsfile_train-sacred, dllib-mlflow
All checks were successful
s444356-evaluation/pipeline/head This commit looks good
s444356-training/pipeline/head This commit looks good

This commit is contained in:
Maciej Czajka 2022-05-11 16:26:16 +02:00
parent 4a3099ce3a
commit 8e09f6cff8
2 changed files with 22 additions and 2 deletions

View File

@ -1,9 +1,12 @@
from urllib.parse import urlparse
import numpy as np
import sys
import os
import torch
import mlflow
import pandas as pd
from mlflow.models import infer_signature
from torch import nn
from torch.autograd import Variable
from sklearn.model_selection import train_test_split
@ -17,7 +20,6 @@ from sacred.observers import MongoObserver
# EPOCHS = int(sys.argv[1])
#mlflow.set_tracking_uri("http://localhost:5000/#/")
mlflow.set_experiment("s444356")
class Model(nn.Module):
@ -298,6 +300,22 @@ def my_main(epochs):
x_train, y_train = Variable(torch.from_numpy(features_train_g)).float(), Variable(
torch.from_numpy(labels_train_g)).long()
input_example = features_train_g
siganture = infer_signature(features_train_g, labels_train_g)
# mlflow.set_tracking_uri("http://172.17.0.1:5000")
# mlflow.set_tracking_uri("http://172.17.0.1:5000/#/")
tracking_url_type_store = urlparse(mlflow.get_tracking_uri()).scheme
# print(tracking_url_type_store)
if tracking_url_type_store != "file":
mlflow.pytorch.log_model(model, "model", registered_model_name="s444356", signature=siganture,
input_example=input_example)
else:
mlflow.pytorch.log_model(model, "model", signature=siganture, input_example=input_example)
mlflow.pytorch.save_model(model, "my_model", signature=siganture, input_example=input_example)
for epoch in range(1, epochs + 1):
print("Epoch #", epoch)
y_pred = model(x_train)
@ -331,4 +349,4 @@ def my_main(epochs):
with mlflow.start_run() as run:
my_main(epochs)
my_main(epochs)

View File

@ -23,6 +23,8 @@ pipeline {
sh 'ls mlruns'
archiveArtifacts artifacts: 'mlruns/**'
sh 'rm -r mlruns'
archiveArtifacts artifacts: 'my_model/**'
sh 'rm -r my_model'
}
}
}