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

Rename container_image to image for improved UX #3094

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

Conversation

JiangJiaWei1103
Copy link
Contributor

@JiangJiaWei1103 JiangJiaWei1103 commented Jan 25, 2025

Tracking issue

Closes flyteorg/flyte#6140.

Why are the changes needed?

To enhance the user experience, the concept of container should be abstracted from flytekit users.

What changes were proposed in this pull request?

We propose renaming container_image to image for both the @task decorator and the with_overrides method. To ensure backward compatibility, we will support both parameters with the following behavior:

  1. Both image and container_image are specified: Raise an error
  2. container_image is used: Warn users about the future deprecation
  3. image is used: Use image directly

In the future, we can revisit whether modifying the developer-facing code is beneficial when it becomes more relevant.

How was this patch tested?

This patch has been tested using enhanced and newly added unit tests.

Setup process

git clone https://github.com/flyteorg/flytekit.git
gh pr checkout 3094
make setup && pip install -e .

Run all unit tests using the following command:

make unit_test

Check all the applicable boxes

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

Related PRs

NA

Docs link

Please refer to flyteorg/flyte#6211

Summary by Bito

This PR implements comprehensive improvements including: 1) renaming 'container_image' parameter to 'image' across Flytekit while maintaining backward compatibility and adding deprecation warnings, 2) enhanced error handling in signal handlers, msgpack processing, and authentication flows, 3) improved type validation for shared memory resources and cache policy handling, and 4) implementation of secure pip argument handling and Kubernetes resource validation.

Unit tests added: True

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

1. Support both `image` and `container_image` for backward compatibility
2. Modify the core decorator used for any task type
    * We focus on the user-facing inteface

Signed-off-by: JiangJiaWei1103 <[email protected]>
@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 29, 2025

Codecov Report

Attention: Patch coverage is 86.66667% with 4 lines in your changes missing coverage. Please review.

Project coverage is 76.22%. Comparing base (66d4aed) to head (fdf243d).

Files with missing lines Patch % Lines
flytekit/core/node.py 84.61% 1 Missing and 1 partial ⚠️
flytekit/core/python_auto_container.py 88.23% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3094      +/-   ##
==========================================
- Coverage   76.85%   76.22%   -0.63%     
==========================================
  Files         206      206              
  Lines       21851    21875      +24     
  Branches     2837     2840       +3     
==========================================
- Hits        16794    16675     -119     
- Misses       4269     4363      +94     
- Partials      788      837      +49     

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

@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].

@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].

@JiangJiaWei1103 JiangJiaWei1103 changed the title [WIP] Rename container_image to image for improved UX Rename container_image to image for improved UX Feb 2, 2025
@JiangJiaWei1103 JiangJiaWei1103 marked this pull request as ready for review February 2, 2025 16:22
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 2, 2025

Code Review Agent Run #e396c5

Actionable Suggestions - 3
  • flytekit/core/type_engine.py - 1
    • Consider maintaining parameter name consistency · Line 383-383
  • flytekit/core/task.py - 2
    • Consider consolidating duplicate image parameters · Line 108-108
    • Consider consolidating duplicate image parameters · Line 148-148
Review Details
  • Files reviewed - 9 · Commit Range: ff7b2c5..f2ddb80
    • flytekit/core/task.py
    • flytekit/core/type_engine.py
    • tests/flytekit/integration/jupyter/test_notebook_run.py
    • tests/flytekit/unit/cli/pyflyte/image_spec_wf.py
    • tests/flytekit/unit/core/test_array_node_map_task.py
    • tests/flytekit/unit/core/test_python_function_task.py
    • tests/flytekit/unit/core/test_serialization.py
    • tests/flytekit/unit/core/test_task.py
    • tests/flytekit/unit/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 Feb 2, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Feature Improvement - Rename container_image to image for better UX

node.py - Renamed container_image to image with deprecation warning

promise.py - Updated parameter name from container_image to image

python_auto_container.py - Added deprecation handling for container_image parameter

task.py - Updated task decorator to use image instead of container_image

type_engine.py - Updated image parameter in type engine

Testing - Add comprehensive tests for image parameter changes

test_task.py - Added tests for image parameter usage and deprecation warnings

test_node_creation.py - Added tests for image override behavior

test_map_task.py - Updated map task tests for new image parameter

test_serialization.py - Updated serialization tests with new image parameter

test_remote.py - Updated remote tests to use new image parameter

test_notebook_run.py - Updated notebook tests with new image parameter

1. Validate `image` and `container_image` in `PythonAutoContainerTask`'s
    initializer
2. Maintain backward compatibility within `PythonAutoContainerTask`

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

flyte-bot commented Feb 3, 2025

Code Review Agent Run #5e8094

Actionable Suggestions - 2
  • flytekit/core/task.py - 1
  • flytekit/core/python_auto_container.py - 1
    • Consider consolidating duplicate image properties · Line 161-171
Review Details
  • Files reviewed - 2 · Commit Range: f2ddb80..bb6e187
    • flytekit/core/python_auto_container.py
    • flytekit/core/task.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

thomasjpfan
thomasjpfan previously approved these changes Feb 4, 2025
Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Minor nit on adding a comment

@JiangJiaWei1103 JiangJiaWei1103 dismissed stale reviews from thomasjpfan and pingsutw via e66743f February 4, 2025 15:31
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 4, 2025

Code Review Agent Run #acb303

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: bb6e187..e66743f
    • flytekit/core/python_auto_container.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 6, 2025

Code Review Agent Run #74c115

Actionable Suggestions - 0
Additional Suggestions - 10
  • flytekit/models/security.py - 2
    • Consider adding env_var validation check · Line 45-45
    • Consider validating env_var for empty string · Line 73-73
  • tests/flytekit/integration/remote/workflows/basic/get_secret.py - 1
    • Consider explicit error for missing env var · Line 19-20
  • flytekit/deck/deck.py - 1
    • Add error handling for deck publishing · Line 96-96
  • plugins/flytekit-k8sdataservice/tests/k8sdataservice/test_sensor.py - 1
    • Add context manager for async task · Line 25-29
  • plugins/flytekit-k8sdataservice/setup.py - 1
    • Consider more specific kubernetes version range · Line 7-7
  • flytekit/image_spec/image_spec.py - 1
    • Consider adding pip args validation · Line 86-86
  • tests/flytekit/unit/core/test_data_persistence.py - 1
    • Consider strengthening test assertion specificity · Line 237-238
  • tests/flytekit/unit/types/structured_dataset/test_structured_dataset.py - 1
  • plugins/flytekit-k8sdataservice/flytekitplugins/k8sdataservice/k8s/manager.py - 1
    • Consider breaking down container creation method · Line 66-82
Review Details
  • Files reviewed - 74 · Commit Range: e66743f..896553e
    • .pre-commit-config.yaml
    • Dockerfile.agent
    • docs/source/plugins/k8sstatefuldataservice.rst
    • flytekit/bin/entrypoint.py
    • flytekit/clients/friendly.py
    • flytekit/clients/raw.py
    • flytekit/clis/sdk_in_container/serve.py
    • flytekit/core/base_task.py
    • flytekit/core/context_manager.py
    • flytekit/core/data_persistence.py
    • flytekit/core/node.py
    • flytekit/core/python_function_task.py
    • flytekit/core/resources.py
    • flytekit/core/type_engine.py
    • flytekit/deck/deck.py
    • flytekit/image_spec/default_builder.py
    • flytekit/image_spec/image_spec.py
    • flytekit/interaction/parse_stdin.py
    • flytekit/loggers.py
    • flytekit/models/core/workflow.py
    • flytekit/models/domain.py
    • flytekit/models/security.py
    • flytekit/models/task.py
    • flytekit/remote/remote.py
    • flytekit/remote/remote_fs.py
    • flytekit/tools/fast_registration.py
    • flytekit/tools/translator.py
    • flytekit/types/directory/types.py
    • flytekit/types/structured/structured_dataset.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/setup.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-omegaconf/flytekitplugins/omegaconf/dictconfig_transformer.py
    • plugins/flytekit-omegaconf/tests/test_dictconfig_transformer.py
    • plugins/flytekit-ray/flytekitplugins/ray/task.py
    • plugins/flytekit-ray/setup.py
    • plugins/flytekit-ray/tests/test_ray.py
    • plugins/setup.py
    • pydoclint-errors-baseline.txt
    • pyproject.toml
    • tests/flytekit/clis/sdk_in_container/test_serve.py
    • tests/flytekit/integration/remote/test_remote.py
    • tests/flytekit/integration/remote/workflows/basic/get_secret.py
    • tests/flytekit/integration/remote/workflows/basic/sd_attr.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_data_persistence.py
    • tests/flytekit/unit/core/test_dataclass.py
    • tests/flytekit/unit/core/test_generice_idl_type_engine.py
    • tests/flytekit/unit/core/test_list.py
    • tests/flytekit/unit/core/test_map_task.py
    • tests/flytekit/unit/core/test_node_creation.py
    • tests/flytekit/unit/core/test_resources.py
    • tests/flytekit/unit/core/test_type_engine.py
    • tests/flytekit/unit/core/test_unions.py
    • tests/flytekit/unit/deck/test_deck.py
    • tests/flytekit/unit/extras/pydantic_transformer/test_pydantic_basemodel_transformer.py
    • tests/flytekit/unit/test_translator.py
    • tests/flytekit/unit/types/structured_dataset/test_structured_dataset.py
  • Files skipped - 2
    • .github/workflows/pythonbuild.yml - Reason: Filter setting
    • plugins/flytekit-k8sdataservice/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

thomasjpfan
thomasjpfan previously approved these changes Feb 6, 2025
@eapolinario
Copy link
Collaborator

shoulnd't we also support image in with_overrides too?

@JiangJiaWei1103
Copy link
Contributor Author

Hi @eapolinario,

Thanks for the suggestion! We focus on @task, @dynamic, and @eager in this PR, as approved by @thomasjpfan.

Supporting image in with_overrides is also a great enhancement. Would you prefer modifying it in this PR, or should we explore it in a follow-up PR? Thanks!

@@ -42,6 +43,7 @@ def __init__(
name: str,
task_config: T,
task_type="python-task",
image: Optional[Union[str, ImageSpec]] = None,
container_image: Optional[Union[str, ImageSpec]] = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

@eapolinario and I were talking about this and we were thinking we might want to put this behind kwargs instead. Could we try that please?

Like delete this line... but leave it in the docs below, maybe move it to the bottom of the params, and check for it explicitly in the code to see if it's set (like kwargs["container_image"]). This way we can hide it from the user, they don't see it in the IDE etc.

cc @thomasjpfan

Copy link
Member

@pingsutw pingsutw Feb 12, 2025

Choose a reason for hiding this comment

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

put this behind kwargs instead

+1

Copy link
Member

Choose a reason for hiding this comment

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

It's a bit non-standard, but I am okay with hiding it in kwargs, but keeping it in the docs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've hidden container_image behind kwargs and kept it at the bottom of docstring. Thanks a lot!

"Please use image because container_image is deprecated and will be removed in the future."
)
elif container_image is not None:
warnings.warn(
Copy link
Contributor

Choose a reason for hiding this comment

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

should we just make this info? warning is a little too annoying I think.

Copy link
Member

Choose a reason for hiding this comment

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

I feel like this is not annoying enough. DeprecationWarning does not really show up with default filter warnings. (FutureWarning would be more annoying)

If we really want users to change their code, then I think warnings should be a bit annoying. Because when we remove this feature, breaking code will be even more annoying.

Add `ImageSpec` to the docstring of the `image` parameter for better clarity.

Co-authored-by: Yee Hing Tong <[email protected]>
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 13, 2025

Code Review Agent Run #3a28a5

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 896553e..98547e5
    • flytekit/core/python_auto_container.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

1. Put deprecated `container_image` param behind `kwargs`
2. Keep `container_image` at the bottom of docstring

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

flyte-bot commented Feb 13, 2025

Code Review Agent Run #44e3d6

Actionable Suggestions - 1
  • flytekit/core/python_auto_container.py - 1
    • Consider extracting image param handling logic · Line 98-108
Review Details
  • Files reviewed - 1 · Commit Range: 98547e5..c2383ee
    • flytekit/core/python_auto_container.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

@wild-endeavor
Copy link
Contributor

@JiangJiaWei1103 could you change with_overrides as well in this pr please?

Also, could you remove container_task from the @task decorator (and the @overloads also) please? If you merge in master, you'll see that @eapolinario has added **kwargs to the decorator already.

Thank you! Let's merge after this last change

@JiangJiaWei1103
Copy link
Contributor Author

Hi Yee,

I’ll get it done this weekend. Thanks for the suggestion!

Signed-off-by: JiangJiaWei1103 <[email protected]>
1. Remove `container_image` from `@task` and `@overload` to hide it
    behind `kwargs`
2. Let `image` take precedence for version hash generation

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

flyte-bot commented Feb 16, 2025

Code Review Agent Run #914520

Actionable Suggestions - 0
Additional Suggestions - 10
  • tests/flytekit/unit/core/test_cache.py - 1
    • Consider parameterizing deprecated cache tests · Line 72-103
  • pyproject.toml - 1
    • Consider adding version upper bound · Line 23-23
  • tests/flytekit/unit/clients/auth/test_keyring_store.py - 1
    • Consider parameterizing similar test functions · Line 44-72
  • tests/flytekit/unit/core/test_type_match_checking.py - 1
    • Consider testing nested collection types · Line 15-16
  • flytekit/core/type_engine.py - 2
  • tests/flytekit/unit/cli/pyflyte/test_run.py - 1
    • Consider using pathlib for file operations · Line 324-332
  • tests/flytekit/unit/interaction/test_string_literals.py - 1
    • Consider adding error handling test case · Line 89-90
  • flytekit/remote/remote.py - 2
Review Details
  • Files reviewed - 66 · Commit Range: c2383ee..0ca8c17
    • dev-requirements.txt
    • flytekit/__init__.py
    • flytekit/clients/auth_helper.py
    • flytekit/clients/grpc_utils/auth_interceptor.py
    • flytekit/clis/sdk_in_container/init.py
    • flytekit/clis/sdk_in_container/run.py
    • flytekit/configuration/plugin.py
    • flytekit/core/cache.py
    • flytekit/core/constants.py
    • flytekit/core/node.py
    • flytekit/core/promise.py
    • flytekit/core/python_auto_container.py
    • flytekit/core/python_function_task.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/image_spec/default_builder.py
    • flytekit/image_spec/image_spec.py
    • flytekit/interaction/click_types.py
    • flytekit/interaction/string_literals.py
    • flytekit/loggers.py
    • flytekit/models/core/workflow.py
    • flytekit/models/execution.py
    • flytekit/models/security.py
    • flytekit/models/task.py
    • flytekit/remote/data.py
    • flytekit/remote/remote.py
    • flytekit/utils/rate_limiter.py
    • plugins/flytekit-aws-sagemaker/tests/test_boto3_agent.py
    • plugins/flytekit-onnx-pytorch/dev-requirements.txt
    • plugins/flytekit-openai/tests/openai_batch/test_agent.py
    • plugins/flytekit-pandera/flytekitplugins/pandera/pandas_transformer.py
    • plugins/flytekit-pandera/setup.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/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_node_creation.py
    • tests/flytekit/unit/core/test_resources.py
    • tests/flytekit/unit/core/test_type_engine.py
    • tests/flytekit/unit/core/test_type_match_checking.py
    • tests/flytekit/unit/core/test_worker_queue.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/types/structured_dataset/test_structured_dataset.py
    • tests/flytekit/unit/utils/test_rate_limiter.py
  • Files skipped - 1
    • .gitignore - 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

1. Hide `container_image` of `Node`'s `with_override` behind `kwargs`
2. Add validation in `Node`'s `with_override` to enforce `image` over
    deprecated `container_image`
3. Hide `container_image` of `Promise`'s `with_override` behind `kwargs`

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

flyte-bot commented Feb 16, 2025

Code Review Agent Run #4f136e

Actionable Suggestions - 1
  • flytekit/core/node.py - 1
    • Consider adding deprecation warning for _container_image · Line 275-278
Review Details
  • Files reviewed - 5 · Commit Range: 0ca8c17..d678e10
    • flytekit/core/node.py
    • flytekit/core/promise.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

Comment on lines +275 to +278
@property
def _container_image(self) -> typing.Optional[str]:
"""Deprecated, please use `_image` instead."""
return self._image
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider adding deprecation warning for _container_image

Consider enhancing the deprecation notice for _container_image by adding a warning using the warnings module. This would help users transition to using _image instead.

Code suggestion
Check the AI-generated fix before applying
Suggested change
@property
def _container_image(self) -> typing.Optional[str]:
"""Deprecated, please use `_image` instead."""
return self._image
def _container_image(self) -> typing.Optional[str]:
"""Deprecated, please use `_image` instead."""
warnings.warn("_container_image is deprecated, use _image instead", DeprecationWarning, stacklevel=2)
return self._image

Code Review Run #4f136e


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

  • it was incorrectly flagged

@JiangJiaWei1103
Copy link
Contributor Author

JiangJiaWei1103 commented Feb 16, 2025

The container_image parameter is now encapsulated within kwargs for the with_overrides method of both Node and Promise. All changes have been validated through enhanced and newly added tests.

Follow-ups

I’m curious to know if it’s also necessary to modify TaskNodeOverrides interface as shown below:

class TaskNodeOverrides(_common.FlyteIdlEntity):
def __init__(
self,
resources: typing.Optional[Resources],
extended_resources: typing.Optional[tasks_pb2.ExtendedResources],
container_image: typing.Optional[str] = None,
pod_template: typing.Optional[PodTemplate] = None,
):
self._resources = resources
self._extended_resources = extended_resources
self._container_image = container_image
self._pod_template = pod_template

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

[flytekit] Polish - Container ux
6 participants