Adeel Hashmi
Adeel Hashmi

Reputation: 837

MLflow stores tags but does not return them

I am running the below code to store tags and then to retrieve them. As you can see below, Mlflow is storing one set of tags and returning another.

import mlflow
with mlflow.start_run() as active_run:
    tw = { "run_id": 1}
    mlflow.set_tags(tw)            
    print("Tags are ", active_run.data.tags)
    print(type(active_run.data.tags))

Output

Tags are  {'mlflow.source.name': '/media/Space/AI/anaconda4/lib/python3.7/site-packages/ipykernel_launcher.py', 'mlflow.source.type': 'LOCAL', 'mlflow.user': 'adeel'}

Looking at the stored tags through mlflow ui, I can see that the tag "run_id" set by the code is actually stored in the run. However, only the header information of the run seems to be getting returned by active_run.data.tags.

Upvotes: 0

Views: 855

Answers (1)

Bram
Bram

Reputation: 406

At the moment, you have to query your run again in MLflow to get the run with all the info that you logged. In the example below, I call mlflow.get_run(<run_id>) to achieve this.

import mlflow


with mlflow.start_run() as active_run:
  tags = { "my_tag": 1}
  mlflow.set_tags(tags)            
  # Keep track of the run ID of the active run
  run_id = active_run.info.run_id

run = mlflow.get_run(run_id)
print("The tags are ", run.data.tags)

Upvotes: 2

Related Questions