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

feat(PipelineJob): support dict, list, bool typed input parameters fr… #693

Merged
merged 5 commits into from Sep 16, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 6 additions & 1 deletion google/cloud/aiplatform/utils/pipeline_utils.py
Expand Up @@ -15,6 +15,7 @@
#

import copy
import json
from typing import Any, Dict, Mapping, Optional, Union


Expand Down Expand Up @@ -89,7 +90,11 @@ def update_runtime_parameters(
Optional. The mapping from runtime parameter names to its values.
"""
if parameter_values:
self._parameter_values.update(parameter_values)
parameters = dict(parameter_values)
for k, v in parameter_values.items():
if isinstance(v, (dict, list, bool)):
ivanmkc marked this conversation as resolved.
Show resolved Hide resolved
parameters[k] = json.dumps(v)
self._parameter_values.update(parameters)

def build(self) -> Dict[str, Any]:
"""Build a RuntimeConfig proto.
Expand Down
14 changes: 13 additions & 1 deletion tests/unit/aiplatform/test_utils.py
Expand Up @@ -370,6 +370,9 @@ class TestPipelineUtils:
"int_param": {"type": "INT"},
"float_param": {"type": "DOUBLE"},
"new_param": {"type": "STRING"},
"bool_param": {"type": "STRING"},
"dict_param": {"type": "STRING"},
"list_param": {"type": "STRING"},
}
}
}
Expand Down Expand Up @@ -430,7 +433,13 @@ def test_pipeline_utils_runtime_config_builder_with_merge_updates(self):
)
my_builder.update_pipeline_root("path/to/my/new/root")
my_builder.update_runtime_parameters(
{"int_param": 888, "new_param": "new-string"}
{
"int_param": 888,
"new_param": "new-string",
"dict_param": {"a": 1},
"list_param": [1, 2, 3],
"bool_param": True,
}
)
actual_runtime_config = my_builder.build()

Expand All @@ -441,6 +450,9 @@ def test_pipeline_utils_runtime_config_builder_with_merge_updates(self):
"int_param": {"intValue": 888},
"float_param": {"doubleValue": 3.14},
"new_param": {"stringValue": "new-string"},
"dict_param": {"stringValue": '{"a": 1}'},
"list_param": {"stringValue": "[1, 2, 3]"},
"bool_param": {"stringValue": "true"},
},
}
assert expected_runtime_config == actual_runtime_config
Expand Down