Dagster 在配置模式中传递有序字典

Dagster pass ordered dict in the config schema

如何在 Dagster solid 的配置模式中传递有序词典?

简单的事情:

from dagster import solid, execute_solid, Field


@solid(config_schema={'my_dict': Field(dict, is_required=True)})
def test_ordered_dict(context):
    print('\n\n>>>>>>>>>>>>>>>>>>>>>>>>>>>')
    print(context.solid_config['my_dict'])
    print('\n\n<<<<<<<<<<<<<<<<<<<<<<<<<<<')


for i in range(20):
    execute_solid(test_ordered_dict,
                  run_config={
                      'solids': {
                          'test_ordered_dict': {
                              'config': {
                                  'my_dict': {
                                      'a': 1,
                                      'b': 2
                                  }
                              }
                          }
                      }
                  })

不起作用。在 Windows 10 上执行此操作始终给出

2021-03-31 18:16:57 - dagster - DEBUG - ephemeral_test_ordered_dict_solid_pipeline - 8e87a380-7ee5-40b6-954e-3ae33b5784e7 - 26348 - test_ordered_dict - STEP_START - Started execution of step "test_ordered_dict".


>>>>>>>>>>>>>>>>>>>>>>>>>>>
{'b': 2, 'a': 1}


<<<<<<<<<<<<<<<<<<<<<<<<<<<
2021-03-31 18:16:57 - dagster - DEBUG - ephemeral_test_ordered_dict_solid_pipeline - 8e87a380-7ee5-40b6-954e-3ae33b5784e7 - 26348 - test_ordered_dict - STEP_OUTPUT - Yielded output "result" of type "Any". (Type check passed).

在 Linux 上,它有时会切换它们,这对我不起作用。

如何在配置架构中传递 collections.OrderedDict,以便字典中的条目按照我在架构中传递的条目完全排序?

这是一个已修复的错误 https://github.com/dagster-io/dagster/discussions/3977