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

[优化改进]:WhileLoopPipeline的 #409

Open
Jou0us opened this issue Aug 15, 2024 · 1 comment
Open

[优化改进]:WhileLoopPipeline的 #409

Jou0us opened this issue Aug 15, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@Jou0us
Copy link

Jou0us commented Aug 15, 2024

def whilelooppipeline(
loop_body_operators: Operators,
condition_func: Callable[[int, Any], bool] = lambda _, __: False,
x: Optional[dict] = None,
) -> dict:
"""Functional version of WhileLoopPipeline.

Args:
    loop_body_operators (`Operators`): Operators executed as the body of
        the loop.
    condition_func (`Callable[[int, Any], bool]`, optional): A function
        that determines whether to continue executing the loop body based
        on the current loop number and output of the loop_body_operator,
        defaults to `lambda _,__: False`
    x (`Optional[dict]`, defaults to `None`):
        The input dictionary.

Returns:
    `dict`: the output dictionary.
"""
i = 0
while condition_func(i, x):
    # loop body
    x = _operators(loop_body_operators, x)
    # check condition
    i += 1
return x  # type: ignore[return-value]

这里的i感觉没什么意义,对于外面函数的定义还有影响,不看源码的话,会导致函数的定义失败的状态 文档也没有说明

@Jou0us Jou0us added the bug Something isn't working label Aug 15, 2024
@Jou0us Jou0us changed the title [Bug]:WhileLoopPipeline的 [优化改进]:WhileLoopPipeline的 Aug 15, 2024
@DavdGao
Copy link
Collaborator

DavdGao commented Aug 21, 2024

Thanks for your attention. For whilelooppipeline, we are considering to abandon this feature for the difficulity to write a lambda function. Currently, we think directly coding a while loop is more simple and user-friendly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants