From 3c850239eb492d9c613ef97384e8d7ff472f281c Mon Sep 17 00:00:00 2001 From: Matheus Moreno Date: Tue, 21 Dec 2021 16:59:32 -0300 Subject: [PATCH 1/4] Do not modify tags dict on start_run() Signed-off-by: Matheus Moreno --- mlflow/tracking/fluent.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mlflow/tracking/fluent.py b/mlflow/tracking/fluent.py index 793e8b1020aa2..8e0a7b45f2975 100644 --- a/mlflow/tracking/fluent.py +++ b/mlflow/tracking/fluent.py @@ -8,6 +8,7 @@ import time import logging import inspect +from copy import deepcopy from packaging.version import Version from typing import Any, Dict, List, Optional, Union, TYPE_CHECKING @@ -278,15 +279,15 @@ def start_run( exp_id_for_run = experiment_id if experiment_id is not None else _get_experiment_id() - user_specified_tags = tags or {} + user_specified_tags = deepcopy(tags) or {} if parent_run_id is not None: user_specified_tags[MLFLOW_PARENT_RUN_ID] = parent_run_id if run_name is not None: user_specified_tags[MLFLOW_RUN_NAME] = run_name - tags = context_registry.resolve_tags(user_specified_tags) + run_tags = context_registry.resolve_tags(user_specified_tags) - active_run_obj = client.create_run(experiment_id=exp_id_for_run, tags=tags) + active_run_obj = client.create_run(experiment_id=exp_id_for_run, tags=run_tags) _active_run_stack.append(ActiveRun(active_run_obj)) return _active_run_stack[-1] From 355fcd4a0b7b75366d3dee4c49b12683558cf20c Mon Sep 17 00:00:00 2001 From: Matheus Moreno Date: Wed, 22 Dec 2021 15:26:11 -0300 Subject: [PATCH 2/4] Do not rewrite tags param on create_run() Signed-off-by: Matheus Moreno --- mlflow/tracking/_tracking_service/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mlflow/tracking/_tracking_service/client.py b/mlflow/tracking/_tracking_service/client.py index 0a1d77698b1f3..abeb9efe15f34 100644 --- a/mlflow/tracking/_tracking_service/client.py +++ b/mlflow/tracking/_tracking_service/client.py @@ -94,18 +94,18 @@ def create_run(self, experiment_id, start_time=None, tags=None): :return: :py:class:`mlflow.entities.Run` that was created. """ - tags = tags if tags else {} + run_tags = tags if tags else {} # Extract user from tags # This logic is temporary; the user_id attribute of runs is deprecated and will be removed # in a later release. - user_id = tags.get(MLFLOW_USER, "unknown") + user_id = run_tags.get(MLFLOW_USER, "unknown") return self.store.create_run( experiment_id=experiment_id, user_id=user_id, start_time=start_time or int(time.time() * 1000), - tags=[RunTag(key, value) for (key, value) in tags.items()], + tags=[RunTag(key, value) for (key, value) in run_tags.items()], ) def list_run_infos( From f4679c6b42a30a03bbbb1e15c9db5e6113d29169 Mon Sep 17 00:00:00 2001 From: Matheus Moreno Date: Wed, 22 Dec 2021 15:26:34 -0300 Subject: [PATCH 3/4] Rename variable in start_run() Signed-off-by: Matheus Moreno --- mlflow/tracking/fluent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mlflow/tracking/fluent.py b/mlflow/tracking/fluent.py index 8e0a7b45f2975..19a9346235219 100644 --- a/mlflow/tracking/fluent.py +++ b/mlflow/tracking/fluent.py @@ -285,9 +285,9 @@ def start_run( if run_name is not None: user_specified_tags[MLFLOW_RUN_NAME] = run_name - run_tags = context_registry.resolve_tags(user_specified_tags) + resolved_tags = context_registry.resolve_tags(user_specified_tags) - active_run_obj = client.create_run(experiment_id=exp_id_for_run, tags=run_tags) + active_run_obj = client.create_run(experiment_id=exp_id_for_run, tags=resolved_tags) _active_run_stack.append(ActiveRun(active_run_obj)) return _active_run_stack[-1] From 18fffc18db73bf4adcde4a2ca55214e309d7520f Mon Sep 17 00:00:00 2001 From: Matheus Moreno Date: Wed, 22 Dec 2021 21:18:22 -0300 Subject: [PATCH 4/4] Revert "Do not rewrite tags param on create_run()" This reverts commit 355fcd4a0b7b75366d3dee4c49b12683558cf20c. Signed-off-by: Matheus Moreno --- mlflow/tracking/_tracking_service/client.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mlflow/tracking/_tracking_service/client.py b/mlflow/tracking/_tracking_service/client.py index abeb9efe15f34..0a1d77698b1f3 100644 --- a/mlflow/tracking/_tracking_service/client.py +++ b/mlflow/tracking/_tracking_service/client.py @@ -94,18 +94,18 @@ def create_run(self, experiment_id, start_time=None, tags=None): :return: :py:class:`mlflow.entities.Run` that was created. """ - run_tags = tags if tags else {} + tags = tags if tags else {} # Extract user from tags # This logic is temporary; the user_id attribute of runs is deprecated and will be removed # in a later release. - user_id = run_tags.get(MLFLOW_USER, "unknown") + user_id = tags.get(MLFLOW_USER, "unknown") return self.store.create_run( experiment_id=experiment_id, user_id=user_id, start_time=start_time or int(time.time() * 1000), - tags=[RunTag(key, value) for (key, value) in run_tags.items()], + tags=[RunTag(key, value) for (key, value) in tags.items()], ) def list_run_infos(