-
Notifications
You must be signed in to change notification settings - Fork 133
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
add a "resolve from config" wrapper around the resolve decorator #828
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good! Minor change for docstring (and maybe name) then let's merge.
@@ -148,3 +148,8 @@ def resolve(self, config: Dict[str, Any], fn: Callable) -> NodeTransformLifecycl | |||
if key in config: | |||
kwargs[key] = config[key] | |||
return self.decorate_with(**kwargs) | |||
|
|||
|
|||
class resolve_from_config(resolve): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thought from @zilto -- would @resolve_at_config
be cleaner?
Also, let's add a docstring then stick it in the decorators documentation.
See https://github.com/DAGWorks-Inc/hamilton/blob/main/docs/reference/decorators/resolve.rst -- should be easy!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @resolve_at_config
better capture that it's a subset of @resolve
where we set the value of ResolveAt
to ConfigAvailable
.
There's no other ResolveAt
value, but I think the semantic make sense. I believe the name @resolve_at_config
is an improvement over @resolve
as it better communicate it's role during the Driver building.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 just to voice my opinion that resolve_from_config
doesn't need you to understand what the driver does, but it does help more clearly tie the connection that it comes from configuration passed in. Which I think for a new person to Hamilton that might be more intuitive, than resolve_at_config
since now they need to understand what "at" might be referring to.
@janhurst thoughts on the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
realistically im pretty ambivalent...
i used @resolve_from_config
for the reason @skrawcz mentioned... it described to me where the resolve was obtaining information
I think
@resolve_at_config
better capture that it's a subset of@resolve
where we set the value ofResolveAt
toConfigAvailable
.
the other way to look at this is to just default the when
of @resolve
to the only value it can use right now :) ... this is practically why i wrote my original wrapper functions anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the other way to look at this is to just default the when of @resolve to the only value it can use right now :) ... this is practically why i wrote my original wrapper functions anyway
We could do that. But would that be clear where the values come from? That's only reason we did such a verbose API in the first place -- to make it easier to read... 😆
added a little bit of a redirect to the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This works for me.
Add a small wrapper around
resolve
function modifier to "resolve from config"Changes
Add a
hamilton.function_modifiers.resolve_from_config
hook that just passesResolveAt.CONFIG_AVAILABLE
flag to the originalresolve
class.How I tested this
Have been using this as a small custom snippet (albeit not as a wrapper around the class) in some internal projects for quite a while. Its really just a convenience wrapper to make my pipeline code a little cleaner.
I've made a very small attempt to duplicate a relevant unit test.
Notes
Checklist