pythonmlflowmlops

How to set a tag at the experiment level in MLFlow


I can see that an experiment in MLFlow can have tags (like runs can have tags). I'm able to set a run's tag using mlflow.set_tag, but how do I set it for an experiment?


Solution

  • If you look into the Python API, the very first example in mlflow.tracking package that shows how to create the MLflowClient is really showing how to tag experiment using the client.set_experiment_tag function (doc):

    from mlflow.tracking import MlflowClient
    
    # Create an experiment with a name that is unique and case sensitive.
    client = MlflowClient()
    experiment_id = client.create_experiment("Social NLP Experiments")
    client.set_experiment_tag(experiment_id, "nlp.framework", "Spark NLP")
    

    you can also set it for model version with set_model_version_tag function, and for registered model with set_registered_model_tag.