-
Notifications
You must be signed in to change notification settings - Fork 305
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
Support overriding task annotations and labels via with_overrides #3061
base: master
Are you sure you want to change the base?
Conversation
Code Review Agent Run #2c0fc5Actionable Suggestions - 2
Review Details
|
Changelist by BitoThis pull request implements the following key changes.
|
if annotations is not None: | ||
assert_not_promise(annotations, "annotations") | ||
self._annotations = annotations | ||
|
||
if labels is not None: | ||
assert_not_promise(labels, "labels") | ||
self._labels = labels |
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.
Consider consolidating the duplicate validation logic for annotations
and labels
into a helper function to reduce code duplication. The same pattern of checking for None
and calling assert_not_promise()
is repeated.
Code suggestion
Check the AI-generated fix before applying
if annotations is not None: | |
assert_not_promise(annotations, "annotations") | |
self._annotations = annotations | |
if labels is not None: | |
assert_not_promise(labels, "labels") | |
self._labels = labels | |
def _validate_dict_param(value: Optional[Dict[str, str]], param_name: str) -> None: | |
if value is not None: | |
assert_not_promise(value, param_name) | |
setattr(self, f"_{param_name}", value) | |
_validate_dict_param(annotations, "annotations") | |
_validate_dict_param(labels, "labels") |
Code Review Run #2c0fc5
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
annotations=entity._annotations, | ||
labels=entity._labels, |
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.
Consider adding validation for _annotations
and _labels
before passing them to TaskNodeOverrides
. These fields could potentially be None
which may cause issues downstream.
Code suggestion
Check the AI-generated fix before applying
annotations=entity._annotations, | |
labels=entity._labels, | |
annotations=entity._annotations if entity._annotations is not None else {}, | |
labels=entity._labels if entity._labels is not None else {}, |
Code Review Run #2c0fc5
Is this a valid issue, or was it incorrectly flagged by the Agent?
- it was incorrectly flagged
Signed-off-by: Nelson Chen <asd3431090@gmail.com>
84c3cad
to
7df32f2
Compare
Code Review Agent Run #db4a2cActionable Suggestions - 0Review Details
|
Tracking issue
Why are the changes needed?
Improvement to allow setting labels and annotations dynamically at run time for things like cost allocation.
What changes were proposed in this pull request?
Adds labels and annotations to with_overrides().
How was this patch tested?
Excute a workflow and using with_override(labels={"lKeyA": "lValA"},annotations={"lKeyB": "lValB"}).
Setup process
It can be tested by using kubectl describe pods {pod_name} -n flytesnacks-development
Screenshots
Check all the applicable boxes
Related PRs
flyte 6171
Docs link
Summary by Bito
Implementation of task annotations and labels override functionality via with_overrides() method. Added label and annotation fields to Node class and TaskNodeOverrides with serialization support. Enables dynamic runtime configuration of labels/annotations for cost allocation purposes. Includes comprehensive test coverage across various task types.Unit tests added: True
Estimated effort to review (1-5, lower is better): 2