Skip to content

Commit

Permalink
feat(PipelineJob): support dict, list, bool typed input parameters fr… (
Browse files Browse the repository at this point in the history
#693)

* chore: release 1.4.2

Release-As: 1.4.2

* address comments
  • Loading branch information
ji-yaqi committed Sep 16, 2021
1 parent 64768c3 commit 243b75c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
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)):
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

0 comments on commit 243b75c

Please sign in to comment.