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.
- Pre-installed tools/packages required for MLflow development.
- Pre-configured VSCode settings and extensions for automatic code formatting and lint check.
- Pre-commit hooks to avoid pushing commits that won't pass the CI checks.
-
Build the devcontainer image.
# This command may take a while to finish DOCKER_BUILDKIT=1 docker build -f .devcontainer/Dockerfile.devcontainer -t ghcr.io/mlflow/mlflow-devcontainer . # Test the image docker run --rm -it ghcr.io/mlflow/mlflow-devcontainer zsh # Alternatively, you can pull the pre-built image from GitHub Container Registry, # but a GitHub personal access token is required to authenticate to ghcr.io: echo <GITHUB_TOKEN> | docker login ghcr.io -u <GITHUB_USERNAME> --password-stdin docker pull ghcr.io/mlflow/mlflow-devcontainer
-
Open the MLflow repository on VSCode.
-
Press
Ctrl/Cmd+Shift+P
to launch the command palette. -
Select
Remote-Containers: Reopen in Container
. -
Once the devcontainer is up and running, launch the command palette again.
-
Select
Terminal: Create New Terminal
. -
Run the following commands and make sure they run successfully:
pytest tests/test_version.py
You can create the same development environment as your local devcontainer in a web browser with just a few clicks using GitHub Codespaces. The instructions in Creating a codespace cover how to set up a codespace.
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.
- Python ML packages such as
tensorflow
- R
- Docker
- conda
NAME="mlflow-$(uuidgen)"
docker run \
--name $NAME \
-w /mlflow \
-v $(pwd)/requirements:/mlflow/requirements:ro \
-v $(pwd)/.devcontainer/pip-compile.sh:/mlflow/pip-compile.sh \
python:3.8.15 ./pip-compile.sh
docker cp $NAME:/tmp/requirements.txt .devcontainer/requirements.txt
docker rm -f -v $NAME