diff --git a/hamilton/function_modifiers/recursive.py b/hamilton/function_modifiers/recursive.py index 72c9160c4..d86ad74f1 100644 --- a/hamilton/function_modifiers/recursive.py +++ b/hamilton/function_modifiers/recursive.py @@ -147,6 +147,11 @@ def _resolve_subdag_configuration( sources_to_map[key] = value.source elif isinstance(value, dependencies.LiteralDependency): values_to_include[key] = value.value + elif isinstance(value, (dependencies.GroupedDependency, dependencies.SingleDependency)): + raise InvalidDecoratorException( + f"`{value}` is not allowed in the config= part of the subdag decorator. " + "Please use `configuration()` or `value()` or literal python values." + ) plain_configs = { k: v for k, v in fields.items() if k not in sources_to_map and k not in values_to_include } diff --git a/tests/function_modifiers/test_recursive.py b/tests/function_modifiers/test_recursive.py index 6cdcf1065..f2f35ee71 100644 --- a/tests/function_modifiers/test_recursive.py +++ b/tests/function_modifiers/test_recursive.py @@ -11,6 +11,7 @@ InvalidDecoratorException, config, configuration, + group, parameterized_subdag, recursive, subdag, @@ -497,6 +498,18 @@ def test_resolve_subdag_configuration_bad_mapping(): recursive._resolve_subdag_configuration(_configuration, fields, "test") +def test_resolve_subdag_configuration_flag_incorrect_source_group_deps(): + _configuration = {"a": 1, "b": 2} + with pytest.raises(InvalidDecoratorException): + recursive._resolve_subdag_configuration( + _configuration, {"c": value(3), "d": source("e")}, "test" + ) + with pytest.raises(InvalidDecoratorException): + recursive._resolve_subdag_configuration( + _configuration, {"c": value(3), "d": group(source("e"))}, "test" + ) + + def test_subdag_with_external_nodes_input(): def bar(input_1: int) -> int: return input_1 + 1