https://prefect.io logo
c

chelseatroy

01/10/2022, 6:24 PM
Hiya prefect folks! I have the following composition test for a flow that totally works. This composition test literally perfectly describes the flow in question: ``````
k

Kevin Kho

01/10/2022, 6:28 PM
Hi @chelseatroy, could you move the code to the thread to clear up the main channel a bit when you get the chance? I think with is because the Flow object creates copies of the task. Let me test this a bit and get back to you
1
c

chelseatroy

01/10/2022, 6:29 PM
Copy code
from prefect.core.edge import Edge

from src.flows.prereview_engagement_feature_store_flow import *

print(flow.tasks)
assert get_last_executed_value in flow.tasks
assert update_last_executed_value in flow.tasks
assert extract_from_snowflake in flow.tasks
assert dataframe_to_feature_group in flow.tasks
assert len(flow.tasks) == 4

...
However it fails at the very first assertion. I have printed flow.tasks and I see as follows.
Copy code
{<Task: get_last_executed_value>, <Task: extract_from_snowflake>, <Task: update_last_executed_value>, <Task: dataframe_to_feature_group>}
When I print out get_last_executed_value I get:
Copy code
<Task: get_last_executed_value>
k

Kevin Kho

01/10/2022, 6:30 PM
So if you have a flow:
Copy code
from prefect import Flow, task

@task
def abc(x):
    return x+1

@task
def bcd(x):
    return x

with Flow("..") as flow:
    a = abc(1)
    b = bcd(a)
The test would be:
Copy code
from testing import *

assert a in flow
Because a copy is create with the Functional API
Thanks for moving it!
c

chelseatroy

01/10/2022, 6:34 PM
So @Kevin Kho, are you saying to ad that line, or replace some line with that line?
And where does
testing
come from? Because when I do that line it is telling me that's not a thing 😞
k

Kevin Kho

01/10/2022, 6:35 PM
Sorry,
testing.py
is the name of the file of my first file. So I am importing the Flow object and tasks from it
I am saying you need to assign your task copies to a variable, and then assert on that variable because it’s a copy
c

chelseatroy

01/10/2022, 6:36 PM
Hm. @Kevin Kho I believe that that is what I am doing here:
from src.flows.prereview_engagement_feature_store_flow import *
k

Kevin Kho

01/10/2022, 6:36 PM
The assert on my example is on
a
, the copy of the task, not
abc()
, the task definition
c

chelseatroy

01/10/2022, 6:37 PM
Ah, I see
okay, I'll try that. Thank you!
k

Kevin Kho

01/10/2022, 6:37 PM
Yep!
7 Views