From 0f002cf09726a54aa21446503b000a6f53a04ba4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20D=C5=82uski?= Date: Sun, 23 Aug 2020 14:48:38 +0200 Subject: [PATCH] dev commit --- another/Dockerfile | 24 ++++++++++++++++++++++ another/scripts/run.sh | 7 +++++++ docker-compose.yml | 35 +++++++++++++++++++++++++++++++++ Dockerfile => mlflow/Dockerfile | 2 -- quickstart/mlflow_tracking.py | 26 +++++++++++++----------- test.sh | 3 +++ 6 files changed, 83 insertions(+), 14 deletions(-) create mode 100644 another/Dockerfile create mode 100644 another/scripts/run.sh create mode 100644 docker-compose.yml rename Dockerfile => mlflow/Dockerfile (59%) create mode 100644 test.sh diff --git a/another/Dockerfile b/another/Dockerfile new file mode 100644 index 0000000..d951020 --- /dev/null +++ b/another/Dockerfile @@ -0,0 +1,24 @@ +FROM python:3.7.0 +LABEL maintainer="Albert Franzi" + +ENV MLFLOW_HOME /opt/mlflow +ENV SERVER_PORT 5000 +ENV SERVER_HOST 0.0.0.0 +ENV FILE_STORE ${MLFLOW_HOME}/fileStore +ENV ARTIFACT_STORE ${MLFLOW_HOME}/artifactStore + +RUN pip install mlflow && \ + mkdir -p ${MLFLOW_HOME}/scripts && \ + mkdir -p ${FILE_STORE} && \ + mkdir -p ${ARTIFACT_STORE} + +COPY scripts/run.sh ${MLFLOW_HOME}/scripts/run.sh +RUN chmod +x ${MLFLOW_HOME}/scripts/run.sh + +EXPOSE ${SERVER_PORT}/tcp + +VOLUME ["${MLFLOW_HOME}/scripts/", "${FILE_STORE}", "${ARTIFACT_STORE}"] + +WORKDIR ${MLFLOW_HOME} + +ENTRYPOINT ["./scripts/run.sh"] diff --git a/another/scripts/run.sh b/another/scripts/run.sh new file mode 100644 index 0000000..68c4c09 --- /dev/null +++ b/another/scripts/run.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +mlflow server \ + --file-store $FILE_STORE \ + --default-artifact-root $ARTIFACT_STORE \ + --host $SERVER_HOST \ + --port $SERVER_PORT diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b9a462d --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,35 @@ +version: '3' +services: + sftp: + image: atmoz/sftp + #volumes: + # - /upload:/home/foo/upload + ports: + - "2222:22" + command: ftpuser:ftppass:::0 + networks: + - A + database: + container_name: pg_mlflow + image: postgres:13 + environment: + - POSTGRES_USER=pgsql + - POSTGRES_PASSWORD=pg_password + - POSTGRES_DB=mlflow + networks: + - A + tracker: + container_name: tracker_mlflow + image: tracker_ml + build: + context: ./mlflow + dockerfile: Dockerfile + ports: + - "5000:5000" + networks: + - A + + entrypoint: mlflow server --default-artifact-root sftp://ftpuser:ftppass@localhost:2222 -h 0.0.0.0 +networks: + A: + driver: bridge \ No newline at end of file diff --git a/Dockerfile b/mlflow/Dockerfile similarity index 59% rename from Dockerfile rename to mlflow/Dockerfile index ff73c0b..e2ca90a 100644 --- a/Dockerfile +++ b/mlflow/Dockerfile @@ -1,7 +1,5 @@ FROM continuumio/miniconda3:latest -MAINTAINER JianKai Wang "https://jiankaiwang.no-ip.biz" - ADD . /app WORKDIR /app diff --git a/quickstart/mlflow_tracking.py b/quickstart/mlflow_tracking.py index 6e0abb1..386a2d8 100644 --- a/quickstart/mlflow_tracking.py +++ b/quickstart/mlflow_tracking.py @@ -1,20 +1,22 @@ import os from random import random, randint -from mlflow import log_metric, log_param, log_artifacts +from mlflow import mlflow,log_metric, log_param, log_artifacts if __name__ == "__main__": - print("Running mlflow_tracking.py") + with mlflow.start_run() as run: + mlflow.set_tracking_uri('http://localhost:5000') + print("Running mlflow_tracking.py") - log_param("param1", randint(0, 100)) - - log_metric("foo", random()) - log_metric("foo", random() + 1) - log_metric("foo", random() + 2) + log_param("param1", randint(0, 100)) + + log_metric("foo", random()) + log_metric("foo", random() + 1) + log_metric("foo", random() + 2) - if not os.path.exists("outputs"): - os.makedirs("outputs") - with open("outputs/test.txt", "w") as f: - f.write("hello world!") + if not os.path.exists("outputs"): + os.makedirs("outputs") + with open("outputs/test.txt", "w") as f: + f.write("hello world!") - log_artifacts("outputs") + log_artifacts("outputs") diff --git a/test.sh b/test.sh new file mode 100644 index 0000000..a7a5edf --- /dev/null +++ b/test.sh @@ -0,0 +1,3 @@ +#!/bin/bash +export MLFLOW_TRACKING_UI=http://localhost:5000 +mlflow run git@github.com:databricks/mlflow-example.git -P alpha=0.5 --no-conda \ No newline at end of file