【问题标题】:Noneable type for Field in solid config not allowing null values实体配置中字段的不可设置类型不允许空值
【发布时间】:2020-10-08 10:49:25
【问题描述】:

我希望 Dagster 接受 config.yaml 中的空参数并将它们视为具有 None 的值。

当我启动 dagit 时,我可以看到参数为空。这是有道理的,因为我在 config.yaml 中将参数的值留空。

但是,当我执行管道时,我收到以下错误:

我不确定为什么当我在可靠配置中指定 Noneable(str) 类型时它会期望一个类 str 的值。有趣的是,当我在 dagit 中为 example_parameter 传入一个非空值时,管道执行得非常好。

以下是我用于实体的配置

@solid(
    description="Example solid",
    config={
        "example_parameter": Field(
                 Noneable(str),
                 is_required=False
        )
    }
)
def example_solid(context):
"""an example solid"""
   etc...

如何让 dagster 接受空值并将它们解析为 None?

【问题讨论】:

    标签: config nonetype valueerror dagster


    【解决方案1】:

    我尝试重现,但管道使用您共享的代码 sn-p 和以下配置成功运行。您使用的是哪个版本的 dagster/您可以尝试升级到最新版本 (0.8.3)?

    @solid(
        description="Example solid",
        config={
            "example_parameter": Field(
                     Noneable(str),
                     is_required=False
            )
        }
    )
    def example_solid(context):
        context.log.info(str(context.solid_config['example_parameter']))
        pass
    
    @pipeline
    def example_pipeline():
        example_solid()
    

    带配置

    solids:
      example_solid:
        config:
          example_parameter: null
    

    【讨论】:

      猜你喜欢
      • 2021-04-19
      • 2015-12-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多