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

Merged
merged 7 commits into from
Feb 24, 2025

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 addresses multiple improvements: 1) Fixes a critical bug in with_overrides() method's timeout handling by introducing TIMEOUT_OVERRIDE_SENTINEL for better timeout case management, 2) Implements enhanced error handling and security improvements for private keys and webhooks, 3) Adds proper validation for shared memory formats and improves event loop management, 4) Includes comprehensive test coverage for all changes.

Unit tests added: True

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

@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 override behavior in Node class

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

promise.py - Updated timeout parameter type to include 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

Copy link
Member

Choose a reason for hiding this comment

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

@pvditt For typing, I think this needs to be a timedelta object.

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

@eapolinario eapolinario merged commit 55c15ea into master Feb 24, 2025
112 checks passed
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 24, 2025

Code Review Agent Run #7f6c33

Actionable Suggestions - 0
Additional Suggestions - 10
  • plugins/flytekit-slurm/flytekitplugins/slurm/function/agent.py - 1
  • flytekit/core/python_function_task.py - 1
    • Consider using context for signal handlers · Line 631-634
  • flytekit/image_spec/image_spec.py - 1
    • Consider validating pip secret mount paths · Line 89-89
  • flytekit/models/execution.py - 2
    • Consider adding validation for interruptible parameter · Line 219-219
    • Consider extracting bool value wrapping logic · Line 332-332
  • tests/flytekit/unit/core/test_resources.py - 2
  • tests/flytekit/unit/core/test_annotated_bindings.py - 1
  • tests/flytekit/unit/core/test_cache.py - 1
  • tests/flytekit/unit/core/test_type_match_checking.py - 1
    • Consider expanding collection type test coverage · Line 15-16
Review Details
  • Files reviewed - 116 · Commit Range: f43f286..37cc0c3
    • dev-requirements.in
    • dev-requirements.txt
    • flytekit/__init__.py
    • flytekit/bin/entrypoint.py
    • flytekit/clients/auth_helper.py
    • flytekit/clients/friendly.py
    • flytekit/clients/grpc_utils/auth_interceptor.py
    • flytekit/clients/raw.py
    • flytekit/clis/sdk_in_container/init.py
    • flytekit/clis/sdk_in_container/run.py
    • flytekit/clis/sdk_in_container/serve.py
    • flytekit/configuration/plugin.py
    • flytekit/core/base_task.py
    • flytekit/core/cache.py
    • flytekit/core/constants.py
    • flytekit/core/context_manager.py
    • flytekit/core/node.py
    • flytekit/core/promise.py
    • flytekit/core/python_auto_container.py
    • flytekit/core/python_function_task.py
    • flytekit/core/reference_entity.py
    • flytekit/core/resources.py
    • flytekit/core/task.py
    • flytekit/core/type_engine.py
    • flytekit/core/type_match_checking.py
    • flytekit/core/worker_queue.py
    • flytekit/core/workflow.py
    • flytekit/deck/deck.py
    • flytekit/extend/backend/base_agent.py
    • flytekit/extend/backend/utils.py
    • flytekit/extras/webhook/__init__.py
    • flytekit/extras/webhook/agent.py
    • flytekit/extras/webhook/constants.py
    • flytekit/extras/webhook/task.py
    • flytekit/image_spec/default_builder.py
    • flytekit/image_spec/image_spec.py
    • flytekit/interaction/click_types.py
    • flytekit/interaction/parse_stdin.py
    • flytekit/interaction/string_literals.py
    • flytekit/loggers.py
    • flytekit/models/core/workflow.py
    • flytekit/models/domain.py
    • flytekit/models/execution.py
    • flytekit/models/security.py
    • flytekit/models/task.py
    • flytekit/remote/data.py
    • flytekit/remote/entities.py
    • flytekit/remote/remote.py
    • flytekit/tools/fast_registration.py
    • flytekit/tools/translator.py
    • flytekit/types/directory/types.py
    • flytekit/types/structured/structured_dataset.py
    • flytekit/utils/dict_formatter.py
    • flytekit/utils/rate_limiter.py
    • plugins/flytekit-aws-sagemaker/flytekitplugins/awssagemaker_inference/boto3_agent.py
    • plugins/flytekit-aws-sagemaker/flytekitplugins/awssagemaker_inference/boto3_mixin.py
    • plugins/flytekit-aws-sagemaker/setup.py
    • plugins/flytekit-aws-sagemaker/tests/test_boto3_agent.py
    • plugins/flytekit-aws-sagemaker/tests/test_boto3_mixin.py
    • plugins/flytekit-greatexpectations/tests/test_schema.py
    • plugins/flytekit-onnx-pytorch/dev-requirements.txt
    • plugins/flytekit-openai/flytekitplugins/openai/batch/agent.py
    • plugins/flytekit-openai/tests/openai_batch/test_agent.py
    • plugins/flytekit-pandera/flytekitplugins/pandera/pandas_transformer.py
    • plugins/flytekit-pandera/setup.py
    • plugins/flytekit-ray/flytekitplugins/ray/task.py
    • plugins/flytekit-ray/setup.py
    • plugins/flytekit-ray/tests/test_ray.py
    • plugins/flytekit-slurm/flytekitplugins/slurm/__init__.py
    • plugins/flytekit-slurm/flytekitplugins/slurm/function/agent.py
    • plugins/flytekit-slurm/flytekitplugins/slurm/function/task.py
    • plugins/flytekit-slurm/flytekitplugins/slurm/ssh_utils.py
    • plugins/flytekit-slurm/setup.py
    • plugins/flytekit-slurm/tests/test_slurm_fn_task.py
    • pydoclint-errors-baseline.txt
    • pyproject.toml
    • tests/flytekit/integration/remote/test_remote.py
    • tests/flytekit/integration/remote/workflows/basic/dataclass_wf.py
    • tests/flytekit/integration/remote/workflows/basic/deep_child_workflow.py
    • tests/flytekit/integration/remote/workflows/basic/dynamic_array_map.py
    • tests/flytekit/integration/remote/workflows/basic/sd_attr.py
    • tests/flytekit/unit/bin/test_python_entrypoint.py
    • tests/flytekit/unit/cli/pyflyte/test_run.py
    • tests/flytekit/unit/cli/pyflyte/test_run_lps.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_array_node_map_task.py
    • tests/flytekit/unit/core/test_cache.py
    • tests/flytekit/unit/core/test_generice_idl_type_engine.py
    • tests/flytekit/unit/core/test_map_task.py
    • tests/flytekit/unit/core/test_node_creation.py
    • tests/flytekit/unit/core/test_references.py
    • tests/flytekit/unit/core/test_resources.py
    • tests/flytekit/unit/core/test_serialization.py
    • tests/flytekit/unit/core/test_type_engine.py
    • tests/flytekit/unit/core/test_type_match_checking.py
    • tests/flytekit/unit/core/test_unions.py
    • tests/flytekit/unit/core/test_worker_queue.py
    • tests/flytekit/unit/deck/test_deck.py
    • tests/flytekit/unit/extras/webhook/test_agent.py
    • tests/flytekit/unit/extras/webhook/test_end_to_end.py
    • tests/flytekit/unit/extras/webhook/test_task.py
    • tests/flytekit/unit/interaction/test_click_types.py
    • tests/flytekit/unit/interaction/test_string_literals.py
    • tests/flytekit/unit/models/core/test_security.py
    • tests/flytekit/unit/models/core/test_workflow.py
    • tests/flytekit/unit/models/test_execution.py
    • tests/flytekit/unit/models/test_tasks.py
    • tests/flytekit/unit/test_translator.py
    • tests/flytekit/unit/types/structured_dataset/test_structured_dataset.py
    • tests/flytekit/unit/utils/test_rate_limiter.py
  • Files skipped - 5
    • .github/workflows/build_image.yml - Reason: Filter setting
    • .github/workflows/pythonbuild.yml - Reason: Filter setting
    • .github/workflows/pythonpublish.yml - Reason: Filter setting
    • .gitignore - Reason: Filter setting
    • plugins/flytekit-slurm/README.md - Reason: Filter setting
  • 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
4 participants