flytekit
flytekit copied to clipboard
Support overriding task annotations and labels via with_overrides
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
python
@task
def say_hello() -> str:
return "Hello, World!"
@workflow
def hello_world_wf() -> str:
res = say_hello().with_overrides(labels={"lKeyA": "lValA"},annotations={"lKeyB": "lValB"})
return res
It can be tested by using kubectl describe pods {pod_name} -n flytesnacks-development
Screenshots
Check all the applicable boxes
- [ ] I updated the documentation accordingly.
- [ ] All new and existing tests passed.
- [X] All commits are signed-off.
Related PRs
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