I’m a little confused with the migration from v1 to Orion.
Should we continue to use .map? Or write async tasks?
k
Khuyen Tran
08/03/2022, 7:53 PM
2.0 is Dags free so you can use it like how you would use Python.
That means that instead of:
Copy code
from prefect import Flow, task
@task
def add_ten(x):
return x + 10
with Flow('simple map') as flow:
mapped_result = add_ten.map([1, 2, 3])
You can simply write this:
Copy code
from prefect import flow, task
@task
def add_ten(x):
return x + 10
@flow
def my_flow():
result = [add_ten(num) for num in [1, 2, 3])
Khuyen Tran
08/03/2022, 7:54 PM
You can use async in 2.0
s
Stephen Herron
08/03/2022, 8:44 PM
subtle difference though in that you would now have to call sumbit() to really make those calls concurrent e.g.
result = add_ten.submit(num) for num in [1, 2, 3]
k
Khuyen Tran
08/03/2022, 9:11 PM
that is true. It is because a lot of Prefect users are not using concurrency and were confused about why the returned result is not a Python object. Since we prioritize incremental adoption, we set the default return value of a task to be a Python object
z
Zanie
08/03/2022, 9:21 PM
We’ve also got the
map
operator still, which will run your tasks concurrently. It doesn’t support DFE yet though.
Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.