|
| 1 | +import ReactPlayer from 'react-player' |
| 2 | + |
| 3 | +# Setting Up the Dev Stack |
| 4 | + |
| 5 | +You can start writing and running flows just by installing Metaflow locally with |
| 6 | +`pip install metaflow`. However, its true power lies in its integration with underlying |
| 7 | +infrastructure, which allows you to |
| 8 | + |
| 9 | + - [run tasks in the cloud at any scale](/scaling/remote-tasks/introduction), |
| 10 | + - [visualize and observe them in a UI](/metaflow/visualizing-results), |
| 11 | + - [deploy them in a highly available production orchestrator](/production/introduction), |
| 12 | + - and compose reactive systems with [event-triggered flows](/production/event-triggering). |
| 13 | + |
| 14 | +All of these features require an infrastructure stack that needs to be configured to work |
| 15 | +with Metaflow. In production settings, this infrastructure runs in your cloud account - |
| 16 | +as [described on this page](/getting-started/infrastructure) - but you may want to test the |
| 17 | +full stack first locally. |
| 18 | + |
| 19 | +Metaflow comes with a one-click script, `metaflow-dev`, which sets up a complete |
| 20 | +development stack for you locally on top of [Minikube](https://minikube.sigs.k8s.io/docs/), |
| 21 | +including a local metadata service and a database, and [Metaflow UI](https://github.com/Netflix/metaflow-ui). |
| 22 | +The stack allows you to [test scaling with `@kubernetes`](/scaling/remote-tasks/kubernetes), |
| 23 | +[deployment on Argo Workflows](/production/scheduling-metaflow-flows/scheduling-with-argo-workflows), |
| 24 | +as well as [event-triggering](/production/event-triggering). |
| 25 | + |
| 26 | +## When to use `metaflow-dev` |
| 27 | + |
| 28 | +The `metaflow-dev` stack comes in handy in a few scenarios: |
| 29 | + |
| 30 | + 1. It allows you to **test the full functionality of Metaflow** before [deploying it in your cloud account](/getting-started/infrastructure). |
| 31 | + |
| 32 | + 2. You can use it **in your CI/CD workflows to test flows** in a fully isolated, ephemeral environment. |
| 33 | + |
| 34 | + 3. If you want to **contribute extensions for Metaflow**, or make changes in the core Metaflow, the stack |
| 35 | + provides you a complete development and testing environment. |
| 36 | + |
| 37 | +## How to set up the dev stack |
| 38 | + |
| 39 | +Setting up the stack is straightforward: |
| 40 | + |
| 41 | +1. Install Metaflow with `pip install metaflow`. |
| 42 | +2. Ensure that [you have Docker installed](https://docs.docker.com/desktop/). |
| 43 | +3. Run `metaflow-dev up`. |
| 44 | + |
| 45 | +The `metaflow-dev` command downloads and installs Minikube. After this, it uses [Tilt](https://tilt.dev/) to deploy |
| 46 | +and expose [all components required by Metaflow](/internals/technical-overview) inside Minikube. |
| 47 | + |
| 48 | +After the deployment completes, leave the shell running `metaflow-dev up` open, as it hosts necessary port |
| 49 | +forwardings. On the side, open a new shell and execute |
| 50 | +`metaflow-dev shell`. This will open a session with a Metaflow configuration pointing at the local stack. |
| 51 | +You can now use the shell to develop, run, and deploy Metaflow flows! |
| 52 | + |
| 53 | +You can navigate to the Tilt UI, linked in the console output, to find links to the Metaflow and Argo Workflows UIs. |
| 54 | +You can find direct links to the UI in the Metaflow output as well. |
| 55 | + |
| 56 | +### The dev stack in action |
| 57 | + |
| 58 | +Watch this short video (no sound) for a quick setup-to-usage walkthrough: |
| 59 | + |
| 60 | +<ReactPlayer controls url="https://www.youtube.com/watch?v=nPtqj72hfKU" /> |
| 61 | +<br/> |
| 62 | + |
| 63 | +The video covers: |
| 64 | + |
| 65 | +- Setting up the dev stack |
| 66 | +- Observing the stack through the Tilt UI |
| 67 | +- Using the stack to run and monitor runs |
| 68 | +- Running at scale with `@kubernetes` |
| 69 | +- Inspecting results in a notebook, accessing metadata |
| 70 | +- Deploying to Argo Workflows |
| 71 | +- Tearing down the stack |
| 72 | + |
| 73 | +## Using the dev stack in a CI/CD pipeline |
| 74 | + |
| 75 | +The dev stack is lightweight enough to run in small CI/CD worker nodes, including those provided by GitHub Actions. You |
| 76 | +can use the stack to run integration tests for flows in a fully isolated, ephemeral environment. |
| 77 | + |
| 78 | +Take a look at [this example repository](https://github.com/outerbounds/gha-metaflow/) and |
| 79 | +[a GitHub Actions config](https://github.com/outerbounds/gha-metaflow/blob/main/.github/workflows/metaflow.yml) for |
| 80 | +a template that you can easily apply in your own setup. |
| 81 | + |
0 commit comments