示例#1
0
 def config_type(cls):
     return {
         "max_concurrent_runs":
         Field(config=IntSource, is_required=False),
         "tag_concurrency_limits":
         Field(
             config=Noneable(
                 Array(
                     Shape({
                         "key":
                         String,
                         "value":
                         Field(
                             ScalarUnion(
                                 scalar_type=String,
                                 non_scalar_schema=Shape(
                                     {"applyLimitPerUniqueValue": Bool}),
                             ),
                             is_required=False,
                         ),
                         "limit":
                         Field(int),
                     }))),
             is_required=False,
         ),
         "dequeue_interval_seconds":
         Field(config=IntSource, is_required=False),
     }
示例#2
0
def _construct_noneable_from_snap(config_type_snap, config_snap_map):
    check.list_param(config_type_snap.type_param_keys, 'type_param_keys', str)
    check.invariant(
        len(config_type_snap.type_param_keys) == 1,
        'Expect NONEABLE to provide a single inner type. Snapshot provided: {}'
        .format(config_type_snap.type_param_keys),
    )
    return Noneable(
        construct_config_type_from_snap(
            config_snap_map[config_type_snap.type_param_keys[0]],
            config_snap_map))
def test_deserialize_solid_def_snaps_noneable():
    @solid(config=Field(Noneable(str)))
    def noop_solid(_):
        pass

    @pipeline
    def noop_pipeline():
        noop_solid()

    pipeline_snapshot = PipelineSnapshot.from_pipeline_def(noop_pipeline)
    solid_def_snap = pipeline_snapshot.get_solid_def_snap('noop_solid')
    recevied_config_type = pipeline_snapshot.get_config_type_from_solid_def_snap(solid_def_snap)
    assert isinstance(recevied_config_type, Noneable)
    assert isinstance(recevied_config_type.inner_type, String)
示例#4
0
 def config_type(cls):
     return {
         "max_concurrent_runs":
         Field(
             config=IntSource,
             is_required=False,
             description=
             "The maximum number of runs that are allowed to be in progress at once. "
             "Defaults to 10. Set to -1 to disable the limit. Set to 0 to stop any runs from launching. "
             "Any other negative values are disallowed.",
         ),
         "tag_concurrency_limits":
         Field(
             config=Noneable(
                 Array(
                     Shape({
                         "key":
                         String,
                         "value":
                         Field(
                             ScalarUnion(
                                 scalar_type=String,
                                 non_scalar_schema=Shape(
                                     {"applyLimitPerUniqueValue": Bool}),
                             ),
                             is_required=False,
                         ),
                         "limit":
                         Field(int),
                     }))),
             is_required=False,
             description=
             "A set of limits that are applied to runs with particular tags. "
             "If a value is set, the limit is applied to only that key-value pair. "
             "If no value is set, the limit is applied across all values of that key. "
             "If the value is set to a dict with `applyLimitPerUniqueValue: true`, the limit "
             "will apply to the number of unique values for that key.",
         ),
         "dequeue_interval_seconds":
         Field(
             config=IntSource,
             is_required=False,
             description=
             "The interval in seconds at which the Dagster Daemon "
             "should periodically check the run queue for new runs to launch.",
         ),
     }
 def config_type(cls):
     return {
         "max_concurrent_runs":
         Field(config=int, is_required=False),
         "tag_concurrency_limits":
         Field(
             config=Noneable(
                 Array(
                     Shape({
                         "key": String,
                         "value": Field(String, is_required=False),
                         "limit": Field(int),
                     }))),
             is_required=False,
         ),
         "dequeue_interval_seconds":
         Field(config=int, is_required=False),
     }
def test_deserialize_solid_def_snaps_multi_type_config(snapshot):
    @solid(config=Field(
        Permissive({
            'foo':
            Field(Array(float)),
            'bar':
            Selector({
                'baz': Field(Noneable(int)),
                'qux': {
                    'quux':
                    Field(str),
                    'corge':
                    Field(
                        Enum(
                            'RGB',
                            [
                                EnumValue('red'),
                                EnumValue('green'),
                                EnumValue('blue')
                            ],
                        )),
                },
            }),
        })))
    def fancy_solid(_):
        pass

    @pipeline
    def noop_pipeline():
        fancy_solid()

    pipeline_snapshot = PipelineSnapshot.from_pipeline_def(noop_pipeline)
    solid_def_snap = pipeline_snapshot.get_solid_def_snap('fancy_solid')
    recevied_config_type = pipeline_snapshot.get_config_type_from_solid_def_snap(
        solid_def_snap)
    snapshot.assert_match(
        serialize_pp(snap_from_config_type(recevied_config_type)))
    _map_has_stable_hashes(
        recevied_config_type,
        pipeline_snapshot.config_schema_snapshot.all_config_snaps_by_key)
示例#7
0
def test_deserialize_solid_def_snaps_multi_type_config(snapshot):
    @solid(config_schema=Field(
        Permissive({
            "foo":
            Field(Array(float)),
            "bar":
            Selector({
                "baz": Field(Noneable(int)),
                "qux": {
                    "quux":
                    Field(str),
                    "corge":
                    Field(
                        Enum(
                            "RGB",
                            [
                                EnumValue("red"),
                                EnumValue("green"),
                                EnumValue("blue")
                            ],
                        )),
                },
            }),
        })))
    def fancy_solid(_):
        pass

    @pipeline
    def noop_pipeline():
        fancy_solid()

    pipeline_snapshot = PipelineSnapshot.from_pipeline_def(noop_pipeline)
    solid_def_snap = pipeline_snapshot.get_solid_def_snap("fancy_solid")
    recevied_config_type = pipeline_snapshot.get_config_type_from_solid_def_snap(
        solid_def_snap)
    snapshot.assert_match(
        serialize_pp(snap_from_config_type(recevied_config_type)))
    _map_has_stable_hashes(
        recevied_config_type,
        pipeline_snapshot.config_schema_snapshot.all_config_snaps_by_key)