<@ULVA73B9P> I'm really struggling to understand w...
# ask-marvin
a
@Marvin I'm really struggling to understand what's going on: I have a flow consisting of multiple mapped tasks, and the whole thing runs perfectly when I run the flow directly. However, when I run the same flow as a subflow (using flow.from_source), it skips most of the tasks, only executing the first and last ones in the sequence. Why would the flow behave differently depending on how it's invoked?
m
It seems like there might be some confusion about how subflows and tasks work in Prefect. In Prefect, you can call tasks or subflows to do work within your workflow, including passing results from other tasks to your subflow. However, the behavior of the flow should not change depending on how it's invoked. The
flow.from_source
method is used to retrieve a flow from remote storage and it accepts a git repository URL and an entrypoint pointing to the flow to load from the repository. If your tasks are being skipped when running as a subflow, it might be due to some other issue. It could be related to how the tasks are being mapped or the state of the tasks when the subflow is invoked. Without more specific information about your flow and tasks, it's hard to say exactly why this is happening. I would recommend checking the state of your tasks and the mapping in your subflow. If you're still having trouble, you might want to consider reaching out to the Prefect community for more specific help.
a
@Marvin I do not believe there is a misunderstanding. As I said, the flow works perfectly fine when I run it directly. The only difference between a successful run and an unsuccessful run is that the unsuccessful run was invoked using flow.from_source. It's the exact same code.
m
Based on the information from the Prefect documentation, the behavior of a flow should not change depending on whether it's invoked directly or as a subflow. The
flow.from_source
method is used to retrieve a flow from remote storage and it accepts a git repository URL and an entrypoint pointing to the flow to load from the repository. A subflow run is created when a flow function is called inside the execution of another flow. The primary flow is the "parent" flow. The flow created within the parent is the "child" flow or "subflow." Subflow runs behave like normal flow runs. There is a full representation of the flow run in the backend as if it had been called separately. If your tasks are being skipped when running as a subflow, it might be due to some other issue. It could be related to how the tasks are being mapped or the state of the tasks when the subflow is invoked. If you're still having trouble, you might want to consider reaching out to the Prefect community for more specific help.
🙅 1