Skip to content

Commit

Permalink
[Python] Convert log_params and set_tags values into strings (mlflow#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aarondav committed May 30, 2019
1 parent 2844431 commit 79ece06
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions mlflow/tracking/fluent.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def log_params(params):
:returns: None
"""
run_id = _get_or_start_run().info.run_id
params_arr = [Param(key, value) for key, value in params.items()]
params_arr = [Param(key, str(value)) for key, value in params.items()]
MlflowClient().log_batch(run_id=run_id, metrics=[], params=params_arr, tags=[])


Expand All @@ -229,7 +229,7 @@ def set_tags(tags):
:returns: None
"""
run_id = _get_or_start_run().info.run_id
tags_arr = [RunTag(key, value) for key, value in tags.items()]
tags_arr = [RunTag(key, str(value)) for key, value in tags.items()]
MlflowClient().log_batch(run_id=run_id, metrics=[], params=[], tags=tags_arr)


Expand Down
6 changes: 3 additions & 3 deletions tests/tracking/test_tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ def get_store_mock(tmpdir):


def test_set_tags(tracking_uri_mock):
exact_expected_tags = {"name_1": "c", "name_2": "b", "nested/nested/name": "5"}
exact_expected_tags = {"name_1": "c", "name_2": "b", "nested/nested/name": 5}
approx_expected_tags = set([MLFLOW_USER, MLFLOW_SOURCE_NAME, MLFLOW_SOURCE_TYPE])
with start_run() as active_run:
run_id = active_run.info.run_id
Expand All @@ -319,7 +319,7 @@ def test_set_tags(tracking_uri_mock):
if tag_key in approx_expected_tags:
pass
else:
assert exact_expected_tags[tag_key] == tag_val
assert str(exact_expected_tags[tag_key]) == tag_val


def test_log_metric_validation(tracking_uri_mock):
Expand All @@ -344,7 +344,7 @@ def test_log_param(tracking_uri_mock):


def test_log_params(tracking_uri_mock):
expected_params = {"name_1": "c", "name_2": "b", "nested/nested/name": "5"}
expected_params = {"name_1": "c", "name_2": "b", "nested/nested/name": 5}
with start_run() as active_run:
run_id = active_run.info.run_id
mlflow.log_params(expected_params)
Expand Down

0 comments on commit 79ece06

Please sign in to comment.