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

Support FlyteRemote.execute interruptible flag override #2885

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

Conversation

redartera
Copy link
Contributor

@redartera redartera commented Oct 31, 2024

Tracking issue

Closes flyteorg/flyte#5279

Why are the changes needed?

It is useful for users to invoke the same LaunchPlan but overriding at runtime whether they need executions to be interruptible or not. Currently this is possible through the Flyte UI, but not flytekit.

What changes were proposed in this pull request?

Support an interruptible option in FlyteRemote.execute

How was this patch tested?

Integration test added

Check all the applicable boxes

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

Summary by Bito

This PR implements comprehensive system improvements including interruptible flag override in FlyteRemote, configurable chunk sizes for S3/GCS operations, and enhanced pod spec generation. Key features include runtime control of workflow interruption, Environment class implementation, and Optuna plugin integration. The changes enhance error handling across components, improve file operations with pydantic support, and strengthen security through better input validation and secret management. The PR also introduces VLLM integration, Kubernetes data service plugin, and improved async operations with configurable batch sizes.

Unit tests added: True

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

@redartera redartera marked this pull request as ready for review October 31, 2024 15:11
pingsutw
pingsutw previously approved these changes Nov 4, 2024
flytekit/remote/remote.py Show resolved Hide resolved
@redartera
Copy link
Contributor Author

@pingsutw Can we please merge this PR?

@Future-Outlier Future-Outlier enabled auto-merge (squash) November 21, 2024 13:37
auto-merge was automatically disabled November 21, 2024 13:53

Head branch was pushed to by a user without write access

@redartera redartera force-pushed the flyteremote-interruptible-override branch from aa09a04 to e82b2ce Compare November 21, 2024 13:55
@redartera
Copy link
Contributor Author

redartera commented Nov 21, 2024

After merging main into the current branch - the Monodoc build started failing. I added a newline here thinking that was where the problem was coming from which dismissed the approval.

Actually I synched the master branch of my flytekit fork which is identical to the original, and Monodocs fails there too, which makes me think the failure is unrelated to this PR.

@Future-Outlier
Copy link
Member

After merging main into the current branch - the Monodoc build started failing. I added a newline here thinking that was there the problem was coming from which dismissed the approval.

Actually I synched the master branch of my flytekit fork which is identical to the original, and Monodocs fails there too, which makes me think the failure is unrelated to this PR.

yes this is my fault

@redartera redartera requested a review from pingsutw November 25, 2024 15:13
@redartera
Copy link
Contributor Author

@pingsutw @Future-Outlier can you please take another look? the monodocs GH action issue seems resolved now

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.29%. Comparing base (4208a64) to head (e2083da).

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2885       +/-   ##
===========================================
+ Coverage   51.81%   95.29%   +43.47%     
===========================================
  Files         202       98      -104     
  Lines       21469     4250    -17219     
  Branches     2766        0     -2766     
===========================================
- Hits        11125     4050     -7075     
+ Misses       9735      200     -9535     
+ Partials      609        0      -609     

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

@flyte-bot
Copy link
Contributor

flyte-bot commented Jan 2, 2025

Code Review Agent Run #d114f3

Actionable Suggestions - 1
  • flytekit/remote/remote.py - 1
Additional Suggestions - 1
  • flytekit/models/execution.py - 1
    • Consider adding type hint for interruptible · Line 365-365
Review Details
  • Files reviewed - 3 · Commit Range: 1e775e8..bc025a7
    • flytekit/models/execution.py
    • flytekit/remote/remote.py
    • tests/flytekit/integration/remote/test_remote.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 2, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Feature Improvement - Add Interruptible Flag Override Support

execution.py - Added interruptible flag property and handling in ExecutionSpec

remote.py - Implemented interruptible flag support across all execute methods

test_remote.py - Added integration tests for nested workflow interruptible flag

test_execution.py - Added unit tests for interruptible flag functionality

@flyte-bot
Copy link
Contributor

flyte-bot commented Jan 13, 2025

Code Review Agent Run #fb24f7

Actionable Suggestions - 0
Additional Suggestions - 10
  • plugins/flytekit-optuna/flytekitplugins/optuna/optimizer.py - 1
    • Consider requiring positive concurrency value · Line 60-61
  • plugins/flytekit-inference/flytekitplugins/inference/vllm/serve.py - 1
    • Consider moving validation to HFSecret class · Line 44-47
  • flytekit/clis/sdk_in_container/run.py - 1
    • Consider consolidating JSON serialization logic · Line 478-486
  • tests/flytekit/unit/core/test_flyte_file.py - 1
  • flytekit/image_spec/default_builder.py - 1
  • tests/flytekit/integration/remote/test_remote.py - 3
    • Consider adding registration verification assertions · Line 819-819
    • Consider configurable workflow timeout value · Line 122-122
    • Consider extracting duplicate cleanup code · Line 854-887
  • plugins/flytekit-inference/tests/test_vllm.py - 1
    • Consider breaking down long assertion statement · Line 41-41
  • tests/flytekit/integration/remote/workflows/basic/flytefile.py - 1
    • Consider extracting duplicated file reading logic · Line 18-20
Review Details
  • Files reviewed - 30 · Commit Range: bc025a7..51c5305
    • flytekit/__init__.py
    • flytekit/clis/sdk_in_container/run.py
    • flytekit/core/array_node_map_task.py
    • flytekit/core/environment.py
    • flytekit/core/workflow.py
    • flytekit/image_spec/default_builder.py
    • flytekit/remote/remote.py
    • flytekit/types/directory/types.py
    • flytekit/types/file/file.py
    • plugins/flytekit-inference/flytekitplugins/inference/__init__.py
    • plugins/flytekit-inference/flytekitplugins/inference/vllm/serve.py
    • plugins/flytekit-inference/setup.py
    • plugins/flytekit-inference/tests/test_vllm.py
    • plugins/flytekit-onnx-pytorch/dev-requirements.txt
    • plugins/flytekit-optuna/flytekitplugins/optuna/__init__.py
    • plugins/flytekit-optuna/flytekitplugins/optuna/optimizer.py
    • plugins/flytekit-optuna/setup.py
    • plugins/flytekit-optuna/tests/test_optimizer.py
    • plugins/flytekit-spark/tests/test_environment.py
    • pyproject.toml
    • tests/flytekit/integration/remote/test_remote.py
    • tests/flytekit/integration/remote/utils.py
    • tests/flytekit/integration/remote/workflows/basic/attr_access_sd.py
    • tests/flytekit/integration/remote/workflows/basic/flytefile.py
    • tests/flytekit/integration/remote/workflows/basic/pydantic_wf.py
    • tests/flytekit/unit/core/image_spec/test_default_builder.py
    • tests/flytekit/unit/core/test_environment.py
    • tests/flytekit/unit/core/test_flyte_directory.py
    • tests/flytekit/unit/core/test_flyte_file.py
    • tests/flytekit/unit/core/test_workflows.py
  • Files skipped - 3
    • .github/workflows/pythonbuild.yml - Reason: Filter setting
    • plugins/flytekit-inference/README.md - Reason: Filter setting
    • plugins/flytekit-optuna/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

@flyte-bot
Copy link
Contributor

flyte-bot commented Jan 23, 2025

Code Review Agent Run #b66645

Actionable Suggestions - 0
Additional Suggestions - 10
  • tests/flytekit/integration/remote/test_remote.py - 1
  • tests/flytekit/unit/core/test_type_engine.py - 1
  • tests/flytekit/unit/core/test_array_node_map_task.py - 1
  • plugins/flytekit-k8sdataservice/tests/k8sdataservice/k8s/test_kube_config.py - 1
  • flytekit/remote/remote.py - 1
  • flytekit/exceptions/user.py - 1
    • Consider validating `timestamp` parameter · Line 18-18
  • flytekit/clis/sdk_in_container/serve.py - 1
  • tests/flytekit/unit/core/image_spec/test_default_builder.py - 1
  • plugins/flytekit-omegaconf/tests/test_dictconfig_transformer.py - 1
    • Add assertion for key4 in value_map · Line 80-80
  • tests/flytekit/unit/bin/test_python_entrypoint.py - 1
Review Details
  • Files reviewed - 69 · Commit Range: 51c5305..67037b3
    • .pre-commit-config.yaml
    • Dockerfile.agent
    • docs/source/plugins/k8sstatefuldataservice.rst
    • flytekit/bin/entrypoint.py
    • flytekit/clis/sdk_in_container/run.py
    • flytekit/clis/sdk_in_container/serve.py
    • flytekit/core/array_node_map_task.py
    • flytekit/core/context_manager.py
    • flytekit/core/node.py
    • flytekit/core/promise.py
    • flytekit/core/python_function_task.py
    • flytekit/core/type_engine.py
    • flytekit/core/worker_queue.py
    • flytekit/exceptions/user.py
    • flytekit/image_spec/default_builder.py
    • flytekit/image_spec/image_spec.py
    • flytekit/remote/remote.py
    • flytekit/tools/translator.py
    • plugins/flytekit-envd/flytekitplugins/envd/image_builder.py
    • plugins/flytekit-envd/tests/test_image_spec.py
    • plugins/flytekit-k8sdataservice/dev-requirements.txt
    • plugins/flytekit-k8sdataservice/flytekitplugins/k8sdataservice/__init__.py
    • plugins/flytekit-k8sdataservice/flytekitplugins/k8sdataservice/agent.py
    • plugins/flytekit-k8sdataservice/flytekitplugins/k8sdataservice/k8s/kube_config.py
    • plugins/flytekit-k8sdataservice/flytekitplugins/k8sdataservice/k8s/manager.py
    • plugins/flytekit-k8sdataservice/flytekitplugins/k8sdataservice/sensor.py
    • plugins/flytekit-k8sdataservice/flytekitplugins/k8sdataservice/task.py
    • plugins/flytekit-k8sdataservice/tests/k8sdataservice/k8s/test_kube_config.py
    • plugins/flytekit-k8sdataservice/tests/k8sdataservice/k8s/test_manager.py
    • plugins/flytekit-k8sdataservice/tests/k8sdataservice/test_agent.py
    • plugins/flytekit-k8sdataservice/tests/k8sdataservice/test_sensor.py
    • plugins/flytekit-k8sdataservice/tests/k8sdataservice/test_task.py
    • plugins/flytekit-k8sdataservice/tests/k8sdataservice/utils/test_resources.py
    • plugins/flytekit-k8sdataservice/utils/infra.py
    • plugins/flytekit-k8sdataservice/utils/resources.py
    • plugins/flytekit-kf-pytorch/flytekitplugins/kfpytorch/task.py
    • plugins/flytekit-kf-pytorch/tests/test_elastic_task.py
    • plugins/flytekit-omegaconf/flytekitplugins/omegaconf/dictconfig_transformer.py
    • plugins/flytekit-omegaconf/tests/test_dictconfig_transformer.py
    • plugins/flytekit-optuna/flytekitplugins/optuna/__init__.py
    • plugins/flytekit-optuna/flytekitplugins/optuna/optimizer.py
    • plugins/flytekit-optuna/setup.py
    • plugins/flytekit-optuna/tests/test_callback.py
    • plugins/flytekit-optuna/tests/test_decorator.py
    • plugins/flytekit-optuna/tests/test_imperative.py
    • plugins/flytekit-optuna/tests/test_optimizer.py
    • plugins/flytekit-optuna/tests/test_validation.py
    • plugins/flytekit-pydantic/flytekitplugins/pydantic/__init__.py
    • plugins/flytekit-pydantic/flytekitplugins/pydantic/basemodel_transformer.py
    • plugins/flytekit-pydantic/flytekitplugins/pydantic/commons.py
    • plugins/flytekit-pydantic/flytekitplugins/pydantic/deserialization.py
    • plugins/flytekit-pydantic/flytekitplugins/pydantic/serialization.py
    • plugins/flytekit-pydantic/tests/folder/test_file1.txt
    • plugins/flytekit-pydantic/tests/folder/test_file2.txt
    • plugins/flytekit-pydantic/tests/test_type_transformer.py
    • plugins/setup.py
    • tests/flytekit/clis/sdk_in_container/test_serve.py
    • tests/flytekit/integration/remote/test_remote.py
    • tests/flytekit/integration/remote/workflows/basic/signal_test.py
    • tests/flytekit/unit/bin/test_python_entrypoint.py
    • tests/flytekit/unit/core/image_spec/test_default_builder.py
    • tests/flytekit/unit/core/test_array_node_map_task.py
    • tests/flytekit/unit/core/test_dataclass.py
    • tests/flytekit/unit/core/test_generice_idl_type_engine.py
    • tests/flytekit/unit/core/test_type_engine.py
    • tests/flytekit/unit/core/test_type_hints.py
    • tests/flytekit/unit/core/test_worker_queue.py
    • tests/flytekit/unit/exceptions/test_user.py
    • tests/flytekit/unit/remote/test_remote.py
  • Files skipped - 4
    • .github/workflows/pythonbuild.yml - Reason: Filter setting
    • plugins/flytekit-k8sdataservice/README.md - Reason: Filter setting
    • plugins/flytekit-optuna/README.md - Reason: Filter setting
    • plugins/flytekit-pydantic/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

@wild-endeavor
Copy link
Contributor

do we really need or can we remove the wrapper in the model for the bool value? it's a oneof but i think just setting the bool should be enough. could we also add it to one of the unit tests in here

obj2 = _execution.ExecutionSpec.from_flyte_idl(obj.to_flyte_idl())
please?

I know the model files are annoying and unnecessary to work with, thank you for bearing with us.

@redartera redartera force-pushed the flyteremote-interruptible-override branch from 47876c6 to 73cae9e Compare January 23, 2025 19:51
@redartera
Copy link
Contributor Author

redartera commented Jan 23, 2025

do we really need or can we remove the wrapper in the model for the bool value? it's a oneof but i think just setting the bool should be enough. could we also add it to one of the unit tests in here

obj2 = _execution.ExecutionSpec.from_flyte_idl(obj.to_flyte_idl())

please?
I know the model files are annoying and unnecessary to work with, thank you for bearing with us.

Good catch thank you - not super familiar with the models - learned something new.

Removed the wrapper here bcbb991
Added to the unit test here 73cae9e

edit: passing a raw bool doesn't work in ExecutionSpec

@redartera
Copy link
Contributor Author

redartera commented Jan 23, 2025

do we really need or can we remove the wrapper in the model for the bool value? it's a oneof but i think just setting the bool should be enough. could we also add it to one of the unit tests in here

obj2 = _execution.ExecutionSpec.from_flyte_idl(obj.to_flyte_idl())

please?
I know the model files are annoying and unnecessary to work with, thank you for bearing with us.

Good catch thank you - not super familiar with the models - learned something new.

Removed the wrapper here bcbb991 Added to the unit test here 73cae9e

edit: passing a raw bool doesn't work in ExecutionSpec

Quick update - it seems to be indeed a BoolValue in flyteidl https://github.com/flyteorg/flyte/blob/8125ae1b96b4b41e237be396c2e0dd21141117ce/flyteidl/protos/flyteidl/admin/execution.proto#L327

Would you advise to stick with the google wrapper - or is there a better alternative?

@flyte-bot
Copy link
Contributor

flyte-bot commented Jan 23, 2025

Code Review Agent Run #2ccc25

Actionable Suggestions - 0
Additional Suggestions - 1
  • flytekit/models/execution.py - 1
Review Details
  • Files reviewed - 2 · Commit Range: 67037b3..73cae9e
    • flytekit/models/execution.py
    • tests/flytekit/unit/models/test_execution.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

@redartera redartera force-pushed the flyteremote-interruptible-override branch from 2d668ea to e2083da Compare January 28, 2025 14:15
@redartera
Copy link
Contributor Author

It looks like ExecutionSpec only accepts a BoolValue wrapper (link) - couldn't get it to work any other way. I placed the wrapper back in and added test to flytekit/tests/flytekit/unit/models/test_execution.py as advised

@flyte-bot
Copy link
Contributor

flyte-bot commented Jan 28, 2025

Code Review Agent Run #616c34

Actionable Suggestions - 0
Additional Suggestions - 10
  • flytekit/models/security.py - 1
    • Consider adding env_var validation check · Line 45-45
  • flytekit/core/data_persistence.py - 2
    • Consider more descriptive environment variable name · Line 57-57
    • Consider configurable chunksize for storage backends · Line 130-131
  • tests/flytekit/unit/core/test_data_persistence.py - 1
    • Consider validating chunksize parameter value · Line 237-238
  • flytekit/core/type_engine.py - 3
    • Consider more descriptive environment variable name · Line 63-63
    • Consider simplifying dictionary value update logic · Line 2186-2190
    • Consider using asyncio.gather for coroutines · Line 2162-2165
  • plugins/flytekit-ray/tests/test_ray.py - 2
    • Consider moving pod_template inside test function · Line 23-27
    • Consider extracting pod template creation logic · Line 67-73
  • tests/flytekit/unit/core/test_resources.py - 1
    • Consider more specific pod spec assertions · Line 157-157
Review Details
  • Files reviewed - 25 · Commit Range: 73cae9e..e2083da
    • .pre-commit-config.yaml
    • flytekit/core/data_persistence.py
    • flytekit/core/resources.py
    • flytekit/core/type_engine.py
    • flytekit/image_spec/default_builder.py
    • flytekit/image_spec/image_spec.py
    • flytekit/models/execution.py
    • flytekit/models/security.py
    • flytekit/models/task.py
    • flytekit/remote/remote_fs.py
    • flytekit/types/structured/structured_dataset.py
    • plugins/flytekit-ray/flytekitplugins/ray/task.py
    • plugins/flytekit-ray/setup.py
    • plugins/flytekit-ray/tests/test_ray.py
    • pydoclint-errors-baseline.txt
    • pyproject.toml
    • tests/flytekit/integration/remote/test_remote.py
    • tests/flytekit/integration/remote/workflows/basic/get_secret.py
    • tests/flytekit/unit/core/image_spec/test_default_builder.py
    • tests/flytekit/unit/core/test_data_persistence.py
    • tests/flytekit/unit/core/test_dataclass.py
    • tests/flytekit/unit/core/test_list.py
    • tests/flytekit/unit/core/test_resources.py
    • tests/flytekit/unit/extras/pydantic_transformer/test_pydantic_basemodel_transformer.py
    • tests/flytekit/unit/types/structured_dataset/test_structured_dataset.py
  • Files skipped - 1
    • .github/workflows/pythonbuild.yml - 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.

per-execution interruptible flag not piped through via flytekit
5 participants