|
| 1 | +# MLflow development container (experimental) |
| 2 | + |
| 3 | +This directory contains a set of files to set up a reproducible and disposable development environment for MLflow in Visual Studio Code using the [Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers). |
| 4 | + |
| 5 | +## Supported features |
| 6 | + |
| 7 | +- Pre-installed tools/packages required for MLflow development. |
| 8 | +- Pre-configured VSCode settings and extensions for automatic code formatting and lint check. |
| 9 | +- Pre-commit hooks to avoid pushing commits that won't pass the CI checks. |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +- [Visual Studio Code](https://code.visualstudio.com/) |
| 14 | +- [Remote - Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) |
| 15 | +- [Docker](https://www.docker.com/) |
| 16 | + |
| 17 | +## Getting started |
| 18 | + |
| 19 | +1. Build the devcontainer image. |
| 20 | + |
| 21 | + ```bash |
| 22 | + # This command may take a while to finish |
| 23 | + DOCKER_BUILDKIT=1 docker build -f .devcontainer/Dockerfile.devcontainer -t ghcr.io/mlflow/mlflow-devcontainer . |
| 24 | + |
| 25 | + # Test the image |
| 26 | + docker run --rm -it ghcr.io/mlflow/mlflow-devcontainer zsh |
| 27 | + |
| 28 | + # Alternatively, you can pull the pre-built image from GitHub Container Registry, |
| 29 | + # but a GitHub personal access token is required to authenticate to ghcr.io: |
| 30 | + echo <GITHUB_TOKEN> | docker login ghcr.io -u <GITHUB_USERNAME> --password-stdin |
| 31 | + docker pull ghcr.io/mlflow/mlflow-devcontainer |
| 32 | + ``` |
| 33 | + |
| 34 | +2. Open the MLflow repository on VSCode. |
| 35 | +3. Press `Ctrl/Cmd+Shift+P` to launch [the command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette). |
| 36 | +4. Select `Remote-Containers: Reopen in Container`. |
| 37 | +5. Once the devcontainer is up and running, launch the command palette again. |
| 38 | +6. Select `Terminal: Create New Terminal`. |
| 39 | +7. Run the following commands and make sure they run successfully: |
| 40 | + |
| 41 | +```bash |
| 42 | +pytest tests/test_version.py |
| 43 | +``` |
| 44 | + |
| 45 | +## Developing in GitHub Codespaces |
| 46 | + |
| 47 | +You can create the same development environment as your local devcontainer **in a web browser with just a few clicks** using [GitHub Codespaces](https://github.com/features/codespaces). The instructions in [Creating a codespace](https://docs.github.com/en/codespaces/developing-in-codespaces/creating-a-codespace#creating-a-codespace) cover how to set up a codespace. |
| 48 | + |
| 49 | +<img src="./images/codespace.png" width="50%"> |
| 50 | + |
| 51 | +## Limitations |
| 52 | + |
| 53 | +The following tools/packages are NOT pre-installed to avoid increasing the image size. They can be manually installed after launching the devcontainer if necessary. |
| 54 | + |
| 55 | +- Python ML packages such as `tensorflow` |
| 56 | +- R |
| 57 | +- Docker |
| 58 | +- conda |
| 59 | + |
| 60 | +## How to update `requirements.txt` |
| 61 | + |
| 62 | +```bash |
| 63 | +NAME="mlflow-$(uuidgen)" |
| 64 | +docker run \ |
| 65 | + --name $NAME \ |
| 66 | + -w /mlflow \ |
| 67 | + -v $(pwd)/requirements:/mlflow/requirements:ro \ |
| 68 | + -v $(pwd)/.devcontainer/pip-compile.sh:/mlflow/pip-compile.sh \ |
| 69 | + python:3.8.15 ./pip-compile.sh |
| 70 | +docker cp $NAME:/tmp/requirements.txt .devcontainer/requirements.txt |
| 71 | +docker rm -f -v $NAME |
| 72 | +``` |
0 commit comments