[components] Put resolvers back on ResolvableSchema #27734
+158
−256
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary & Motivation
Reviving some ideas that we strayed away from, remixed slightly.
Some nice things about this iteration:
resolve_fields()
to get a dictionary of all the resolved fields, and you can optionally exclude some or add some more in as desired (see: AssetSpec). This means that stack traces will be prettycontext.resolve(self.assets)
. This means that if we plug this value into an incompatible spot, the type system can warn us ahead of time. I've also set the overloads up such that if the type system can't infer what type something will turn into (i.e. you're just resolving an arbitrary string), you're forced to put theas_type
parameter in to tell us what you think it will be. I didn't actually wire this up to any checking code yet, but that's a natural extension.get_resolved_fields()
, there's really not a ton of boilerplate.Some bad things about this iteration:
resolve
on some schemas andresolve_as
on others? This is because we need to support the case where we create a subclass of a Component. If we just made the schema directly resolve into (e.g.)DbtProjectComponent
, thenload()
would always returnDbtProjectComponent
instead of the subclass that you actually want.cls(not_a_field=1)
is invalid when done inside of theresolve_as()
method (try as I might to type the input parameter). In contrast, if you do the resolution inside of theload()
method, things work out just fine.One solution here might just be convention. We could create a
ResolvedDbtProjectSchema
type, and haveDbtProjectSchema
resolve into that, then define an explicitload()
method onDbtProjectComponent
that looks like:That way, we'd be able to get rid of the
resolve_as
method entirely.How I Tested These Changes
Changelog
NOCHANGELOG