Hi everyone. What is the recommended way to "forwa...
# ask-community
p
Hi everyone. What is the recommended way to "forward" the parent flow's labels (at run time) to a child flow?
k
Hey @Pedro Machado, use the new
create_flow_run
task and it accepts labels.
p
Hi Kevin. How can I access the labels of the parent flow to pass to the child at run time? If we use labels for separating environments, the parent flow needs to know what labels to pass to the child. I don't believe I can use
flow.labels
in my parent flow. Thanks
k
I took a look and it’s not in the context so you need to retrieve it by using the graphQL API and then using it like this:
Copy code
def get_flow_run(flow_run_id: str) -> PrefectFlowRun:
    client = Client()
    response = client.graphql(
        f"""
        query {{ 
          flow_run_by_pk ( id: "{flow_run_id}" ),
        {{ 
            id, 
            labels
          }}
        }}"""
    )
    return
Pull the labels out of here and then pass it on.
p
Thanks, I will try this.