Gary Liao
09/25/2019, 1:47 AMJeremiah
09/25/2019, 1:48 AMhello()
, Prefect isn’t running the function and doesn’t know that it’s going to return two items. Therefore, you can’t use Python unpacking assignment to unpack a and b inplace.hello_result = hello(1)
a = hello_result[0]
b = hello_result[1]
...
Gary Liao
09/25/2019, 1:52 AMemre
09/25/2019, 7:21 AMGetItem
task:
class MyGetItem(Task):
def __init__(self, key, *args, **kwargs):
self.key = key
super().__init__(*args, **kwargs)
def run(self, task_result):
return task_result[self.key]
then call as such:
hello_result = hello(1)
a = MyGetItem(0)(hello_result)
b = MyGetItem(1)(hello_result)
MyGetItem(a)
, where a
is an upstream task result.Jeremiah
09/25/2019, 3:55 PMTask() + Task()
it’ll generate an Add()
task for you, or if you pass [Task(), Task()]
as the input to another task, it’ll automatically generate a List()
task. I’m not sure we’ve really publicized thatBrett Naul
09/25/2019, 8:04 PM__iter__
for tasks? the GetItem behavior is great but the *
syntax is just so much prettier 🙂Jeremiah
09/25/2019, 8:05 PMemre
09/25/2019, 9:51 PMthat's actually what Prefect is doing behind the scenes
Oh I know, went a little source code mining for this myself 😅 Anyways, all aboard the unpacking hype train 🚂Jeremiah
09/25/2019, 9:51 PM