John Jacoby
01/06/2022, 8:48 PMwith Flow(constants['name'], result=result) as flow:
Kevin Kho
Kevin Kho
nout
.Kevin Kho
John Jacoby
01/06/2022, 10:24 PMJohn Jacoby
01/12/2022, 8:41 PMJohn Jacoby
01/12/2022, 8:44 PMKevin Kho
@task
def taskA(x):
return [x, x+1, x+2]
so if you map, you get a List[List]
with Flow(...) as flow:
taskA.map(1,2,3) # [[1,2,3],[2,3,4],[3,4,5]]
what needs to happen is a reshape to multiple lists to chain the mapping.
@task(nout=2)
def reshape(list_x):
x1 = [x[0] for x in list_x]
x2 = [x[1] for x in list_x]
return x1, x2
and then you can do:
with Flow(...) as flow:
a = taskA.map(1,2,3) # [[1,2,3],[2,3,4],[3,4,5]]
x1, x2 = reshape(a) # x1 = [1,2,3]; x2 = [2,3,4]
and then you can map:
@task
def taskB(x1, x2):
return x2 - x1
with Flow(...) as flow:
a = taskA.map(1,2,3) # [[1,2,3],[2,3,4],[3,4,5]]
x1, x2 = reshape(a) # x1 = [1,2,3]; x2 = [2,3,4]
taskB.map(x1, x2) # [1, 1, 1]
John Jacoby
01/12/2022, 9:00 PM