Spaces:
Sleeping
Sleeping
| title: Mlflow Server | |
| emoji: π | |
| colorFrom: gray | |
| colorTo: pink | |
| sdk: docker | |
| pinned: false | |
| license: apache-2.0 | |
| short_description: A sample MLFlow server for demo | |
| Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference | |
| # π MLflow Tracking Server Configuration | |
| This Space hosts a remote MLflow Tracking Server. It allows you to log parameters, metrics, and models from your training pipelines (like GitHub Actions) to a centralized location. | |
| ## π Environment Variables (Secrets) | |
| To make this server functional, you need to go to **Settings > Variables and secrets** in your Hugging Face Space and add the following secrets. | |
| | Variable Name | Description | Example Value | | |
| | :--- | :--- | :--- | | |
| | `BACKEND_STORE_URI` | The database URI where metrics and parameters are stored. | `postgresql://user:password@host:port/db` or `sqlite:///mlflow.db` | | |
| | `ARTIFACT_STORE_URI` | The remote storage location for model artifacts (S3, GCS, etc.). | `s3://my-mlflow-bucket/artifacts` | | |
| | `AWS_ACCESS_KEY_ID` | Required if your artifact store is on S3. | `AKIA...` | | |
| | `AWS_SECRET_ACCESS_KEY` | Required if your artifact store is on S3. | `wJalr...` | | |
| | `PORT` | The port the application listens on (HF Spaces defaults to 7860). | `7860` | | |
| > **Note:** The `AWS_` credentials are required because the Dockerfile installs the AWS CLI to handle interactions with S3 buckets. | |
| ## π³ Dockerfile Overview | |
| The `Dockerfile` is built on top of `continuumio/miniconda3` to ensure a robust Python environment. Here is what happens during the build: | |
| 1. **Tool Installation:** Installs utility tools (`nano`, `unzip`, `curl`) and the **AWS CLI** (via the official installer) to allow MLflow to communicate with S3 buckets. | |
| 2. **Dependencies:** Installs Python packages listed in `requirements.txt` (typically `mlflow`, `boto3`, `psycopg2`, etc.). | |
| 3. **Startup Command:** The container launches the MLflow server with specific flags to ensure it works in a cloud environment. | |
| ### Understanding the Launch Parameters | |
| The `CMD` in the Dockerfile uses the following flags: | |
| * `--host 0.0.0.0`: Binds the server to all network interfaces so it is accessible from outside the container. | |
| * `--serve-artifacts`: Enables the MLflow server to act as a proxy for artifact downloads/uploads (useful if the client doesn't have direct S3 access). | |
| * `--allowed-hosts '*'`: Disables the Host Header validation check. This is necessary in cloud environments (like HF Spaces) where the internal IP and public DNS might mismatch. | |
| * `--cors-allowed-origins '*'`: Sets the Cross-Origin Resource Sharing policy to allow any domain to access this API. This is useful for teaching environments but can be restricted for production. |