From bca471fe3dca4b3eec42d7746e2bb21da5fbd84b Mon Sep 17 00:00:00 2001 From: Narek Amirbekian Date: Thu, 6 Oct 2022 10:06:04 -0700 Subject: [PATCH] Add changes for minikube --- .gitignore | 3 +++ .gitmodules | 3 +++ docker-compose.development.yml | 13 +++++++++ local-example/README.md | 23 ++++++++++++++++ local-example/helloworld.py | 43 ++++++++++++++++++++++++++++++ local-example/metaflow-config.json | 8 ++++++ local-example/run_services.sh | 23 ++++++++++++++++ metaflow-ui | 1 + 8 files changed, 117 insertions(+) create mode 100644 .gitmodules create mode 100644 local-example/README.md create mode 100755 local-example/helloworld.py create mode 100644 local-example/metaflow-config.json create mode 100644 local-example/run_services.sh create mode 160000 metaflow-ui diff --git a/.gitignore b/.gitignore index 0cc624223..9e3d7b0bd 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ __pycache__/ # jetbrains .idea + +# Metaf;ow +.metaflow \ No newline at end of file diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..0ce601a07 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "metaflow-ui"] + path = metaflow-ui + url = https://github.com/Netflix/metaflow-ui diff --git a/docker-compose.development.yml b/docker-compose.development.yml index 07285611a..2675df772 100644 --- a/docker-compose.development.yml +++ b/docker-compose.development.yml @@ -15,6 +15,7 @@ services: cap_add: - SYS_PTRACE environment: + - MF_KUBERNETES_NAMESPACE=argo - MF_METADATA_DB_HOST=db - MF_METADATA_DB_PORT=5432 - MF_METADATA_DB_USER=postgres @@ -77,6 +78,7 @@ services: volumes: - ./services:/root/services environment: + - METAFLOW_KUBERNETES_NAMESPACE=argo - MF_METADATA_DB_HOST=db - MF_METADATA_DB_PORT=5432 - MF_METADATA_DB_USER=postgres @@ -88,6 +90,17 @@ services: - MF_MIGRATION_PORT=${MF_MIGRATION_PORT:-8082} depends_on: - db + metaflow-ui: + build: + context: ./metaflow-ui + dockerfile: Dockerfile + ports: + - "3000:3000" + environment: + - METAFLOW_SERVICE=http://localhost:8083/ + - METAFLOW_KUBERNETES_NAMESPACE=argo + depends_on: + - ui_backend db: image: "postgres:11" command: ["postgres", "-c", "log_statement=none", "-c", "wal_level=logical"] diff --git a/local-example/README.md b/local-example/README.md new file mode 100644 index 000000000..34b2fa477 --- /dev/null +++ b/local-example/README.md @@ -0,0 +1,23 @@ +# Running Flows in Local UI + +1. Start your metadata services using the following command: + + ```bash + ./local-example/run-services.sh + ``` + +2. Configure metaflow to use your local metadata services: + + ```bash + metaflow configure import local-example/metaflow-config.json + ``` +3. + +4. Run the example flow: + + ```bash + python local-example/helloworld.py run + ``` +5. Go to your UI metaflow UI at http://localhost:3000/ to see your flow runs. + +![](../../../../Downloads/metaflow UI.png) \ No newline at end of file diff --git a/local-example/helloworld.py b/local-example/helloworld.py new file mode 100755 index 000000000..cd4ed72e2 --- /dev/null +++ b/local-example/helloworld.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python +from metaflow import FlowSpec, step, conda, kubernetes + + +class HelloFlow(FlowSpec): + """ + A flow where Metaflow prints 'Hi'. + + Run this flow to validate that Metaflow is installed correctly. + + """ + @step + def start(self): + """ + This is the 'start' step. All flows must have a step named 'start' that + is the first step in the flow. + + """ + print("HelloFlow is starting.") + self.next(self.hello) + + @kubernetes(cpu=.3, memory=4, namespace="argo") + @step + def hello(self): + """ + A step for metaflow to introduce itself. + + """ + print("Metaflow says: Hi!") + self.next(self.end) + + @step + def end(self): + """ + This is the 'end' step. All flows must have an 'end' step, which is the + last step in the flow. + + """ + print("HelloFlow is all done.") + + +if __name__ == '__main__': + HelloFlow() diff --git a/local-example/metaflow-config.json b/local-example/metaflow-config.json new file mode 100644 index 000000000..ce252706a --- /dev/null +++ b/local-example/metaflow-config.json @@ -0,0 +1,8 @@ +{ + "METAFLOW_SERVICE_URL": "http://localhost:8080", + "METAFLOW_DEFAULT_METADATA": "service", + "METAFLOW_DEFAULT_DATASTORE": "s3", + "METAFLOW_DATASTORE_SYSROOT_S3": "s3://your-bucket", + "METAFLOW_DATATOOLS_S3ROOT": "s3://your-bucket", + "METAFLOW_KUBERNETES_NAMESPACE": "argo" +} diff --git a/local-example/run_services.sh b/local-example/run_services.sh new file mode 100644 index 000000000..08267cc91 --- /dev/null +++ b/local-example/run_services.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e + +docker-compose -f docker-compose.development.yml up -d --build & + +# Mac installation steps +#brew install minikube +#brew install argo +#brew install kubectl + + +pip install kubernetes +echo "Starting Minikube" +minikube start + +alias kubectl="minikube kubectl --" +kubectl apply -f https://github.com/cert-manager/cert-manager/releases/download/v1.1.1/cert-manager.yaml +kubectl create ns argo +kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo-workflows/master/manifests/quick-start-postgres.yaml +kubectl -n argo port-forward deployment/argo-server 2746:2746 + +wait diff --git a/metaflow-ui b/metaflow-ui new file mode 160000 index 000000000..886a2854c --- /dev/null +++ b/metaflow-ui @@ -0,0 +1 @@ +Subproject commit 886a2854c0861ba95bb4b6606356677a0bdf81b2