Skip to content

Commit

Permalink
Adds more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
skrawcz committed Dec 12, 2024
1 parent 169862d commit 4611553
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hamilton/function_modifiers/recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
13 changes: 13 additions & 0 deletions tests/function_modifiers/test_recursive.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
InvalidDecoratorException,
config,
configuration,
group,
parameterized_subdag,
recursive,
subdag,
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4611553

Please sign in to comment.