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

[pythonic config][alternate] properly propagate default values set at the top level for nested config classes #27209

Open
wants to merge 1 commit into
base: benpankow/partial-support
Choose a base branch
from

Conversation

benpankow
Copy link
Member

@benpankow benpankow commented Jan 17, 2025

Summary

Alternate implementation of #27206 which relies on the partial config utilities from #12870

Ensures that default values on Pythonic Config get properly propagated to inner Config classes, e.g.

class ANestedOpConfig(Config):
    an_int: int = 1
    a_bool: bool = True

class AnOpConfig(Config):
    a_string: str = "foo"
    a_nested: ANestedOpConfig = ANestedOpConfig(an_int=5)

Test Plan

New unit test; todo add a few more

@benpankow
Copy link
Member Author

benpankow commented Jan 17, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@@ -433,7 +433,6 @@ def infer_schema_from_config_class(
" definition. 'dagster.Field' should only be used in legacy Dagster config"
" schemas. Did you mean to use 'pydantic.Field' instead?"
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strange

Comment on lines +145 to +148
inferred_field = _apply_defaults_to_schema_field(
inferred_field,
pydantic_field.default._convert_to_config_dictionary(), # noqa: SLF001
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice

Comment on lines +199 to +207
a_job.execute_in_process(
{
"ops": {
"a_struct_config_op": {
"config": {"a_string": "foo", "a_nested": {"inner_config": {"a_float": 3.0}}}
}
}
}
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert result.success. Also, maybe a test on executing with no config at all (should be possible now right)

Copy link
Member

@prha prha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants