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

Flytekit: Rename map_task to map, replace min_successes and min_success_ratio with tolerance, rename max_parallelism to concurrency #3107

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

Conversation

ChihTsungLu
Copy link

@ChihTsungLu ChihTsungLu commented Feb 4, 2025

Tracking issue

Related to flyteorg/flyte#6139

Why are the changes needed?

The current Flytekit has several areas that could be improved for a better developer experience:

  1. The map_task name is unnecessarily verbose when imported via the recommended import flytekit as fl
  2. The failure tolerance parameters (min_successes and min_success_ratio) are powerful but overly verbose
  3. The max_parallelism parameter naming in workflow and LaunchPlan needs to be aligned with map_task's concurrency parameter

What changes were proposed in this pull request?

  1. Rename map_task to map

    • While this conflicts with Python's built-in map, it's acceptable since we recommend using import flytekit as fl
    • All changes will maintain backwards compatibility
  2. Simplify failure tolerance parameters

    • Deprecate min_successes and min_success_ratio
    • Introduce new tolerance parameter that accepts both float and int types
    • Maintain backwards compatibility with existing parameters
  3. Standardize parallelism parameter

    • Deprecate max_parallelism argument in workflow and LaunchPlan
    • Introduce new concurrency parameter to match map_task's parameter
    • Maintain backwards compatibility with existing parameter

Known issue

The changes introduce the concurrency field in Flytekit, which is not currently defined in flyteidl's LaunchPlanSpec

<img width="1561" alt="valueError" src="https://github.com/user-attachments/assets/e794e7d0-6393-4009-a320-988fdd1769cb" />

Code to Address the Issue:
The following code handles the transition between the concurrency and max_parallelism fields:

    @classmethod
    def from_flyte_idl(cls, pb2):
        """
        :param flyteidl.admin.launch_plan_pb2.LaunchPlanSpec pb2:
        :rtype: LaunchPlanSpec
        """

        auth_role = None
        # First check the newer field, auth_role.
        if pb2.auth_role is not None and (pb2.auth_role.assumable_iam_role or pb2.auth_role.kubernetes_service_account):
            auth_role = _common.AuthRole.from_flyte_idl(pb2.auth_role)
        # Fallback to the deprecated field.
        elif pb2.auth is not None:
            if pb2.auth.assumable_iam_role:
                auth_role = _common.AuthRole(assumable_iam_role=pb2.auth.assumable_iam_role)
            else:
                auth_role = _common.AuthRole(assumable_iam_role=pb2.auth.kubernetes_service_account)

        # Handle concurrency/max_parallelism transition
        concurrency = None
        max_parallelism = None

        if hasattr(pb2, "concurrency"):
            try:
                if pb2.HasField("concurrency"):
                    concurrency = pb2.concurrency
            except ValueError:
                pass  # Field doesn't exist in protobuf yet

        # Fallback to max_parallelism (deprecated field)
        if hasattr(pb2, "max_parallelism"):
            max_parallelism = pb2.max_parallelism

        # Use concurrency if available, otherwise use max_parallelism
        final_concurrency = concurrency if concurrency is not None else max_parallelism

        return cls(
            workflow_id=_identifier.Identifier.from_flyte_idl(pb2.workflow_id),
            entity_metadata=LaunchPlanMetadata.from_flyte_idl(pb2.entity_metadata),
            default_inputs=_interface.ParameterMap.from_flyte_idl(pb2.default_inputs),
            fixed_inputs=_literals.LiteralMap.from_flyte_idl(pb2.fixed_inputs),
            labels=_common.Labels.from_flyte_idl(pb2.labels),
            annotations=_common.Annotations.from_flyte_idl(pb2.annotations),
            auth_role=auth_role,
            raw_output_data_config=_common.RawOutputDataConfig.from_flyte_idl(pb2.raw_output_data_config),
            concurrency=final_concurrency,
            max_parallelism=pb2.max_parallelism,
            security_context=security.SecurityContext.from_flyte_idl(pb2.security_context)
            if pb2.security_context
            else None,
            overwrite_cache=pb2.overwrite_cache if pb2.overwrite_cache else None,
        )

How was this patch tested?

Ran tests with the command: make 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 implements API improvements in Flytekit by renaming map_task to map, introducing a tolerance parameter to replace min_successes/min_success_ratio, and standardizing parallelism control by replacing max_parallelism with concurrency. The changes include comprehensive deprecation warnings and backward compatibility handling.

Unit tests added: True

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

- Rename map_task to map for simpler API
- Replace min_successes/min_success_ratio with tolerance parameter
- Rename max_parallelism to concurrency for consistency
@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 4, 2025

Code Review Agent Run #d47fe6

Actionable Suggestions - 13
  • tests/flytekit/unit/types/directory/test_listdir.py - 2
    • Consider implications of map vs map_task · Line 4-4
    • Consider using map_task for workflow operations · Line 29-29
  • plugins/flytekit-papermill/tests/test_task.py - 1
    • Consider using map_task for notebook tasks · Line 417-417
  • flytekit/__init__.py - 1
    • Consider maintaining backward compatibility for imports · Line 222-222
  • flytekit/core/array_node_map_task.py - 1
    • Consider keeping descriptive function name · Line 373-373
  • tests/flytekit/unit/core/test_array_node_map_task.py - 8
Additional Suggestions - 10
  • flytekit/core/options.py - 3
    • Consider adding concurrency parameter validation · Line 26-27
    • Consider adding validation for concurrency parameter · Line 38-38
    • Consider using @deprecated decorator instead · Line 43-66
  • tests/flytekit/unit/core/test_array_node_map_task.py - 2
  • tests/flytekit/integration/remote/workflows/basic/array_map.py - 1
    • Consider potential naming confusion with map · Line 4-4
  • tests/flytekit/unit/core/test_array_node.py - 1
  • flytekit/models/launch_plan.py - 2
    • Consider validating concurrency value before use · Line 277-277
    • Consider simplifying concurrency handling logic · Line 301-318
  • flytekit/tools/translator.py - 1
    • Consider consolidating duplicate warning logic · Line 355-382
Review Details
  • Files reviewed - 24 · Commit Range: 87dfe2f..d8e5d4b
    • flytekit/__init__.py
    • flytekit/clis/sdk_in_container/run.py
    • flytekit/core/array_node_map_task.py
    • flytekit/core/launch_plan.py
    • flytekit/core/options.py
    • flytekit/models/execution.py
    • flytekit/models/launch_plan.py
    • flytekit/remote/entities.py
    • flytekit/remote/remote.py
    • flytekit/tools/translator.py
    • plugins/flytekit-k8s-pod/tests/test_pod.py
    • plugins/flytekit-papermill/tests/test_task.py
    • tests/flytekit/integration/remote/workflows/basic/array_map.py
    • tests/flytekit/integration/remote/workflows/basic/pydantic_wf.py
    • tests/flytekit/unit/core/test_array_node.py
    • tests/flytekit/unit/core/test_array_node_map_task.py
    • tests/flytekit/unit/core/test_artifacts.py
    • tests/flytekit/unit/core/test_interface.py
    • tests/flytekit/unit/core/test_launch_plan.py
    • tests/flytekit/unit/core/test_node_creation.py
    • tests/flytekit/unit/core/test_partials.py
    • tests/flytekit/unit/core/test_type_hints.py
    • tests/flytekit/unit/remote/test_remote.py
    • tests/flytekit/unit/types/directory/test_listdir.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 4, 2025

Changelist by Bito

This pull request implements the following key changes.

Key Change Files Impacted
Feature Improvement - API Standardization and Simplification

__init__.py - Renamed map_task to map and added deprecation warning

array_node_map_task.py - Replaced min_successes/min_success_ratio with new tolerance parameter

launch_plan.py - Standardized parallelism control by replacing max_parallelism with concurrency

options.py - Updated options to use concurrency instead of max_parallelism

execution.py - Added concurrency field and deprecation warnings for max_parallelism

launch_plan.py - Added concurrency support and backwards compatibility handling

entities.py - Updated remote entities to use concurrency parameter

translator.py - Added concurrency parameter handling in translator

Testing - Test Updates for API Changes

test_array_node_map_task.py - Updated tests to use map instead of map_task

test_array_node.py - Updated array node tests for new map function

test_artifacts.py - Updated artifact tests for map function

test_pod.py - Updated pod tests to use map

test_task.py - Updated papermill tests to use map

array_map.py - Updated workflow tests for map function

pydantic_wf.py - Updated pydantic workflow tests for map

Feature Improvement - API Standardization and Simplification

__init__.py - Renamed map_task to map and added deprecation warning

array_node_map_task.py - Replaced min_successes/min_success_ratio with new tolerance parameter

launch_plan.py - Standardized parallelism control by replacing max_parallelism with concurrency

options.py - Updated options to use concurrency instead of max_parallelism

execution.py - Added concurrency field and deprecation warnings for max_parallelism

launch_plan.py - Added concurrency support and backwards compatibility handling

entities.py - Updated remote entities to use concurrency parameter

translator.py - Added concurrency parameter handling in translator

Testing - Test Updates for API Changes

test_interface.py - Updated import and usage of map instead of map_task

test_launch_plan.py - Updated tests to use concurrency instead of max_parallelism

test_node_creation.py - Updated map_task imports and usage to map

test_partials.py - Updated array node map task imports

test_type_hints.py - Updated imports and usage to use map

test_remote.py - Updated imports and map_task usage

test_listdir.py - Updated imports and map_task usage

test_array_node_map_task.py - Updated tests to use map instead of map_task

test_array_node.py - Updated array node tests for new map function

test_artifacts.py - Updated artifact tests for map function

@@ -1,7 +1,7 @@
import tempfile
from pathlib import Path

from flytekit import FlyteDirectory, FlyteFile, map_task, task, workflow
from flytekit import FlyteDirectory, FlyteFile, map, task, workflow
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider implications of map vs map_task

Consider if replacing map_task with map is intentional as they might have different functionality in the Flyte framework. map_task is typically used for task parallelization while map might have different semantics.

Code suggestion
Check the AI-generated fix before applying
Suggested change
from flytekit import FlyteDirectory, FlyteFile, map, task, workflow
from flytekit import FlyteDirectory, FlyteFile, map_task, task, workflow

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@@ -26,6 +26,6 @@ def list_dir(dir: FlyteDirectory) -> list[FlyteFile]:
def wf() -> list[str]:
tmpdir = setup()
files = list_dir(dir=tmpdir)
return map_task(read_file)(file=files)
return map(read_file)(file=files)
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 map_task for workflow operations

Consider using map_task instead of map for task mapping operations in Flytekit workflows. The map function may not provide the same task-level parallelization and execution guarantees as map_task.

Code suggestion
Check the AI-generated fix before applying
Suggested change
return map(read_file)(file=files)
return map_task(read_file)(file=files)

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@@ -414,7 +414,7 @@ def create_sd() -> StructuredDataset:
def test_map_over_notebook_task():
@workflow
def wf(a: float) -> typing.List[float]:
return map_task(nb_sub_task)(a=[a, a])
return map(nb_sub_task)(a=[a, a])
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 map_task for notebook tasks

Consider using map_task instead of map for mapping over notebook tasks. The map function may not handle notebook task specific requirements correctly.

Code suggestion
Check the AI-generated fix before applying
Suggested change
return map(nb_sub_task)(a=[a, a])
return map_task(nb_sub_task)(a=[a, a])

Code Review Run #d47fe6


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

  • it was incorrectly flagged

from flytekit._version import __version__
from flytekit.configuration import Config
from flytekit.core.array_node_map_task import map_task
from flytekit.core.array_node_map_task import map
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider maintaining backward compatibility for imports

Consider keeping both map_task and map imports to maintain backward compatibility. The alias is defined later but importing directly as map may break existing code that uses map_task.

Code suggestion
Check the AI-generated fix before applying
Suggested change
from flytekit.core.array_node_map_task import map
from flytekit.core.array_node_map_task import map_task

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@@ -369,11 +370,12 @@ def _raw_execute(self, **kwargs) -> Any:
return outputs


def map_task(
def map(
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider keeping descriptive function name

Consider keeping the original function name map_task instead of renaming to map as it could conflict with Python's built-in map function and cause confusion. The original name was more descriptive of the function's purpose.

Code suggestion
Check the AI-generated fix before applying
Suggested change
def map(
def map_task(

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@@ -63,7 +63,7 @@ def say_hello(name: str) -> str:

@workflow
def wf() -> List[str]:
return map_task(say_hello)(name=["abc", "def"])
return map(say_hello)(name=["abc", "def"])
Copy link
Contributor

Choose a reason for hiding this comment

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

Map task function call change

Consider if using map() instead of map_task() is intentional as it changes the behavior from using Flyte's map task functionality to Python's built-in map().

Code suggestion
Check the AI-generated fix before applying
Suggested change
return map(say_hello)(name=["abc", "def"])
return map_task(say_hello)(name=["abc", "def"])

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@@ -575,7 +575,7 @@ def say_hello(name: str) -> str:
for index, map_input_str in enumerate(list_strs):
monkeypatch.setenv("BATCH_JOB_ARRAY_INDEX_VAR_NAME", "name")
monkeypatch.setenv("name", str(index))
t = map_task(say_hello)
t = map(say_hello)
Copy link
Contributor

Choose a reason for hiding this comment

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

Potential task mapping behavior change

Consider if using map() instead of map_task() is intentional as this could change the behavior of task mapping functionality.

Code suggestion
Check the AI-generated fix before applying
Suggested change
t = map(say_hello)
t = map_task(say_hello)

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@@ -410,7 +410,7 @@ def test_serialization_metadata(serialization_settings):
def t1(a: int) -> int:
return a + 1

arraynode_maptask = map_task(t1, metadata=TaskMetadata(retries=2))
arraynode_maptask = map(t1, metadata=TaskMetadata(retries=2))
Copy link
Contributor

Choose a reason for hiding this comment

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

Function rename may affect compatibility

Consider if changing from map_task to map could impact backward compatibility. The function name change from map_task to map may affect existing code that imports and uses the original function name.

Code suggestion
Check the AI-generated fix before applying
Suggested change
arraynode_maptask = map(t1, metadata=TaskMetadata(retries=2))
# Maintain both for backward compatibility
arraynode_maptask = map_task(t1, metadata=TaskMetadata(retries=2))

Code Review Run #d47fe6


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

  • it was incorrectly flagged

Comment on lines +229 to +230
t1 = map(say_hello, **kwargs1)
t2 = map(say_hello, **kwargs2)
Copy link
Contributor

Choose a reason for hiding this comment

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

Verify intended function call change

Consider if replacing map_task with map is intentional as this changes the function being called which could affect functionality. The map_task decorator appears to be imported but not used after this change.

Code suggestion
Check the AI-generated fix before applying
Suggested change
t1 = map(say_hello, **kwargs1)
t2 = map(say_hello, **kwargs2)
t1 = map_task(say_hello, **kwargs1)
t2 = map_task(say_hello, **kwargs2)

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@@ -316,7 +316,7 @@ def test_bounded_inputs_vars_order(serialization_settings):
def task1(a: int, b: float, c: str) -> str:
return f"{a} - {b} - {c}"

mt = map_task(functools.partial(task1, c=1.0, b="hello", a=1))
mt = map(functools.partial(task1, c=1.0, b="hello", a=1))
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 map_task instead of map

Consider using map_task() instead of map() as it appears to be the intended function based on the test context and imports. Using map() could lead to unexpected behavior since it's a built-in Python function.

Code suggestion
Check the AI-generated fix before applying
Suggested change
mt = map(functools.partial(task1, c=1.0, b="hello", a=1))
mt = map_task(functools.partial(task1, c=1.0, b="hello", a=1))

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@@ -492,7 +492,7 @@ def test_supported_node_type():
def test_task():
...

map_task(test_task)
map(test_task)
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 map_task instead of map

The function call has been changed from map_task(test_task) to map(test_task). This could potentially cause confusion with Python's built-in map() function. Consider using the imported map_task decorator/function to maintain clarity and avoid potential naming conflicts.

Code suggestion
Check the AI-generated fix before applying
Suggested change
map(test_task)
map_task(test_task)

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@@ -533,7 +533,7 @@ def consume_directories(dirs: List[FlyteDirectory]):
for path_info, other_info in d.crawl():
print(path_info)

mt = map_task(generate_directory, min_success_ratio=0.1)
mt = map(generate_directory, min_success_ratio=0.1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Verify map function usage intention

Consider if using map() instead of map_task() is intentional as it may change the expected behavior. The map_task() function is typically used for array node map tasks in Flytekit.

Code suggestion
Check the AI-generated fix before applying
Suggested change
mt = map(generate_directory, min_success_ratio=0.1)
mt = map_task(generate_directory, min_success_ratio=0.1)

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@@ -575,7 +575,7 @@ def say_hello(name: str) -> str:
for index, map_input_str in enumerate(list_strs):
monkeypatch.setenv("BATCH_JOB_ARRAY_INDEX_VAR_NAME", "name")
monkeypatch.setenv("name", str(index))
t = map_task(say_hello)
t = map(say_hello)
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 map_task instead of map

Consider using map_task instead of map as it appears to be the intended decorator based on the imports and test context. The map function could be confused with Python's built-in map function.

Code suggestion
Check the AI-generated fix before applying
Suggested change
t = map(say_hello)
t = map_task(say_hello)

Code Review Run #d47fe6


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

  • it was incorrectly flagged

@flyte-bot
Copy link
Contributor

flyte-bot commented Feb 5, 2025

Code Review Agent Run #99b31d

Actionable Suggestions - 8
  • tests/flytekit/unit/core/test_array_node_map_task.py - 4
  • flytekit/remote/remote.py - 1
  • tests/flytekit/unit/core/test_node_creation.py - 1
    • Consider using map_task for workflow testing · Line 276-276
  • tests/flytekit/unit/remote/test_remote.py - 1
  • flytekit/core/launch_plan.py - 1
Additional Suggestions - 10
  • flytekit/core/options.py - 4
    • Consider adding concurrency parameter validation · Line 26-27
    • Consider adding validation for concurrency parameter · Line 38-38
    • Consider using standard deprecation decorator pattern · Line 43-66
    • Consider consolidating duplicate warning message · Line 48-64
  • flytekit/models/execution.py - 1
    • Consider adding property setter for deprecation · Line 290-302
  • flytekit/clis/sdk_in_container/run.py - 1
    • Consider updating deprecated parameter name · Line 529-529
  • tests/flytekit/unit/core/test_node_creation.py - 1
  • tests/flytekit/unit/core/test_array_node_map_task.py - 3
Review Details
  • Files reviewed - 24 · Commit Range: 87dfe2f..09755a2
    • flytekit/__init__.py
    • flytekit/clis/sdk_in_container/run.py
    • flytekit/core/array_node_map_task.py
    • flytekit/core/launch_plan.py
    • flytekit/core/options.py
    • flytekit/models/execution.py
    • flytekit/models/launch_plan.py
    • flytekit/remote/entities.py
    • flytekit/remote/remote.py
    • flytekit/tools/translator.py
    • plugins/flytekit-k8s-pod/tests/test_pod.py
    • plugins/flytekit-papermill/tests/test_task.py
    • tests/flytekit/integration/remote/workflows/basic/array_map.py
    • tests/flytekit/integration/remote/workflows/basic/pydantic_wf.py
    • tests/flytekit/unit/core/test_array_node.py
    • tests/flytekit/unit/core/test_array_node_map_task.py
    • tests/flytekit/unit/core/test_artifacts.py
    • tests/flytekit/unit/core/test_interface.py
    • tests/flytekit/unit/core/test_launch_plan.py
    • tests/flytekit/unit/core/test_node_creation.py
    • tests/flytekit/unit/core/test_partials.py
    • tests/flytekit/unit/core/test_type_hints.py
    • tests/flytekit/unit/remote/test_remote.py
    • tests/flytekit/unit/types/directory/test_listdir.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

@@ -315,7 +316,7 @@ def test_bounded_inputs_vars_order(serialization_settings):
def task1(a: int, b: float, c: str) -> str:
return f"{a} - {b} - {c}"

mt = map_task(functools.partial(task1, c=1.0, b="hello", a=1))
mt = map(functools.partial(task1, c=1.0, b="hello", a=1))
Copy link
Contributor

Choose a reason for hiding this comment

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

Parameter type mismatch in task call

The function call parameters c=1.0, b="hello", a=1 appear to have mismatched types with the task definition. The task expects a: int, b: float, c: str but receives c as float, b as string, and a as int. Consider adjusting the parameter types to match the task signature.

Code suggestion
Check the AI-generated fix before applying
Suggested change
mt = map(functools.partial(task1, c=1.0, b="hello", a=1))
mt = map(functools.partial(task1, c="1.0", b=1.0, a=1))

Code Review Run #99b31d


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

  • it was incorrectly flagged

@@ -1551,7 +1551,7 @@ def _execute(
annotations=options.annotations,
raw_output_data_config=options.raw_output_data_config,
auth_role=None,
max_parallelism=options.max_parallelism,
concurrency=options.concurrency,
Copy link
Contributor

Choose a reason for hiding this comment

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

Parameter rename may break compatibility

Consider verifying if renaming max_parallelism to concurrency maintains backward compatibility. This change could potentially break existing code that relies on the max_parallelism parameter.

Code suggestion
Check the AI-generated fix before applying
Suggested change
concurrency=options.concurrency,
concurrency=options.max_parallelism if hasattr(options, 'max_parallelism')
else options.concurrency,
# TODO: Remove max_parallelism support in next major version
# Deprecated in favor of concurrency parameter

Code Review Run #99b31d


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

  • it was incorrectly flagged

@@ -273,7 +273,7 @@ def t1(a: str) -> str:

@workflow
def my_wf(a: typing.List[str]) -> typing.List[str]:
mappy = map_task(t1)
mappy = map(t1)
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 map_task for workflow testing

Consider using map_task instead of map as it appears to be the intended function based on the test context. The map function may not provide the same task mapping functionality needed for workflow testing.

Code suggestion
Check the AI-generated fix before applying
Suggested change
mappy = map(t1)
mappy = map_task(t1)

Code Review Run #99b31d


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

  • it was incorrectly flagged

@@ -726,7 +726,7 @@ def t1(x: int, y: int) -> int:

@workflow
def w() -> int:
return map_task(partial(t1, y=2))(x=[1, 2, 3])
return map(partial(t1, y=2))(x=[1, 2, 3])
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 map_task for consistency

Consider using map_task instead of map as it appears to be testing map task functionality based on the test name and context.

Code suggestion
Check the AI-generated fix before applying
Suggested change
return map(partial(t1, y=2))(x=[1, 2, 3])
return map_task(partial(t1, y=2))(x=[1, 2, 3])

Code Review Run #99b31d


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

  • it was incorrectly flagged

Comment on lines +307 to +309
m1 = map(functools.partial(task1, c=param_c))(a=param_a, b=param_b)
m2 = map(functools.partial(task2, c=param_c))(a=param_a, b=param_b)
m3 = map(functools.partial(task3, c=param_c))(a=param_a, b=param_b)
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 map_task for array testing

Consider using map_task instead of map for consistency with the test name and module being tested (test_array_node_map_task.py). The test appears to be validating array node map task functionality.

Code suggestion
Check the AI-generated fix before applying
Suggested change
m1 = map(functools.partial(task1, c=param_c))(a=param_a, b=param_b)
m2 = map(functools.partial(task2, c=param_c))(a=param_a, b=param_b)
m3 = map(functools.partial(task3, c=param_c))(a=param_a, b=param_b)
m1 = map_task(functools.partial(task1, c=param_c))(a=param_a, b=param_b)
m2 = map_task(functools.partial(task2, c=param_c))(a=param_a, b=param_b)
m3 = map_task(functools.partial(task3, c=param_c))(a=param_a, b=param_b)

Code Review Run #99b31d


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

  • it was incorrectly flagged

Comment on lines +461 to +475
map(test_dynamic)

@eager
def test_eager():
...

with pytest.raises(ValueError):
map_task(test_eager)
map(test_eager)

@workflow
def test_wf():
...

with pytest.raises(ValueError):
map_task(test_wf)
map(test_wf)
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 more specific function name

Consider using map_task() instead of map() to avoid confusion with Python's built-in map() function. The change from map_task() to map() could lead to confusion.

Code suggestion
Check the AI-generated fix before applying
 -        map(test_dynamic)
 +        map_task(test_dynamic)
 @@ -468,1 +468,1 @@
 -        map(test_eager)
 +        map_task(test_eager)
 @@ -475,1 +475,1 @@
 -        map(test_wf)
 +        map_task(test_wf)

Code Review Run #99b31d


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

  • it was incorrectly flagged

@@ -326,7 +336,8 @@ def get_or_create(
labels,
annotations,
raw_output_data_config,
max_parallelism,
concurrency=concurrency,
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactor init method signature

The 'init' method has too many parameters (14 > 5) and is missing docstring and return type annotation.

Code suggestion
Check the AI-generated fix before applying
 -    def __init__(
 -        self,
 -        name: str,
 -        workflow: _annotated_workflow.WorkflowBase,
 -        parameters: _interface_models.ParameterMap,
 -        fixed_inputs: _literal_models.LiteralMap,
 -        schedule: Optional[_schedule_model.Schedule] = None,
 -        notifications: Optional[List[_common_models.Notification]] = None,
 -        labels: Optional[_common_models.Labels] = None,
 -        annotations: Optional[_common_models.Annotations] = None,
 -        raw_output_data_config: Optional[_common_models.RawOutputDataConfig] = None,
 -        max_parallelism: Optional[int] = None,
 -        security_context: Optional[security.SecurityContext] = None,
 -        trigger: Optional[LaunchPlanTriggerBase] = None,
 -        overwrite_cache: Optional[bool] = None,
 -        auto_activate: bool = False,
 -    ):
 +    @dataclass
 +    class Config:
 +        """Configuration for LaunchPlan initialization."""
 +        name: str
 +        workflow: _annotated_workflow.WorkflowBase
 +        parameters: _interface_models.ParameterMap
 +        fixed_inputs: _literal_models.LiteralMap
 +        schedule: _schedule_model.Schedule | None = None
 +        notifications: list[_common_models.Notification] | None = None
 +        labels: _common_models.Labels | None = None
 +        annotations: _common_models.Annotations | None = None
 +        raw_output_data_config: _common_models.RawOutputDataConfig | None = None
 +        max_parallelism: int | None = None
 +        security_context: security.SecurityContext | None = None
 +        trigger: LaunchPlanTriggerBase | None = None
 +        overwrite_cache: bool | None = None
 +        auto_activate: bool = False
 +
 +    def __init__(self, config: Config) -> None:

Code Review Run #99b31d


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

  • it was incorrectly flagged

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.

2 participants