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

Refactor extract_types in Dict Transformer #3124

Merged
merged 5 commits into from
Feb 14, 2025

Conversation

Future-Outlier
Copy link
Member

@Future-Outlier Future-Outlier commented Feb 11, 2025

Tracking issue

#3123

Why are the changes needed?

  1. add more test for the above PR's is_pickle function
  2. make the logic more clear in the function extract_types

What changes were proposed in this pull request?

  1. add tests for is_pickle in the above PR.
  2. refactor function extract_types in Dict Transformer

How was this patch tested?

unit test.

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 enhances Flytekit's type system with improved DictTransformer class and dictionary handling, while also upgrading the remote execution test suite. Key changes include new cache management system, expanded remote execution capabilities, and improved error logging with conditional display logic for better debugging visibility. The implementation covers msgpack encoding, pod template handling, and comprehensive test coverage.

Unit tests added: True

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

@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 11, 2025

Code Review Agent Run #f8e289

Actionable Suggestions - 1
  • flytekit/core/type_engine.py - 1
Additional Suggestions - 1
  • tests/flytekit/unit/core/test_type_engine.py - 1
Review Details
  • Files reviewed - 2 · Commit Range: 56cfc80..56cfc80
    • flytekit/core/type_engine.py
    • tests/flytekit/unit/core/test_type_engine.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: Future-Outlier <[email protected]>
@Future-Outlier Future-Outlier enabled auto-merge (squash) February 11, 2025 03:31
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 11, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Feature Improvement - Enhanced Dictionary Type Handling

type_engine.py - Refactored extract_types method in DictTransformer for better handling of Annotated types

test_type_engine.py - Added comprehensive tests for dictionary type handling and pickle functionality

Testing - Remote Execution Test Improvements

test_remote.py - Added error logging and new test cases for dataclass workflow execution

dataclass_wf.py - Added new workflow test file for dataclass input handling

Comment on lines +2867 to +2882
"t,expected,allow_pickle",
[
(None, (None, None)),
(typing.Dict, ()),
(typing.Dict[str, str], (str, str)),
(None, (None, None), False),
(typing.Dict, (), False),
(typing.Dict[str, str], (str, str), False),
(
Annotated[typing.Dict[str, str], kwtypes(allow_pickle=True)],
(str, str),
Annotated[typing.Dict[str, str], kwtypes(allow_pickle=True)],
(str, str),
True,
),
(typing.Dict[Annotated[str, "a-tag"], int], (Annotated[str, "a-tag"], int)),
(typing.Dict[Annotated[str, "a-tag"], int], (Annotated[str, "a-tag"], int), False),
],
)
def test_dict_get(t, expected):
def test_dict_get(t, expected, allow_pickle):
assert DictTransformer.extract_types(t) == expected

assert DictTransformer.is_pickle(t) == allow_pickle
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a follow up for your PR, your PR make sense to me
#3123

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

@eapolinario
Copy link
Collaborator

Can you also add a test to cover the case described in flyteorg/flyte#6057?

# If this is something like Annotated[dict[int, str], FlyteAnnotation("abc")],
# we need to check if there's a FlyteAnnotation in the metadata.
if _origin is Annotated:
if not _args:
Copy link
Contributor

Choose a reason for hiding this comment

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

Can add a comment saying this should never happen. Python errors if you try to do Annotated[dict[str, str]] with

TypeError: Annotated[...] should be used with at least two arguments (a type and an annotation).

Copy link
Member Author

Choose a reason for hiding this comment

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

@Future-Outlier
Copy link
Member Author

@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 14, 2025

Code Review Agent Run #059fd1

Actionable Suggestions - 0
Additional Suggestions - 10
  • flytekit/remote/remote.py - 5
  • flytekit/models/execution.py - 1
    • Consider adding validation for interruptible parameter · Line 183-183
  • flytekit/core/task.py - 1
    • Consider adding Optional to cache type hint · Line 139-139
  • tests/flytekit/unit/models/core/test_workflow.py - 1
    • Consider clarifying empty string parameter usage · Line 348-348
  • tests/flytekit/integration/remote/test_remote.py - 1
  • tests/flytekit/unit/core/test_type_match_checking.py - 1
    • Missing test cases for blob dimensionality · Line 26-34
Review Details
  • Files reviewed - 45 · Commit Range: 56cfc80..faa2c6e
    • flytekit/__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/interaction/string_literals.py
    • flytekit/loggers.py
    • flytekit/models/core/workflow.py
    • flytekit/models/execution.py
    • flytekit/models/task.py
    • flytekit/remote/data.py
    • flytekit/remote/remote.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
    • 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/core/test_array_node_map_task.py
    • tests/flytekit/unit/core/test_cache.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_string_literals.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
  • 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

Signed-off-by: Future-Outlier <[email protected]>
@Future-Outlier Future-Outlier merged commit 1dadf0b into master Feb 14, 2025
108 of 110 checks passed
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 14, 2025

Code Review Agent Run #08028a

Actionable Suggestions - 1
  • tests/flytekit/integration/remote/test_remote.py - 1
    • Consider adding error check before printing · Line 919-919
Review Details
  • Files reviewed - 1 · Commit Range: faa2c6e..463e3dc
    • 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

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