Scott
01/16/2025, 8:35 PMMarvin
01/16/2025, 8:35 PMfrom_source
method, which allows you to define the source directory and the specific Python file and function where the flow is defined:
python
from pathlib import Path
from prefect import flow
@flow(log_prints=True)
def my_flow(name: str = "world"):
print(f"Hello {name}! I'm a flow from a Python script!")
if __name__ == "__main__":
my_flow.from_source(
source=str(Path(__file__).parent),
entrypoint="from_local_source.py:my_flow",
).deploy(
name="my-deployment",
parameters=dict(name="Marvin"),
work_pool_name="local",
)
This flexibility allows you to organize your codebase as you see fit, without being constrained to a specific directory structure. You can find more about this in the Prefect documentation.