How to have a default for Pydantic Discriminated Union #31737
Unanswered
SjoerdTUDelft
asked this question in
Q&A
Replies: 1 comment
-
I am also struggling with this issue. If there is a solution out there I would love to know! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a dagster job with many discriminated unions, I want to have simple yaml files without specifying every field to run everything but I run into the issue that for discriminated unions the default always seems to be explicitely given in the yaml even though the default is also present in the pydantic definition.
I looked into the source code of dagster and my impression is that this is not supported, at least looking at the following file I see no default is passed:
dagster/_config/pythonic_config/conversion_utils.py(288)_convert_pydantic_discriminated_union_field
with the following line missing a value for the default:
return Field(config=Selector(fields=dagster_config_field_mapping) })
So my question is whether I can somehow still get the desired effect of using unions without having to specify them in the yaml. And if it is not possible, how difficult does it seem to add this functionality?
An example:
Error when running without a value specified in the yaml:
Beta Was this translation helpful? Give feedback.
All reactions