question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running dependent flows with parameters

See original GitHub issue

Hi! I dont see in doc, how i can add parameters in b_flow from a_flow and dir parameter. I think for this i can use local context in b_flow from a_flow. May be add upstream_tasks with parameters?

Flow A:

@task
def any_work(a: str) -> str:
    return f'/tmp/{a}'

with Flow('a_flow') as flow:
    name = Parameter('name', default='all')
    result = any_work(name)

Flow B:

@task
def any_work(a: str, b: str) -> str:
    return f'{a}/{b}'

with Flow('b_flow') as flow:
    home = Parameter('home', required=True)
    dir = Parameter('dir', default='any')

    result = any_work(home, dir)

Flow C:

a_flow = FlowRunTask(flow_name='a_flow', wait=True)
b_flow = FlowRunTask(flow_name='b_flow', wait=True)

with Flow('c_flow') as flow:
    name = Parameter('name', default='all')
    dir = Parameter('dir', default='any')

    a_flow_state = a_flow(parameters={'name': name})

    # this error code, but how i can add parameters in `b_flow` from `a_flow` and dir parameter?
    result = b_flow(
        upstream_tasks=[a_flow_state],
        parameters={
            'home': a_flow_state.result,
            'dir': dir,
        },
    )

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:4
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
madkinszcommented, Jun 8, 2021

Thanks for sharing your task @peterroelants – this should be resolved by #4563

1reaction
dmvieiracommented, Dec 23, 2020

I did this workaround to retrieve results:

import time
from prefect.tasks.prefect import StartFlowRun
from prefect import Flow, task, Client

task1= StartFlowRun(
      flow_name="test_flow",
      project_name="test_project",
      wait=False
)

with Flow("Call Flow") as flow:
    end_flow = task1()

state = flow.run()
flow_id = state.result[end_flow].result
client = Client()

while not client.get_flow_run_info(flow_id).state.is_finished():
    time.sleep(5)
info = client.get_flow_run_info(flow_id)
last_task = info.task_runs.pop()
res = last_task.state.load_result(last_task.state._result).result

print(res)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Running dependent flows - Prefect Docs
Running dependent flows ... Running a parametrized flow. Let's say that you want to always run a flow with parameters that are generated...
Read more >
How to Make Your Data Pipelines More Dynamic Using ...
5. Start a parametrized remote flow run from the UI ... The easiest and most accessible way of triggering a parametrized flow run...
Read more >
Create and Use Parameters in Flows - Tableau Help
Instead of building and maintaining multiple flows, you can now build one flow and use parameters to run the flow with your different...
Read more >
Solved: Trigger a flow from within another flow
Run a child flow action is only available from solution. You can run a manually trigger flow as run a child flow. Create...
Read more >
Flow Pattern Parameters - Oracle Help Center
Flow parameters are a subset of task action parameters. They supply the information required to successfully complete the tasks in the flow pattern....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found