Sashank Nekkadapu
07/17/2025, 5:34 PMMarvin
07/17/2025, 5:34 PMMarvin
07/17/2025, 5:35 PMflow.from_source()
to dynamically pull and run flows from other repositories. Here's how you can do it:
1. For a public repository:
python
from prefect import flow
# Reference the flow from the other repository
remote_flow = flow.from_source(
source="<https://github.com/other-org/other-repo.git>",
entrypoint="path/to/file.py:flow_name"
)
@flow
def my_flow():
# Call the remote flow
result = remote_flow()
return result
2. For a private repository, you'll need to set up authentication:
python
from prefect import flow
from prefect.filesystems import GitRepository
from prefect.blocks.system import Secret
# Set up Git repository with credentials
git_repo = GitRepository(
url="<https://github.com/other-org/other-repo.git>",
credentials={"access_token": Secret.load("github-access-token")}
)
remote_flow = flow.from_source(
source=git_repo,
entrypoint="path/to/file.py:flow_name"
)
@flow
def my_flow():
result = remote_flow()
return result
A few important notes:
1. The entrypoint
parameter should point to the specific file and flow name in the format "path/to/file.py:flow_name"
2. For private repositories, you'll need to create a GitHub access token and store it as a Prefect Secret
3. The repository will be cloned at runtime, so you don't need to manually copy any code
4. Make sure any dependencies required by the remote flow are installed in your environment
You can then deploy this flow like any other:
python
my_flow.deploy(
name="cross-repo-flow",
work_pool_name="your-work-pool"
)
This approach gives you the flexibility to keep your code separate while still being able to execute flows from different repositories dynamically. The repository will be cloned fresh each time the flow runs, ensuring you always have the latest code.
Would you like me to provide more specific details about any part of this setup, such as creating secrets or handling dependencies?Sashank Nekkadapu
07/17/2025, 5:39 PMMarvin
07/17/2025, 5:39 PMreview_common_3x_gotchas
📊 Tools used:
• display_callable_signature
(17x)
• explore_module_offerings
(34x)
• research_prefect_topic
(17x)
• review_common_3x_gotchas
(14x)
• search_prefect_3x_docs
(17x)Marvin
07/17/2025, 5:40 PMsearch_prefect_3x_docs
📊 Tools used:
• display_callable_signature
(102x)
• explore_module_offerings
(68x)
• get_latest_prefect_release_notes
(17x)
• research_prefect_topic
(17x)
• review_common_3x_gotchas
(17x)
• search_prefect_3x_docs
(83x)