def test_mlflow_run_name_setting(tmp_path):
    """Test that the run_name argument makes the MLFLOW_RUN_NAME tag."""
    if not _MLFLOW_AVAILABLE:
        pytest.skip("test for explicit file creation requires mlflow dependency to be installed.")

    from mlflow.utils.mlflow_tags import MLFLOW_RUN_NAME

    resolve_tags = _get_resolve_tags()
    tags = resolve_tags({MLFLOW_RUN_NAME: "run-name-1"})

    # run_name is appended to tags
    logger = MLFlowLogger("test", run_name="run-name-1", save_dir=str(tmp_path))
    logger._mlflow_client = client = Mock()

    logger = mock_mlflow_run_creation(logger, experiment_id="exp-id")
    _ = logger.experiment
    client.create_run.assert_called_with(experiment_id="exp-id", tags=tags)

    # run_name overrides tags[MLFLOW_RUN_NAME]
    logger = MLFlowLogger("test", run_name="run-name-1", tags={MLFLOW_RUN_NAME: "run-name-2"}, save_dir=str(tmp_path))
    logger = mock_mlflow_run_creation(logger, experiment_id="exp-id")
    _ = logger.experiment
    client.create_run.assert_called_with(experiment_id="exp-id", tags=tags)

    # default run_name (= None) does not append new tag
    logger = MLFlowLogger("test", save_dir=str(tmp_path))
    logger = mock_mlflow_run_creation(logger, experiment_id="exp-id")
    _ = logger.experiment
    default_tags = resolve_tags(None)
    client.create_run.assert_called_with(experiment_id="exp-id", tags=default_tags)
Test that the run_name argument makes the MLFLOW_RUN_NAME tag.
tests/tests_pytorch/loggers/test_mlflow.py