Saltar al contenido

Lección 23 · Servers, Deployment and Teams

Teams, Security and Reproducibility

Share MLflow safely with authentication and permissions, clean up deleted runs, package code as MLflow Projects and use MLflow in a CI pipeline.

When more people share MLflow, three questions matter: who may do what, how you keep it tidy, and whether someone else can repeat your work.

Authentication and permissions

MLflow includes basic HTTP authentication. As documented, you install the extra and enable it:

Terminal
pip install 'mlflow[auth]'
export MLFLOW_FLASK_SERVER_SECRET_KEY="<a long random secret>"
export MLFLOW_AUTH_ADMIN_PASSWORD="<a strong password, 12+ characters>"
mlflow server --app-name basic-auth

The default admin username is admin, and you must set a password before the first start. After that start, remove the password variable and rotate the password. Clients authenticate with MLFLOW_TRACKING_USERNAME and MLFLOW_TRACKING_PASSWORD. A credentials file is also possible, but it stores the password unencrypted. Always use HTTPS with passwords.

Permission levels include READ, USE, EDIT, MANAGE and NO_PERMISSIONS. Check the default permission for users and tighten it if needed. From MLflow 3.13.0, permissions are granted through roles. Many organizations use single sign-on instead. MLflow also has optional workspaces to separate teams on one server, which need a SQL backend.

Naming and conventions

Write a short team guide with:

  • Naming rules for experiments and registered models.
  • Required tags, such as owner and data_version.
  • Who may move production aliases.
  • What must never be logged, such as secrets and raw personal data.
  • How long to keep runs and artifacts.

A check like this can run in your pipeline:

Python Stand-in: require team tags on a run

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Deleting and cleaning up

Deleting a run in MLflow is normally a soft delete: the run is hidden and can be restored. To free storage, the mlflow gc command permanently removes deleted items. It accepts options such as --older-than, --run-ids and --experiment-ids. Permanent removal cannot be undone, so back up first, check which store you target, and test on a copy.

Reproducibility

To repeat a result, you need the same code, data, environment and settings, including random seeds. MLflow records some of this, but not all of it. Record the Git commit, the data version and the dependencies. Even then, some hardware and parallel operations can cause small differences.

MLflow Projects

An MLflow Project describes how to run code. A file named MLproject lists an environment and entry points with typed parameters:

YAML
name: churn
python_env: python_env.yaml
entry_points:
  main:
    parameters:
      max_depth: {type: float, default: 6}
      data: {type: path, default: data/train.csv}
    command: "python train.py --max-depth {max_depth} --data {data}"

Run it like this:

Terminal
mlflow run . -P max_depth=8
mlflow run . -e main --env-manager local

The documented parameter types are string, float, int, path and uri. A path parameter downloads remote files first, while a uri is passed through unchanged. You can also run a project from a Git address, but only run projects you trust, because running one executes its code on your machine.

MLflow in CI

A typical pipeline on a pull request:

  1. Install pinned dependencies.
  2. Train or load the candidate model.
  3. Evaluate it and validate thresholds.
  4. Log results to the shared server with a limited account.
  5. Fail the build if a gate fails.
  6. After approval, register the model and move the alias.

Give the pipeline only the permissions it needs. Keep its credentials in the secret store of your CI system, and never print them in logs.

Cost control

Storage grows with every checkpoint and trace. Review large experiments regularly, set a retention policy for traces and artifacts, and remove what nobody will use. Ask before you delete shared work.

A permission system protects only what you configure. Test it with an account that is not an administrator, and review access when people change roles.

Least privilege in practice

Give each person and each automated job only what it needs. A training pipeline may need to write runs, but not to move the production alias. A monitoring dashboard may only need to read. Separate accounts also make it easier to see who did what, and to remove one account without breaking others.

An onboarding checklist

When a new teammate joins:

  1. Create their account with the minimum role.
  2. Share the naming and tagging guide.
  3. Show where to find the official docs for your MLflow version.
  4. Have them log a test run in a sandbox experiment.
  5. Explain what must never be logged.

When someone leaves, disable the account, rotate any shared secrets they knew, and check which experiments they owned.

Incident basics

If a secret was logged by mistake, treat it as exposed. First revoke or rotate the secret at its source. Then remove it from runs, artifacts and traces, remembering that soft deletion may keep the data until permanent cleanup, and that backups may still hold copies. Finally, find out how it got there and add a check that prevents a repeat.

Review your guide

A team guide only helps if people follow it. Put checks in code where you can, such as a required-tags test in the pipeline, and keep the written rules short. Revisit the guide every few months. Remove rules that nobody needs, add rules for problems that really happened, and make sure that new features, such as traces or prompts, are covered by your privacy and retention decisions.

Check your understanding

Quick check · 3 questions

of 3 answered You scored / 3 · perfect!

  1. 1. What is the usual effect of deleting a run?

    Deletion is usually soft, and mlflow gc removes deleted items permanently.
  2. 2. What does an MLproject file define?

    It describes how to run the project code.
  3. 3. What is an important rule for running a project from the internet?

    The entry points of a project run real commands on your machine.

Summary

  • Turn on authentication, use HTTPS and apply least privilege.
  • Agree on team naming, tags and retention.
  • mlflow gc permanently removes deleted items, so back up first.
  • Projects and CI help others repeat your work.

Next: Project: A Tracked Model Release

Tu progreso se guarda en este navegador. No necesitas una cuenta.