Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not modify tags dict on start_run() #5191

Merged
merged 4 commits into from Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions mlflow/tracking/_tracking_service/client.py
Expand Up @@ -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 {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At first I thought so, since it could rewrite the parameter, but it does seem unnecessary. Will undo the commit!


# 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(
Expand Down
7 changes: 4 additions & 3 deletions mlflow/tracking/fluent.py
Expand Up @@ -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

Expand Down Expand Up @@ -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 {}
harupy marked this conversation as resolved.
Show resolved Hide resolved
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)
resolved_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=resolved_tags)

_active_run_stack.append(ActiveRun(active_run_obj))
return _active_run_stack[-1]
Expand Down