acoustic-carpenter-78188
03/04/2023, 12:53 AMimport time
from flytekit import Resources, dynamic, task, workflow
from typing import Dict
@task(requests=Resources(cpu="500m", mem="400Mi"), limits=Resources(cpu="1", mem="600Mi"))
def echo(a: int) -> int:
time.sleep(10)
return a
@task(requests=Resources(cpu="500m", mem="400Mi"), limits=Resources(cpu="1", mem="600Mi"))
def sleep(a: int, b: Dict[str, int]) -> Dict[str, int]:
time.sleep(a)
return b
@dynamic(cache=True, cache_version="1.0", requests=Resources(cpu="500m", mem="400Mi"), limits=Resources(cpu="1", mem="600Mi"))
def dynamic_dict(a: Dict[str, int]) -> Dict[str, int]:
b = {}
for x, y in a.items():
b[x] = echo(a=y)
return b
@workflow
def dynamic_dict_wf(a: Dict[str, int]) -> Dict[str, int]:
b = dynamic_dict(a=a)
c = sleep(a=10, b=b)
return c
Then manually fail of the of the dynamic subnodes by repeatedly deleting the pod in k8s before it completes until Flyte exhausts the number of completions. Then use the 'Recover' button in the UI to start a workflow recovery. Analyze output values of the dynamic task to see incorrect data.
Screenshots
An example of the reproduce context. Launched the aforementioned workflow with inputs:
{
"foo": 1,
"bar": 2,
"baz": 4,
}
Manually failed the n0-0-dn1 node to fail the workflow, the result is below:
failed▾
n0-0-dn0 and n0-0-dn2 correspond to the input values 4 and 2.
failed-n0▾
failed-n2▾
n0-0-dn1 should be responsible for 1 because the python iteration over this Dict was orderd 4,1,2.
Then we recover the workflow and allow it to succeed and see that the output values are:
{
"bar": 2,
"baz": 2,
"foo": 4,
}
recovered▾
Dict iteration. The results from n0-0-dn0 and n0-0-dn2 were reused - albeit applied to different keys (ie. bar & foo rather than baz and bar) and n0-0-dn1 was executed.
recovered-n1▾
acoustic-carpenter-78188
03/04/2023, 12:53 AMacoustic-carpenter-78188
03/10/2023, 8:54 AMacoustic-carpenter-78188
03/10/2023, 8:07 PM