-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug summary
Compete MWE reproducing the issue
import time
from pathlib import Path
from prefect import flow, task
@flow
def mainflow() -> None:
folder = Path(".") / "data"
outfiles = fetch_data(folder)
another_task(outfiles["a"])
@flow
def fetch_data(folder: Path) -> dict[str, Path]:
sql_queries = ["a", "b", "c"]
time.sleep(1)
outfiles = {x: Path(x) for x in sql_queries}
return outfiles
@task
def another_task(
input_file: Path,
) -> None:
time.sleep(1)
if __name__ == "__main__":
mainflow()

This is what you see in the console

Workaround 1: Do not use subflows
If you change the fetch_data
(subflow) in to a @task
, everything works as expected:
import time
from pathlib import Path
from prefect import flow, task
@flow
def mainflow() -> None:
folder = Path(".") / "data"
outfiles = fetch_data(folder)
another_task(outfiles["a"])
@task # This changed from @flow to @task
def fetch_data(folder: Path) -> dict[str, Path]:
sql_queries = ["a", "b", "c"]
time.sleep(1)
outfiles = {x: Path(x) for x in sql_queries}
return outfiles
@task
def another_task(
input_file: Path,
) -> None:
time.sleep(1)
if __name__ == "__main__":
mainflow()

Workaround 2
If you don't use the output from the subflow as an argument to the task, everything works as expected:
import time
from pathlib import Path
from prefect import flow, task
@flow
def mainflow() -> None:
folder = Path(".") / "data"
_ = fetch_data(folder)
another_task(folder / "input.txt") # This input changed
@flow
def fetch_data(folder: Path) -> dict[str, Path]:
sql_queries = ["a", "b", "c"]
time.sleep(1)
outfiles = {x: Path(x) for x in sql_queries}
return outfiles
@task
def another_task(
input_file: Path,
) -> None:
time.sleep(1)
if __name__ == "__main__":
mainflow()

Version info
Version: 3.4.11
API version: 0.8.4
Python version: 3.12.10
Git commit: 3c98aa7f
Built: Thu, Jul 31, 2025 08:45 PM
OS/Arch: linux/x86_64
Profile: local
Server type: server
Pydantic version: 2.11.7
Additional context
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working