Gary Liao09/25/2019, 1:47 AM
Jeremiah09/25/2019, 1:48 AM
, 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 b = hello_result ...
Gary Liao09/25/2019, 1:52 AM
emre09/25/2019, 7:21 AM
then call as such:
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]
hello_result = hello(1) a = MyGetItem(0)(hello_result) b = MyGetItem(1)(hello_result)
is an upstream task result.
Jeremiah09/25/2019, 3:55 PM
it’ll generate an
Task() + Task()
task for you, or if you pass
as the input to another task, it’ll automatically generate a
task. I’m not sure we’ve really publicized that
Brett Naul09/25/2019, 8:04 PM
for tasks? the GetItem behavior is great but the
syntax is just so much prettier 🙂
Jeremiah09/25/2019, 8:05 PM
emre09/25/2019, 9:51 PM
Oh I know, went a little source code mining for this myself 😅 Anyways, all aboard the unpacking hype train 🚂
that's actually what Prefect is doing behind the scenes
Jeremiah09/25/2019, 9:51 PM