Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested configurable resources not initialised if all the fields have default values #27223

Open
tonyyzy opened this issue Jan 20, 2025 · 0 comments
Labels
type: bug Something isn't working

Comments

@tonyyzy
Copy link

tonyyzy commented Jan 20, 2025

What's the issue?

  • ConfigurableResource A is used to configure ConfigurableResource B
  • Run time config is set on A
  • If all A's fields have default values, B does not see the run time configs

What did you expect to happen?

B would get the runtime config via A

How to reproduce?

from dagster import (
    ConfigurableResource,
    asset,
    materialize,
)


class ResourceA(ConfigurableResource):
    date: str = "2025-01-20"


class ResourceB(ConfigurableResource):
    resource_a: ResourceA


@asset
def test_asset(resource_A: ResourceA, resource_B: ResourceB) -> None:
    print("resource A's date: ", resource_A.date)
    print("resource B's resource A's date: ", resource_B.resource_a.date)


resource_A = ResourceA.configure_at_launch()
materialize(
    [test_asset],
    resources={
        "resource_A": resource_A,
        "resource_B": ResourceB.configure_at_launch(resource_a=resource_A),
    },
    run_config={
        "loggers": {"console": {"config": {"log_level": "ERROR"}}},
        "resources": {"resource_A": {"config": {"date": "2025-01-21"}}},
    },
)

This gives

resource A's date:  2025-01-21
resource B's resource A's date:  2025-01-20

while I'd expect

resource A's date:  2025-01-21
resource B's resource A's date:  2025-01-21

If some fields of A do not have default values

from dagster import (
    ConfigurableResource,
    asset,
    materialize,
)


class ResourceA(ConfigurableResource):
    date: str


class ResourceB(ConfigurableResource):
    resource_a: ResourceA


@asset
def test_asset(resource_A: ResourceA, resource_B: ResourceB) -> None:
    print("resource A's date: ", resource_A.date)
    print("resource B's resource A's date: ", resource_B.resource_a.date)


resource_A = ResourceA.configure_at_launch()
materialize(
    [test_asset],
    resources={
        "resource_A": resource_A,
        "resource_B": ResourceB.configure_at_launch(resource_a=resource_A),
    },
    run_config={
        "loggers": {"console": {"config": {"log_level": "ERROR"}}},
        "resources": {"resource_A": {"config": {"date": "2025-01-21"}}},
    },
)

This gives the expected output

resource A's date:  2025-01-21
resource B's resource A's date:  2025-01-21

Dagster version

dagster, version 1.7.16

Deployment type

None

Deployment details

No response

Additional information

No response

Message from the maintainers

Impacted by this issue? Give it a 👍! We factor engagement into prioritization.

@tonyyzy tonyyzy added the type: bug Something isn't working label Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant