flytekit icon indicating copy to clipboard operation
flytekit copied to clipboard

Support overriding task annotations and labels via with_overrides

Open arbaobao opened this issue 1 year ago • 3 comments

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

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

arbaobao avatar Jan 15 '25 09:01 arbaobao

Code Review Agent Run #2c0fc5

Actionable Suggestions - 2
  • flytekit/core/node.py - 1
    • Consider consolidating duplicate validation logic · Line 228-234
  • flytekit/tools/translator.py - 1
Review Details
  • Files reviewed - 6 · Commit Range: 44e8c1b..44e8c1b
    • flytekit/core/node.py
    • flytekit/models/core/workflow.py
    • flytekit/tools/translator.py
    • tests/flytekit/unit/core/test_array_node_map_task.py
    • tests/flytekit/unit/core/test_map_task.py
    • tests/flytekit/unit/core/test_node_creation.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

AI Code Review powered by Bito Logo

flyte-bot avatar Jan 15 '25 09:01 flyte-bot

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Feature Improvement - Task Node Override Enhancement

node.py - Added support for labels and annotations in Node class

workflow.py - Implemented label and annotation fields in TaskNodeOverrides

translator.py - Added serialization support for labels and annotations

Testing - Test Coverage for Label and Annotation Overrides

test_array_node_map_task.py - Added tests for map task overrides with labels and annotations

test_map_task.py - Added tests for map task label and annotation overrides

test_node_creation.py - Added dedicated tests for label and annotation overrides

flyte-bot avatar Jan 15 '25 09:01 flyte-bot

Code Review Agent Run #db4a2c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 6 · Commit Range: e485d6a..7df32f2
    • flytekit/core/node.py
    • flytekit/models/core/workflow.py
    • flytekit/tools/translator.py
    • tests/flytekit/unit/core/test_array_node_map_task.py
    • tests/flytekit/unit/core/test_map_task.py
    • tests/flytekit/unit/core/test_node_creation.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

AI Code Review powered by Bito Logo

flyte-bot avatar Jan 15 '25 16:01 flyte-bot