Skip to content

Commit 243b75c

Browse files
authored
feat(PipelineJob): support dict, list, bool typed input parameters fr… (#693)
* chore: release 1.4.2 Release-As: 1.4.2 * address comments
1 parent 64768c3 commit 243b75c

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

google/cloud/aiplatform/utils/pipeline_utils.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#
1616

1717
import copy
18+
import json
1819
from typing import Any, Dict, Mapping, Optional, Union
1920

2021

@@ -89,7 +90,11 @@ def update_runtime_parameters(
8990
Optional. The mapping from runtime parameter names to its values.
9091
"""
9192
if parameter_values:
92-
self._parameter_values.update(parameter_values)
93+
parameters = dict(parameter_values)
94+
for k, v in parameter_values.items():
95+
if isinstance(v, (dict, list, bool)):
96+
parameters[k] = json.dumps(v)
97+
self._parameter_values.update(parameters)
9398

9499
def build(self) -> Dict[str, Any]:
95100
"""Build a RuntimeConfig proto.

tests/unit/aiplatform/test_utils.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,9 @@ class TestPipelineUtils:
370370
"int_param": {"type": "INT"},
371371
"float_param": {"type": "DOUBLE"},
372372
"new_param": {"type": "STRING"},
373+
"bool_param": {"type": "STRING"},
374+
"dict_param": {"type": "STRING"},
375+
"list_param": {"type": "STRING"},
373376
}
374377
}
375378
}
@@ -430,7 +433,13 @@ def test_pipeline_utils_runtime_config_builder_with_merge_updates(self):
430433
)
431434
my_builder.update_pipeline_root("path/to/my/new/root")
432435
my_builder.update_runtime_parameters(
433-
{"int_param": 888, "new_param": "new-string"}
436+
{
437+
"int_param": 888,
438+
"new_param": "new-string",
439+
"dict_param": {"a": 1},
440+
"list_param": [1, 2, 3],
441+
"bool_param": True,
442+
}
434443
)
435444
actual_runtime_config = my_builder.build()
436445

@@ -441,6 +450,9 @@ def test_pipeline_utils_runtime_config_builder_with_merge_updates(self):
441450
"int_param": {"intValue": 888},
442451
"float_param": {"doubleValue": 3.14},
443452
"new_param": {"stringValue": "new-string"},
453+
"dict_param": {"stringValue": '{"a": 1}'},
454+
"list_param": {"stringValue": "[1, 2, 3]"},
455+
"bool_param": {"stringValue": "true"},
444456
},
445457
}
446458
assert expected_runtime_config == actual_runtime_config

0 commit comments

Comments
 (0)