Runs#
This page discusses ways to manipulate your runs.
import mlflow
mlflow.set_tracking_uri("file:///tmp/runs_page")
Search runs#
Using mlflow.search_runs
, you can load a set of runs that correspond to specified conditions. The most useful parameters are:
Parameter |
Description |
---|---|
|
The IDs of the experiments from which the runs will be retrieved |
|
Will return runs from all awailable experiments |
The following cell generates a set of experiments, as well as a set of runs for each experiment.
for i in range(5):
experiment_name = f"experiment {i + 1}"
mlflow.create_experiment(experiment_name)
mlflow.set_experiment(experiment_name=experiment_name)
for j in range(5):
mlflow.start_run(run_name = f"run {j + 1}")
mlflow.end_run()
The following cell shows the runs of the experiment 1
.
mlflow.search_runs(experiment_ids=[mlflow.get_experiment_by_name("experiment 1").experiment_id])
run_id | experiment_id | status | artifact_uri | start_time | end_time | tags.mlflow.user | tags.mlflow.runName | tags.mlflow.source.name | tags.mlflow.source.type | |
---|---|---|---|---|---|---|---|---|---|---|
0 | 1d3b84196bf04311b515df92ded6e29b | 460233828277669480 | FINISHED | file:///tmp/runs_page/460233828277669480/1d3b8... | 2025-09-26 12:37:43.683000+00:00 | 2025-09-26 12:37:43.685000+00:00 | user | run 5 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
1 | 7d0de82b412d421aac32258101c81136 | 460233828277669480 | FINISHED | file:///tmp/runs_page/460233828277669480/7d0de... | 2025-09-26 12:37:43.680000+00:00 | 2025-09-26 12:37:43.682000+00:00 | user | run 4 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
2 | c6d2dde7251a4847941a1abe664832e6 | 460233828277669480 | FINISHED | file:///tmp/runs_page/460233828277669480/c6d2d... | 2025-09-26 12:37:43.676000+00:00 | 2025-09-26 12:37:43.679000+00:00 | user | run 3 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
3 | d8ac0efee591417bb46b36614c037ccd | 460233828277669480 | FINISHED | file:///tmp/runs_page/460233828277669480/d8ac0... | 2025-09-26 12:37:43.671000+00:00 | 2025-09-26 12:37:43.675000+00:00 | user | run 2 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
4 | 5e93a7b1b5bc418cb7aa59a526b7e2d0 | 460233828277669480 | FINISHED | file:///tmp/runs_page/460233828277669480/5e93a... | 2025-09-26 12:37:43.664000+00:00 | 2025-09-26 12:37:43.669000+00:00 | user | run 1 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
The same, but also runs of the experiment 2
are added.
experiments_ids = [
mlflow.get_experiment_by_name("experiment 1").experiment_id,
mlflow.get_experiment_by_name("experiment 2").experiment_id,
]
mlflow.search_runs(experiment_ids=experiments_ids)
run_id | experiment_id | status | artifact_uri | start_time | end_time | tags.mlflow.user | tags.mlflow.runName | tags.mlflow.source.name | tags.mlflow.source.type | |
---|---|---|---|---|---|---|---|---|---|---|
0 | e6c7219efbe34a8582a4500a11d3ccac | 459248949934636608 | FINISHED | file:///tmp/runs_page/459248949934636608/e6c72... | 2025-09-26 12:37:43.700000+00:00 | 2025-09-26 12:37:43.702000+00:00 | user | run 5 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
1 | ddc7e8c1884c421d885158211f9a5acd | 459248949934636608 | FINISHED | file:///tmp/runs_page/459248949934636608/ddc7e... | 2025-09-26 12:37:43.697000+00:00 | 2025-09-26 12:37:43.699000+00:00 | user | run 4 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
2 | 20fd7890661a4ca6bd2a56d61fb88dfc | 459248949934636608 | FINISHED | file:///tmp/runs_page/459248949934636608/20fd7... | 2025-09-26 12:37:43.694000+00:00 | 2025-09-26 12:37:43.696000+00:00 | user | run 3 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
3 | 4ff4fdacb5bf408092498a187f8e6a0a | 459248949934636608 | FINISHED | file:///tmp/runs_page/459248949934636608/4ff4f... | 2025-09-26 12:37:43.691000+00:00 | 2025-09-26 12:37:43.693000+00:00 | user | run 2 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
4 | 4706fd7e7596464b9d25deee41f9b2db | 459248949934636608 | FINISHED | file:///tmp/runs_page/459248949934636608/4706f... | 2025-09-26 12:37:43.688000+00:00 | 2025-09-26 12:37:43.690000+00:00 | user | run 1 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
5 | 1d3b84196bf04311b515df92ded6e29b | 460233828277669480 | FINISHED | file:///tmp/runs_page/460233828277669480/1d3b8... | 2025-09-26 12:37:43.683000+00:00 | 2025-09-26 12:37:43.685000+00:00 | user | run 5 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
6 | 7d0de82b412d421aac32258101c81136 | 460233828277669480 | FINISHED | file:///tmp/runs_page/460233828277669480/7d0de... | 2025-09-26 12:37:43.680000+00:00 | 2025-09-26 12:37:43.682000+00:00 | user | run 4 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
7 | c6d2dde7251a4847941a1abe664832e6 | 460233828277669480 | FINISHED | file:///tmp/runs_page/460233828277669480/c6d2d... | 2025-09-26 12:37:43.676000+00:00 | 2025-09-26 12:37:43.679000+00:00 | user | run 3 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
8 | d8ac0efee591417bb46b36614c037ccd | 460233828277669480 | FINISHED | file:///tmp/runs_page/460233828277669480/d8ac0... | 2025-09-26 12:37:43.671000+00:00 | 2025-09-26 12:37:43.675000+00:00 | user | run 2 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
9 | 5e93a7b1b5bc418cb7aa59a526b7e2d0 | 460233828277669480 | FINISHED | file:///tmp/runs_page/460233828277669480/5e93a... | 2025-09-26 12:37:43.664000+00:00 | 2025-09-26 12:37:43.669000+00:00 | user | run 1 | /home/user/.virtualenvironments/python/lib/pyt... | LOCAL |
Child & Parent#
MLFlow allows the creation of nested runs. There is an outer run - the parent run and an inner run - the child run. To create a child run, you need to start another run while one is running and pass nested=True
to the mlflow.start_run
.
Check out the Understanding Parent and Child Runs in MLflow tutorial for more details.
The following cell creates a βparentβ run, and inside it iteratively starts some other runs with the names child_0
, child_1
and so on.
mlflow.set_experiment("nested_runs")
with mlflow.start_run(run_name="parent"):
for i in range(10):
with mlflow.start_run(run_name=f"child_{i}", nested=True):
pass
π View run child_0 at: http://localhost:5000/#/experiments/362948453640932348/runs/2562f6f88bd24fd18e590fefc985cc33
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
π View run child_1 at: http://localhost:5000/#/experiments/362948453640932348/runs/9b0233bb13e045e581d79a73e1ef1f73
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
π View run child_2 at: http://localhost:5000/#/experiments/362948453640932348/runs/17799d3fd383422c8ebf2086237854e2
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
π View run child_3 at: http://localhost:5000/#/experiments/362948453640932348/runs/c1283382a89549959c423a12fe09b6fb
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
π View run child_4 at: http://localhost:5000/#/experiments/362948453640932348/runs/4b1163851f0d46eeaebf210102b5d1ab
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
π View run child_5 at: http://localhost:5000/#/experiments/362948453640932348/runs/3fdd20b7cfdb4746b44ce73eb9e19bc9
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
π View run child_6 at: http://localhost:5000/#/experiments/362948453640932348/runs/74eaf04c30c043edbbf6eec9a48b5866
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
π View run child_7 at: http://localhost:5000/#/experiments/362948453640932348/runs/e1d880c924ec4a7cb896a043f29615ed
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
π View run child_8 at: http://localhost:5000/#/experiments/362948453640932348/runs/c292b24e66e24fd7aa8ea632e478388e
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
π View run child_9 at: http://localhost:5000/#/experiments/362948453640932348/runs/2225de115c2e45e0be8c8149dc8fb85c
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
π View run parent at: http://localhost:5000/#/experiments/362948453640932348/runs/a6793e5651944acea30396464bb3bdd7
π§ͺ View experiment at: http://localhost:5000/#/experiments/362948453640932348
The next code displays the names of the runs and the parent ids of the runs that were just created.
id = mlflow.get_experiment_by_name("nested_runs").experiment_id
runs = mlflow.search_runs(experiment_ids=id)
runs.loc[:, ["run_id", "tags.mlflow.runName", "tags.mlflow.parentRunId"]]
run_id | tags.mlflow.runName | tags.mlflow.parentRunId | |
---|---|---|---|
0 | 2225de115c2e45e0be8c8149dc8fb85c | child_9 | a6793e5651944acea30396464bb3bdd7 |
1 | c292b24e66e24fd7aa8ea632e478388e | child_8 | a6793e5651944acea30396464bb3bdd7 |
2 | e1d880c924ec4a7cb896a043f29615ed | child_7 | a6793e5651944acea30396464bb3bdd7 |
3 | 74eaf04c30c043edbbf6eec9a48b5866 | child_6 | a6793e5651944acea30396464bb3bdd7 |
4 | 3fdd20b7cfdb4746b44ce73eb9e19bc9 | child_5 | a6793e5651944acea30396464bb3bdd7 |
5 | 4b1163851f0d46eeaebf210102b5d1ab | child_4 | a6793e5651944acea30396464bb3bdd7 |
6 | c1283382a89549959c423a12fe09b6fb | child_3 | a6793e5651944acea30396464bb3bdd7 |
7 | 17799d3fd383422c8ebf2086237854e2 | child_2 | a6793e5651944acea30396464bb3bdd7 |
8 | 9b0233bb13e045e581d79a73e1ef1f73 | child_1 | a6793e5651944acea30396464bb3bdd7 |
9 | 2562f6f88bd24fd18e590fefc985cc33 | child_0 | a6793e5651944acea30396464bb3bdd7 |
10 | a6793e5651944acea30396464bb3bdd7 | parent | None |
As a result, in the tags.mlflow.parentRunId
column, for the βparentβ run there is None
, but all other runs refer to the βparentβ through this column.
Note that in the mlflow GUI runs are ordered in a hierachal order - check how to work with it in the Understanding Parent and Child Runs in MLflow tutorial.