Thread
#prefect-community
    Bruno Murino

    Bruno Murino

    5 months ago
    Hi everyone — I’m trying to use the Prefect API to “clone” a flow and give it a different name, does anyone know if that’s possible at all ?
    My thinking is to try and get the existing flow “build json” using the API, modify it with the new flow name and then running “prefect register” off that json
    Kevin Kho

    Kevin Kho

    5 months ago
    I think editing the JSON is pretty ugly but I think it can be done. If you already have the flow definition in Python you might be able to do something like.
    with Flow(..) as flow:
        ....
    
    flow2 = copy.deepcopy(flow)
    flow2.name = ...
    If you are you the JSON, have you run into a specific thing? I think it should work. Just query for the
    serialized_flow
    specifically in the GraphQL API
    Bruno Murino

    Bruno Murino

    5 months ago
    I won’t have access to the python definition, but I had a look at the serialized_flow and is indeed an ugly solution to modify that — I’ll think of something else, thanks!