2

MLFlow version: 1.4.0 Python version: 3.7.4

I'm running the UI as mlflow server... with all the required command line options.

I am logging to MLFlow as an MLFlow project, with the appropriate MLproject.yaml file. The project is being run on a Docker container, so the CMD looks like this:

mlflow run . -P document_ids=${D2V_DOC_IDS} -P corpus_path=... --no-conda --experiment-name=${EXPERIMENT_NAME}

Running the experiment like this results in a blank run_name. I know there's a run_id but I'd also like to see the run_name and set it in my code -- either in the command line, or in my code as mlflow.log.....

I've looked at Is it possible to set/change mlflow run name after run initial creation? but I want to programmatically set the run name instead of changing it manually on the UI.

user2226006
  • 53
  • 1
  • 7

2 Answers2

6

One of the parameters to mlflow.start_run() is run_name. This would give you programmatic access to set the run name with each iteration. See the docs here.

Here's an example:

from datetime import datetime

## Define the name of our run
name = "this run is gonna be bananas" + datetime.now()

## Start a new mlflow run and set the run name
with mlflow.start_run(run_name = name):

    ## ...train model, log metrics/params/model...

    ## End the run
    mlflow.end_run()

If you want to include set the name as part of an MLflow Project, you'll have to specify it as a parameter in the entry points to the project. This is located in in the MLproject file. Then you can pass those values into the mlflow.start_run() function from the command line.

Raphael K
  • 2,265
  • 1
  • 16
  • 23
  • use the system tag directly: `mlflow.set_tag("mlflow.runName", "run_name")` https://github.com/mlflow/mlflow/issues/2804#issuecomment-640056129 – Jose R. Zapata Sep 06 '22 at 18:58
0

for CLI, this seems to now be available:

--run-name <runname>

https://mlflow.org/docs/latest/cli.html#cmdoption-mlflow-run-run-name