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

don't override timeout on with_overrides if not specified #3097

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

pvditt
Copy link
Contributor

@pvditt pvditt commented Jan 27, 2025

Tracking issue

fixes: flyteorg/flyte#6153

Why are the changes needed?

with_overrides set timeout to default of 0 if timeout param is not specified

What changes were proposed in this pull request?

  • differentiate between timeout not getting set vs explicitly set to None for with_overrides

How was this patch tested?

added unit tests

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

This PR fixes a critical bug in the with_overrides() method where timeouts were incorrectly defaulting to 0. The implementation introduces a sentinel object (renamed to TIMEOUT_OVERRIDE_SENTINEL for Python naming conventions) to distinguish between explicit timeout settings and unspecified cases. The changes modify the Node class timeout handling logic and improve differentiation between unset timeout and explicit None timeout cases, with comprehensive test coverage for timeout override scenarios.

Unit tests added: True

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

@flyte-bot
Copy link
Contributor

Code Review Agent Run Status

  • Limitations and other issues: ❌ Failure - The AI Code Review Agent skipped reviewing this change because it is configured to exclude certain pull requests based on the source/target branch or the pull request status. You can change the settings here, or contact the agent instance creator at [email protected].

Copy link

codecov bot commented Jan 27, 2025

Codecov Report

Attention: Patch coverage is 11.11111% with 8 lines in your changes missing coverage. Please review.

Project coverage is 46.74%. Comparing base (f0ba47f) to head (f43f286).
Report is 11 commits behind head on master.

Files with missing lines Patch % Lines
flytekit/core/node.py 11.11% 8 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (f0ba47f) and HEAD (f43f286). Click for more details.

HEAD has 8 uploads less than BASE
Flag BASE (f0ba47f) HEAD (f43f286)
9 1
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #3097       +/-   ##
===========================================
- Coverage   76.46%   46.74%   -29.73%     
===========================================
  Files         218      203       -15     
  Lines       22505    21525      -980     
  Branches     2766     2779       +13     
===========================================
- Hits        17209    10062     -7147     
- Misses       4483    10967     +6484     
+ Partials      813      496      -317     

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

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

flyte-bot commented Jan 27, 2025

Code Review Agent Run #01a35d

Actionable Suggestions - 3
  • flytekit/core/node.py - 2
    • Consider more explicit sentinel value type · Line 50-50
    • Consider using timedelta for timeout value · Line 149-149
  • tests/flytekit/unit/core/test_node_creation.py - 1
Review Details
  • Files reviewed - 3 · Commit Range: 1fae040..f205c41
    • flytekit/core/node.py
    • flytekit/core/promise.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
Copy link
Contributor

flyte-bot commented Jan 27, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Bug Fix - Fix timeout handling in Node overrides

node.py - Added sentinel object and modified timeout handling logic

promise.py - Updated timeout parameter type to support sentinel object

test_node_creation.py - Added comprehensive tests for timeout override scenarios

@@ -47,6 +47,8 @@ class Node(object):
ID, which from the registration step
"""

timeout_override_sentinel = object()
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider more explicit sentinel value type

Consider if using object() as a sentinel value is the best approach here. While it works, using a dedicated sentinel class or enum.Enum could provide better type safety and clarity of intent.

Code suggestion
Check the AI-generated fix before applying
 import datetime
 +import enum
 @@ -50,1 +50,4 @@
 -timeout_override_sentinel = object()
 +class TimeoutSentinel(enum.Enum):
 +    NO_OVERRIDE = 'no_override'
 +
 +timeout_override_sentinel = TimeoutSentinel.NO_OVERRIDE

Code Review Run #01a35d


Is this a valid issue, or was it incorrectly flagged by the Agent?

  • it was incorrectly flagged

raise ValueError("timeout should be duration represented as either a datetime.timedelta or int seconds")
if timeout is not Node.timeout_override_sentinel:
if timeout is None:
node_metadata._timeout = 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using timedelta for timeout value

Consider using datetime.timedelta() instead of 0 for timeout value to maintain consistency with the type system and other code paths.

Code suggestion
Check the AI-generated fix before applying
Suggested change
node_metadata._timeout = 0
node_metadata._timeout = datetime.timedelta()

Code Review Run #01a35d


Is this a valid issue, or was it incorrectly flagged by the Agent?

  • it was incorrectly flagged

Comment on lines +319 to +323
t1_expected_timeout_overridden,
t1_expected_timeout_unset,
t2_expected_timeout_overridden,
t2_expected_timeout_unset,
):
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider more descriptive parameter names

Consider using more descriptive parameter names. The current names t1_expected_timeout_overridden, t1_expected_timeout_unset, etc. could be renamed to better indicate their purpose, such as task1_timeout_with_override and task1_timeout_without_override.

Code suggestion
Check the AI-generated fix before applying
Suggested change
t1_expected_timeout_overridden,
t1_expected_timeout_unset,
t2_expected_timeout_overridden,
t2_expected_timeout_unset,
):
task1_timeout_with_override,
task1_timeout_without_override,
task2_timeout_with_override,
task2_timeout_without_override,
):

Code Review Run #01a35d


Is this a valid issue, or was it incorrectly flagged by the Agent?

  • it was incorrectly flagged

flytekit/core/node.py Outdated Show resolved Hide resolved
@@ -47,6 +47,8 @@ class Node(object):
ID, which from the registration step
"""

timeout_override_sentinel = object()
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I usually see python sentinels as constants, thus all capitalized:

Suggested change
timeout_override_sentinel = object()
TIMEOUT_OVERRIDE_SENTINEL = object()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sounds good - just updated

Signed-off-by: Paul Dittamo <[email protected]>
Signed-off-by: Paul Dittamo <[email protected]>
Signed-off-by: Paul Dittamo <[email protected]>
@pvditt pvditt requested a review from thomasjpfan February 6, 2025 00:49
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 6, 2025

Code Review Agent Run #7ddfdb

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: f205c41..f43f286
    • flytekit/core/node.py
    • flytekit/core/promise.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

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.

[BUG] with_overrides unsets timeout if not specified
3 participants