首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Flyte中传递字典作为输入类型的语法是什么?

在Flyte中传递字典作为输入类型的语法是什么?
EN

Stack Overflow用户
提问于 2019-11-16 06:49:57
回答 1查看 118关注 0票数 0

我试图将字典作为参数传递给输入,但我不太确定如何定义@ batch_sub_task。

EN

回答 1

Stack Overflow用户

发布于 2019-11-21 16:00:49

您尝试过将Types.Generic作为类型吗?它映射到Python中的json对象。

代码语言:javascript
复制
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)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58885690

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档