def define_builtin_scalar_input_schema(scalar_name, config_scalar_type):
    def _external_version_fn(val):
        from dagster.core.execution.resolve_versions import join_and_hash

        return join_and_hash(str(val), )

    check.str_param(scalar_name, "scalar_name")
    check.inst_param(config_scalar_type, "config_scalar_type", ConfigType)
    check.param_invariant(config_scalar_type.kind == ConfigTypeKind.SCALAR,
                          "config_scalar_type")
    # TODO: https://github.com/dagster-io/dagster/issues/3084
    with warnings.catch_warnings():
        warnings.simplefilter("ignore", category=ExperimentalWarning)

        @dagster_type_loader(
            ScalarUnion(
                scalar_type=config_scalar_type,
                non_scalar_schema=define_typed_input_schema_dict(
                    config_scalar_type),
            ),
            loader_version=
            scalar_name,  # different for each scalar type this is called upon
            external_version_fn=_external_version_fn,
        )
        def _builtin_input_schema(_context, value):
            return load_type_input_schema_dict(value) if isinstance(
                value, dict) else value

    return _builtin_input_schema
예제 #2
0
def define_builtin_scalar_input_schema(scalar_name, config_scalar_type):
    def _external_version_fn(val):
        from dagster.core.execution.resolve_versions import join_and_hash

        return join_and_hash(str(val), )

    check.str_param(scalar_name, "scalar_name")
    check.inst_param(config_scalar_type, "config_scalar_type", ConfigType)
    check.param_invariant(config_scalar_type.kind == ConfigTypeKind.SCALAR,
                          "config_scalar_type")

    @dagster_type_loader(
        ScalarUnion(
            scalar_type=config_scalar_type,
            non_scalar_schema=define_typed_input_schema_dict(
                config_scalar_type),
        ),
        loader_version=
        scalar_name,  # different for each scalar type this is called upon
        external_version_fn=_external_version_fn,
    )
    def _builtin_input_schema(_context, value):
        return load_type_input_schema_dict(value) if isinstance(
            value, dict) else value

    return _builtin_input_schema
예제 #3
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),
     }
예제 #4
0
def define_builtin_scalar_input_schema(scalar_name, config_scalar_type):
    check.str_param(scalar_name, 'scalar_name')
    check.inst_param(config_scalar_type, 'config_scalar_type', ConfigType)
    check.param_invariant(config_scalar_type.kind == ConfigTypeKind.SCALAR, 'config_scalar_type')

    @dagster_type_loader(
        ScalarUnion(
            scalar_type=config_scalar_type,
            non_scalar_schema=define_typed_input_schema_dict(config_scalar_type),
        )
    )
    def _builtin_input_schema(_context, value):
        return load_type_input_schema_dict(value) if isinstance(value, dict) else value

    return _builtin_input_schema
예제 #5
0
def _construct_scalar_union_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) == 2,
        'Expect SCALAR_UNION to provide a scalar key and a non scalar key. Snapshot Provided: {}'
        .format(config_type_snap.type_param_keys),
    )

    return ScalarUnion(
        scalar_type=construct_config_type_from_snap(
            config_snap_map[config_type_snap.type_param_keys[0]],
            config_snap_map),
        non_scalar_type=construct_config_type_from_snap(
            config_snap_map[config_type_snap.type_param_keys[1]],
            config_snap_map),
    )
예제 #6
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.",
         ),
     }