Hey guys, what is the best way to copy a flow? Jus...
# prefect-community
f
Hey guys, what is the best way to copy a flow? Just use .copy() or deepcopy?
k
From experience I think copy works already. But I think I don’t have a better answer for now than “try copy and if it doesn’t work, deepcopy” lol.
f
I asking because i have 2 flows and in one of them i'm just replacing the name
but now i start getting odd behaviour
ex
if one flow run first the name stick in the next call to
extract_flow_from_file
i get the same object if i extract the flow that i change the name
k
Ah then I guess use deepcopy yep
Copy code
from prefect import Flow, task
from copy import copy

@task
def abc():
    return 1

with Flow("test") as flow:
    abc()

flow2 = copy(flow)
flow2.name = "test2"
print(flow.name)
f
great! thanks.