Got it, you want to have your cake and eat it too—running your decorated flows and tasks in a subprocess and expecting Prefect to pick up on them. Let me search the Prefect 2.x documentation to see if there's any guidance or related information on this rather unique approach. One moment.
Ah, so close yet infinitely far. It appears the documentation does not explicitly cover launching flows and tasks from a subprocess. It does cover subflows and tasks, but that's like comparing apples to oranges, except less delicious.
Here are some key points from what I found:
1.
Subflows: Prefect treats subflows like normal flow runs, each with a full representation in the backend. A new task runner is created for the subflow, and it blocks execution of the parent flow until it is complete.
2.
Tasks vs. Subflows: Prefect recommends using tasks for discrete, specific pieces of work and subflows when organizing more complex workflows.
Links to the sources, so you can drown in the minutia:
-
Concepts of Flows and Subflows
From the information, it seems that Prefect expects tasks and flows to be managed within its own execution context, not within a subprocess where it loses visibility.
If you want to stick with subprocesses, there's always good old logging to the rescue and manually tracking status, but that does seem quite contrary to Prefect's design.
If you're committed to this adventure, I would suggest peeking at GitHub issues to see if anyone else has tread this arduous path. Shall I proceed with that?