Skip to content
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

Improve podtemplate override logic #3117

Merged
merged 9 commits into from
Feb 11, 2025

Conversation

arbaobao
Copy link
Contributor

@arbaobao arbaobao commented Feb 7, 2025

Tracking issue

Issue#5683

Why are the changes needed?

  1. If overrides podTemplate is not defined, tCtx.TaskExecutionMetadata().GetOverrides().GetPodTemplate() should be nil.
  2. Remove duplicate code.

What changes were proposed in this pull request?

  1. If overrides pod_template is none ,return pod_template=None in TaskNodeOverrides.

How was this patch tested?

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Summary by Bito

Enhancement to workflow module's pod template override handling and authentication system. Introduces thread-safe factory patterns, environment validation, and secure pip secret mount support for image building. Improves type system handling with simplified pickle detection and type extraction. Includes restructured TaskNodeOverrides class with proper serialization support and comprehensive test coverage.

Unit tests added: True

Estimated effort to review (1-5, lower is better): 5

Signed-off-by: Nelson Chen <[email protected]>
Signed-off-by: Nelson Chen <[email protected]>
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 7, 2025

Code Review Agent Run #833d42

Actionable Suggestions - 1
  • flytekit/models/core/workflow.py - 1
    • Consider extracting pod template override logic · Line 645-659
Review Details
  • Files reviewed - 1 · Commit Range: f5acd79..190fdfd
    • flytekit/models/core/workflow.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

Signed-off-by: Nelson Chen <[email protected]>
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 7, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Feature Improvement - Enhanced Pod Template Override Handling

workflow.py - Refactored pod template override logic for better null handling and code organization

test_workflow.py - Added test cases to verify pod template override behavior

@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 7, 2025

Code Review Agent Run #85621c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 190fdfd..21c407d
    • flytekit/models/core/workflow.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

Copy link
Collaborator

@eapolinario eapolinario left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add a few unit tests?

Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 79.62%. Comparing base (d732d6f) to head (27d7391).

Files with missing lines Patch % Lines
flytekit/models/core/workflow.py 50.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3117      +/-   ##
==========================================
- Coverage   79.64%   79.62%   -0.03%     
==========================================
  Files         203      203              
  Lines       21621    21625       +4     
  Branches     2788     2789       +1     
==========================================
- Hits        17221    17219       -2     
- Misses       3625     3630       +5     
- Partials      775      776       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@arbaobao
Copy link
Contributor Author

arbaobao commented Feb 7, 2025

@eapolinario
I think we already test it in test_task_node_with_overrides, but i didn't handle pod_template in from_flyte_idl method. As a result, pod_template in obj always returns None, regardless of whether it’s None or K8sPod.

After adding pod_template into from_flyte_idl, if pod_template returns a struct rather than None, the test will fail.

Signed-off-by: Nelson Chen <[email protected]>
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 7, 2025

Code Review Agent Run #9c3fa1

Actionable Suggestions - 1
  • flytekit/models/core/workflow.py - 1
    • Consider reducing return statement duplication · Line 669-680
Review Details
  • Files reviewed - 1 · Commit Range: 21c407d..8b4b063
    • flytekit/models/core/workflow.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
Copy link
Contributor

flyte-bot commented Feb 11, 2025

Code Review Agent Run #9b999a

Actionable Suggestions - 0
Additional Suggestions - 9
  • flytekit/image_spec/image_spec.py - 2
    • Consider moving parameters list to constant · Line 158-162
    • Consider extracting pip_secret_mounts validation logic · Line 134-141
  • flytekit/image_spec/default_builder.py - 1
    • Consider extracting secret mount string construction · Line 224-229
  • tests/flytekit/unit/models/core/test_security.py - 1
    • Consider adding valid env var tests · Line 57-61
  • tests/flytekit/unit/models/core/test_workflow.py - 1
    • Consider meaningful value instead of empty string · Line 348-348
  • flytekit/clients/auth_helper.py - 1
    • Consider caching authenticator instance creation · Line 126-127
  • flytekit/core/promise.py - 1
  • tests/flytekit/integration/remote/test_remote.py - 1
  • flytekit/clients/grpc_utils/auth_interceptor.py - 1
    • Consider consistent private attribute naming · Line 74-74
Review Details
  • Files reviewed - 21 · Commit Range: 8b4b063..0fb390e
    • flytekit/clients/auth_helper.py
    • flytekit/clients/grpc_utils/auth_interceptor.py
    • flytekit/core/promise.py
    • flytekit/core/type_engine.py
    • flytekit/image_spec/default_builder.py
    • flytekit/image_spec/image_spec.py
    • flytekit/models/security.py
    • flytekit/remote/remote.py
    • pydoclint-errors-baseline.txt
    • tests/flytekit/integration/remote/test_remote.py
    • tests/flytekit/unit/clients/auth/test_keyring_store.py
    • tests/flytekit/unit/clients/test_auth_helper.py
    • tests/flytekit/unit/clients/test_friendly.py
    • tests/flytekit/unit/clients/test_raw.py
    • tests/flytekit/unit/core/image_spec/test_default_builder.py
    • tests/flytekit/unit/core/image_spec/test_image_spec.py
    • tests/flytekit/unit/core/test_annotated_bindings.py
    • tests/flytekit/unit/core/test_generice_idl_type_engine.py
    • tests/flytekit/unit/core/test_type_engine.py
    • tests/flytekit/unit/models/core/test_security.py
    • tests/flytekit/unit/models/core/test_workflow.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

@pingsutw pingsutw merged commit 13b8e08 into flyteorg:master Feb 11, 2025
109 of 111 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants