https://prefect.io logo
v

Vincent Chéry

01/25/2022, 11:07 AM
Hi all 👋 I'm a little confused regarding using regular functions (not tasks) in flows and cannot find information about this in the docs. Maybe I did not look in the write place ? For instance, in
Copy code
with Flow("my-flow") as f:
    a = make_a()
    b = make_b()
    c  = a + b
• Do
make_a
and
make_b
need to be tasks or can they be regular functions ? • In particular, when using builtin functions (for instance,
datetime.utcnow()
), can we use it directly or must we wrap it in a task ? • Is
c = a + b
allowed ? Thanks a lot !
a

Anna Geller

01/25/2022, 11:11 AM
1. make_a and make_b must be tasks in the current Prefect. In Orion, you will be able to call any Python code in your flow, but this is not the case in Prefect <= 1.0 2. You should wrap it in a task 3. Yes, you can see this best when you do
flow.visualize()
- this will give you a DAG visualization
v

Vincent Chéry

01/25/2022, 12:40 PM
Thanks Anna!
4 Views