Sub topic 14
Organizing experiments and controlling access
This chapter assumes you can already log runs with mlflow.start_run() and know the difference between notebook and workspace experiments. It covers how to keep experiments tidy as a team's work grows, and how Databricks decides who can see or change them.
Why organization matters
An experiment is a container for runs. Teams usually end up with dozens of experiments. If every one sits under a personal folder with a name like test2, nobody can find the right results later. Decide on a naming scheme before the first run, not after the fiftieth.
Use workspace experiments for shared work
A notebook experiment belongs to one notebook. It is convenient for scratch work, but it is tied to that notebook's location and permissions. A workspace experiment lives at a path you choose. It can be placed in a shared folder, and several notebooks or jobs can log to it.
A common layout is one folder per project, with one experiment per modeling question:
Set the experiment by absolute path at the top of every notebook or job, so runs never land in an unexpected place.
Tag experiments and runs
Names alone do not scale. Tags give you metadata you can filter on. Experiment-level tags describe the whole experiment, and run-level tags describe a single run.
import mlflow
from mlflow import MlflowClient
experiment_path = "/Shared/churn-project/baseline-models"
mlflow.set_experiment(experiment_path)
experiment = mlflow.get_experiment_by_name(experiment_path)
client = MlflowClient()
client.set_experiment_tag(experiment.experiment_id, "team", "retention")
with mlflow.start_run(run_name="logreg-v1"):
mlflow.set_tags({"owner": "data-science", "stage": "exploration"})
mlflow.log_metric("accuracy", 0.91)
found = mlflow.search_runs(
experiment_names=[experiment_path],
filter_string="tags.stage = 'exploration'",
)
print(found[["run_id", "tags.owner"]])Run tags appear as tags.<name> columns in the result of search_runs. This makes the tag scheme part of your query vocabulary. Agree on tag names across the team, because Stage and stage are different keys.
Experiment permissions
Databricks controls access to an experiment with access control lists. Each user or group gets one permission level:
| Permission | What it allows |
|---|---|
| No Permissions | The experiment is not accessible. |
| Can Read | View the experiment, its runs, metrics, and artifacts. |
| Can Edit | Everything in Can Read, plus log runs and edit the experiment's contents. |
| Can Manage | Everything in Can Edit, plus rename, delete, and change permissions. |
You change these from the experiment page, using the Permissions option. Assign permissions to groups rather than individuals, so access follows team membership.
For a workspace experiment, permissions can be inherited from the folder that contains it. A notebook experiment follows the permissions of its notebook. Sharing a notebook with someone therefore shares its runs too.
Experiment access is not model access
Permissions on an experiment do not control a registered model. Models in Unity Catalog use catalog privileges. A user who can read your runs still needs the right privileges on the catalog, the schema, and the model to load or register it. Plan the two separately. Open the experiment to the whole team for transparency, and keep the production model's privileges narrow.
A practical checklist
- Create a project folder under
/Sharedor a team folder. - Create one workspace experiment per question and set it by absolute path.
- Tag the experiment with team and project, and tag runs with stage and owner.
- Grant permissions to groups, starting with Can Read for most and Can Manage for owners.
- Review who holds Can Manage when team membership changes.
Exercise
A colleague has Can Read on your experiment. They report that their notebook fails when it tries to log a new run to it. Why, and what is the smallest change that fixes it?
Show answer
Can Read only allows viewing runs, metrics, and artifacts. Logging a run needs at least Can Edit. Grant the colleague, or better their group, Can Edit on the experiment. Can Manage is not needed.
Exercise
Why might you prefer a workspace experiment at a shared path over a notebook experiment for a project three people work on?
Show answer
A workspace experiment is not tied to one notebook. Several notebooks and jobs can log to the same path, and its permissions can be set on the experiment or inherited from its folder. A notebook experiment follows one notebook's location and permissions.