-
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
Configuration-driven DAG shaping + grouping #108
Conversation
a4eb9fd
to
4b4f996
Compare
tests/resources/dynamic_config.py
Outdated
@dynamic( | ||
lambda columns_to_sum_map: parameterize( | ||
**{ | ||
key: {"col_1": source(value[0]), "col_2": source(value[1])} | ||
for key, value in columns_to_sum_map.items() | ||
} | ||
), | ||
at=ResolveAt.COMPILE, | ||
) | ||
def generic_summation(col_1: pd.Series, col_2: pd.Series) -> pd.Series: | ||
return col_1 + col_2 |
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.
@config.inject(
lambda columns_to_sum_map: parameterize(
**{
key: {"col_1": source(value[0]), "col_2": source(value[1])}
for key, value in columns_to_sum_map.items()
}
),
at=ResolveAt.COMPILE,
)
def generic_summation(col_1: pd.Series, col_2: pd.Series) -> pd.Series:
return col_1 + col_2
I think that reads better...
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.
Yeah that's not bad
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.
OK, so I don't actually like putting this under config
now that I think about it -- its pretty confusing. Specifically, we're not actually injecting
anything, we're using it to delay evaluation. Furthermore, it doesn't actually have anything to do with the other config
decorators, which people already have a tough time understanding. Its also pretty meta, so I want it kept on its own.
I'm thinking @delay_resolution(until=CONFIG_AVAILABLE, lambda ...)
. That's very accurate what it does, lives separately, and it nice and readable.
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.
@resolve(
when=CONFIG_AVAILABLE,
decorate_with=lambda: conf_var_1 -> ...):
64f6eed
to
5e21e4b
Compare
4044982
to
27a9281
Compare
See #109 Note this makes the following decisions: 1. Chooses to use the generic `@dynamic` decorator 2. Buries it under a power-user mode 3. Uses the parameter names of the labmda/function to draw from the config We also Deprecate dynamic_transform This was an old way of doing the same thing. This was never accessible to users, as it reuqired implementing a subclass and konwing some of hamilton's internals. delay_resolution solves the same problem, and gives users access to any of the current decorators.
This is a little hacky but the API is solid. Basically this is a parameterized of 1 parameterization. It goes very well with config-driven pipelines, allowing you to group a set of functions to do stuff with.
There is a bit of duplicated code here, but its well-tested and solves a common problem. At some point we'll clean it up when we rewrite decorators, but for now this is OK. This allows mapping between the following: - group(*args) -> List[...] - group(**kwargs) -> Dict[str, ...] Anything else is not supported yet.
27a9281
to
63edecb
Compare
[Short description explaining the high-level reason for the pull request]
Changes
How I tested this
Notes
Checklist