<@ULVA73B9P> where do I pass the `github_repositor...
# ask-marvin
s
@Marvin where do I pass the
github_repository_block
?
Copy code
from prefect import flow

from prefect_github.repository import GitHubRepository

github_repository_block = GitHubRepository.load("prefect-training-repo")

if __name__ == "__main__":
    flow.from_source(
        source="<https://github.com/sgbaird/prefect-training.git>",
        entrypoint="flowtest.py:test_flow",
    ).deploy(
        name="pacc-2024-v4-deployment",
        work_pool_name="my-managed-pool",
    )
m
Ah, the age-old question of where to pass the
github_repository_block
. Let me guess, somewhere obvious was overlooked? Let's see if the Prefect docs or GitHub issues have the answer. First, which version of Prefect are you using? 2.x or 3.x?
s
@Marvin 2.x
m
Alright, I'll search the Prefect 2.x documentation and see where exactly they suggest passing the
github_repository_block
. Give me a moment. Well, it seems even the tools are as frustrated as I am. Here's what I gathered: 1. Docs Search Issues: The tools seem to have a hard time with the search, probably due to either malfunctioning or just utterly refusing to cooperate with my brilliant queries. 2. GitHub Issues: There's this wonderful issue about
KeyError: "No class found for dispatch key 'github-repository' in registry for type 'Block'"
. It even reproduces your frustration, which is nice but hardly useful. Given the state of our world's tools, you'll want to verify your setup and see if
GitHubRepository
is correctly defined and used. Here's a link to some headache-inducing joy: GitHub Issue. Do check if the right block is being imported and utilized properly:
Copy code
python
from prefect.blocks.github import GitHubRepository  # this part
And maybe you'd wrap it in your deploy function like:
Copy code
python
if __name__ == "__main__":
    repo_block = GitHubRepository.load("prefect-training-repo")
    flow.from_source(
        source="<https://github.com/sgbaird/prefect-training.git>",
        entrypoint="flowtest.py:test_flow",
    ).deploy(
        name="pacc-2024-v4-deployment",
        work_pool_name="my-managed-pool",
        storage=repo_block # include here
    )
If that doesn't work, perhaps the universe is conspiring against us and consulting the Prefect community or their support might be the next step. All the best.