-
Notifications
You must be signed in to change notification settings - Fork 832
Extend the use of config_expr #2409
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
base: master
Are you sure you want to change the base?
Conversation
Now allows: @Environment(vars=config_expr("...")) - This was broken since vars was a ConfigValue and not an updatable dictionary @project(name=config_expr("get_my_name(cfg)")) - This was broken because when evaluating the config_expr, we did not consider the globals at the point of call but instead inside the file defining config_expr. Tests are deployed internally.
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.
Pull Request Overview
This PR extends the functionality of config_expr by allowing globals from the user’s call site to be captured and by adding a to_dict conversion for delayed evaluations.
- Propagate saved globals via the constructor for DelayEvaluator
- Introduce a new to_dict parameter in resolve_delayed_evaluator and update related usages
- Adjust delayed-evaluator resolution in decorators and parameters to incorporate the to_dict conversion
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
metaflow/user_configs/config_parameters.py | Updated DelayEvaluator to accept saved_globals; adjusted eval usage and config_expr to capture caller globals; added to_dict conversion in resolve_delayed_evaluator |
metaflow/parameters.py | Updated resolve_delayed_evaluator calls to include to_dict conversion |
metaflow/decorators.py | Updated delayed evaluator unpacking and re-resolution to use the to_dict flag |
Comments suppressed due to low confidence (1)
metaflow/user_configs/config_parameters.py:389
- [nitpick] Consider enhancing the docstring or adding inline comments for the new 'to_dict' parameter to clarify its behavior and when its conversion is applied.
def resolve_delayed_evaluator(v: Any, ignore_errors: bool = False, to_dict: bool = False) -> Any:
@@ -157,8 +158,9 @@ class DelayEvaluator(collections.abc.Mapping): | |||
of _unpacked_delayed_* | |||
""" | |||
|
|||
def __init__(self, ex: str): | |||
def __init__(self, ex: str, saved_globals: Optional[Dict[str, Any]] = None): |
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.
[nitpick] The constructor now accepts a new parameter 'saved_globals'. Consider updating the class docstring to explain the purpose and usage of this parameter to help future maintainers.
Copilot uses AI. Check for mistakes.
Netflix internal testing[1112] @ d6298d5 |
- fixes a case where configs and Runner/Deployer were not compatible due to configs not being processed in the same cwd - fixes an issue with constructing the config values (introduced in previous commit) - fixes the error message when both default and specified config files are not found
Previously something like: RETRIES = config_expr("settings").retry class MyFlow(FlowSpec): @retries(times=RETRIES) @step def start(self): ... @retries(times=RETRIES) @step def end(self): ... would fail. Also, something like: FOO = config_expr("settings").foo.bar BAR = FOO.BAZ BLAH = FOO.BAZ2 would also fail. This fixes these issues by copying DelayEvaluator everytime and also making the `__call__` function reentrant.
Now allows:
@Environment(vars=config_expr("..."))
@project(name=config_expr("get_my_name(cfg)"))
Tests are deployed internally.