Reputation: 3233
I'm trying to pass a dictionary as a parameter to a batch_sub_task, but I'm not quite sure how to define the @input.
Upvotes: 0
Views: 413
Reputation: 76
Have you tried Types.Generic
as the type? It maps to a json object in Python.
Use this to specify a simple JSON type.
When used with an SDK-decorated method, expect this behavior from the default type engine:
As input:
1) If set, a Python dict with JSON-ifiable primitives and nested lists or maps.
2) Otherwise, a None value will be received.
As output:
1) User code may pass a Python dict with arbitrarily nested lists and dictionaries. JSON-ifiable
primitives may also be specified.
2) Output can also be nulled with a None value.
From command-line:
Specify a JSON string.
.. code-block:: python
@inputs(a=Types.Generic)
@outputs(b=Types.Generic)
@python_task
def operate(wf_params, a, b):
if a['operation'] == 'add':
a['value'] += a['operand'] # a['value'] is a number
elif a['operation'] == 'merge':
a['value'].update(a['some']['nested'][0]['field'])
b.set(a)
Upvotes: 0