Skip to content

Commit

Permalink
Add test to stop a future nested config regression (#27343)
Browse files Browse the repository at this point in the history
## Summary & Motivation

Guard against regression of #27223

## How I Tested These Changes

Local run + BK
  • Loading branch information
deepyaman authored Jan 28, 2025
1 parent db62227 commit 742ac38
Showing 1 changed file with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from pydantic import (
Field as PyField,
ValidationError,
create_model,
)


Expand Down Expand Up @@ -584,6 +585,44 @@ def an_asset(users_resource: UsersResource):
assert executed["yes"]


# https://github.com/dagster-io/dagster/issues/27223
@pytest.mark.parametrize("child_resource_fields_all_have_default_values", [True, False])
def test_nested_config_class_with_runtime_config(
child_resource_fields_all_have_default_values: bool,
) -> None:
# Type hinting a dynamically-generated Pydantic model is impossible:
# https://stackoverflow.com/q/78838473
ChildResource = create_model(
"ChildResource",
date=(str, "2025-01-20" if child_resource_fields_all_have_default_values else ...),
__base__=ConfigurableResource,
)

class ParentResource(ConfigurableResource):
child: ChildResource # pyright: ignore[reportInvalidTypeForm]

@asset
def test_asset(
child: ChildResource, # pyright: ignore[reportInvalidTypeForm]
parent: ParentResource,
) -> None:
assert child.date == "2025-01-21"
assert parent.child.date == "2025-01-21"

child = ChildResource.configure_at_launch()
materialize(
[test_asset],
resources={
"child": child,
"parent": ParentResource.configure_at_launch(child=child),
},
run_config={
"loggers": {"console": {"config": {"log_level": "ERROR"}}},
"resources": {"child": {"config": {"date": "2025-01-21"}}},
},
)


def test_using_enum_simple() -> None:
executed = {}

Expand Down

0 comments on commit 742ac38

Please sign in to comment.