Eddie

    Eddie

    11 months ago
    I am having trouble locally testing the parent-child flow mentioned in the "Sub-flow result passing" section of this page. I tried to run it with
    prefect run -m flows.dev.parent_child -n parent
    and got the following exception:
    └── 14:10:26 | ERROR   | Task 'create_flow_run': Exception encountered during task execution!
    Traceback (most recent call last):
      File "/Users/epantridge/Library/Caches/pypoetry/virtualenvs/flows-Lt6Mru_j-py3.9/lib/python3.9/site-packages/prefect/engine/task_runner.py", line 859, in get_task_run_state
        value = prefect.utilities.executors.run_task_with_timeout(
      File "/Users/epantridge/Library/Caches/pypoetry/virtualenvs/flows-Lt6Mru_j-py3.9/lib/python3.9/site-packages/prefect/utilities/executors.py", line 454, in run_task_with_timeout
        return task.run(*args, **kwargs)  # type: ignore
      File "/Users/epantridge/Library/Caches/pypoetry/virtualenvs/flows-Lt6Mru_j-py3.9/lib/python3.9/site-packages/prefect/tasks/prefect/flow_run.py", line 118, in create_flow_run
        flow = FlowView.from_flow_name(flow_name, project_name=project_name)
      File "/Users/epantridge/Library/Caches/pypoetry/virtualenvs/flows-Lt6Mru_j-py3.9/lib/python3.9/site-packages/prefect/backend/flow.py", line 192, in from_flow_name
        flows = cls._query_for_flows(
      File "/Users/epantridge/Library/Caches/pypoetry/virtualenvs/flows-Lt6Mru_j-py3.9/lib/python3.9/site-packages/prefect/backend/flow.py", line 287, in _query_for_flows
        raise ValueError(
    ValueError: No results found while querying for flows where {'name': {'_eq': 'child'}, 'archived': {'_eq': False}}
    Does this imply that the child flow has to be registered before the parent flow can be run? If so, is there a way to register a flow in-process when testing locally?
    Kevin Kho

    Kevin Kho

    11 months ago
    Hey @Eddie, yes child flows have to be registered because they can be called with
    StartFlowRun
    or
    create_flow_run
    . They are first class flows as well and actually create a flow run in the database. Not quite a way to test because these are API calls to the database so they do need to be registered. I believe someone in the community channel monkeypatched those Tasks for local testing to find the flow and call
    flow.run()
    but I don’t have details on that other than they said it worked
    Eddie

    Eddie

    11 months ago
    Thanks @Kevin Kho. I'll see if I can dig up the monkeypatching solution, but I suspect that I am far too unfamiliar with the internals of Prefect to successfully pull something like that off.
    Kevin Kho

    Kevin Kho

    11 months ago
    It is here . Maybe you can ask him?
    Oh he didn’t even monkeypatch. He just straight up made a new task
    Eddie

    Eddie

    11 months ago
    Thanks! A custom task seems more approachable.