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

BUG: Case task runs without end_times do not terminate properly in the flow run timeline #626

Closed
2 of 5 tasks
znicholasbrown opened this issue Feb 22, 2021 · 3 comments · Fixed by #650
Closed
2 of 5 tasks
Assignees
Labels
bug Something isn't working

Comments

@znicholasbrown
Copy link
Contributor

Bug Description

When a case task runs, it doesn't have and end_time populated in the database. In this case, the flow run timeline shows an indefinite task run duration and a skewed timeline:
image

Steps To Reproduce

  1. Create a flow with a case statement

Browsers Tested:

  • Chrome
  • Firefox
  • Safari
  • Edge
  • IE

Notes

@znicholasbrown znicholasbrown added the bug Something isn't working label Feb 22, 2021
@gryBox
Copy link

gryBox commented Feb 22, 2021

@znicholasbrown I think the bug occurs only with mapped cases.

This flow works:

from random import random

from prefect import task, Flow, case
from prefect.tasks.control_flow import merge

@task
def check_condition():
    return random() < .5

@task
def action_if_true():
    return "I am true!"

@task
def action_if_false():
    return "I am false!"

@task
def another_action(val):
    print(val)


with Flow("conditional-branches") as flow:
    cond = check_condition()

    with case(cond, True):
        val1 = action_if_true()

    with case(cond, False):
        val2 = action_if_false()

    val = merge(val1, val2)

    another_action(val)


# Register 
flow.register(
    project_name="lmap", labels=["make-lmap"],
    build=True   
)

@gryBox
Copy link

gryBox commented Feb 22, 2021

@znicholasbrown Here is a reproducible example with ifelse

from prefect import task, Flow, case, Parameter
from prefect.tasks.control_flow import merge, ifelse

@task
def check_condition(my_num):
    return my_num < .5

@task
def action_if_true():
    return "I am true!"

@task
def action_if_false():
    return "I am false!"

@task
def another_action(val):
    print(val)


with Flow("conditional-branches") as flow:
    num_lst = Parameter("num_lst", default=[1, 2])
    
    cond = check_condition.map(num_lst)

    val1 = action_if_true()
    val2 = action_if_false()

    ifelse(
        cond,
        val1,
        val2,
        mapped=True
    )

    val = merge(val1, val2)

    another_action(val)


# Register 
flow.register(
    project_name="lmap", labels=["make-lmap"],
    build=True   
)

image

@znicholasbrown
Copy link
Contributor Author

Thank you @gryBox!

@ThatGalNatalie ThatGalNatalie self-assigned this Mar 4, 2021
@ThatGalNatalie ThatGalNatalie linked a pull request Mar 9, 2021 that will close this issue
2 tasks
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

Successfully merging a pull request may close this issue.

3 participants