https://prefect.io logo
Title
y

Yaron Levi

01/15/2023, 1:47 PM
Hi 👋 I am trying to define my own new Infrastructure class, but getting the error: “No class found for dispatch key ‘xxx’ in registry for type ‘Block’” full info in this thread: https://discourse.prefect.io/t/submission-failed-keyerror-no-class-found-for-dispatch-key-xxx-in-registry-for-type-block/2203/1 Any ideas what am I doing wrong here?
1
r

Ryan Peden

01/15/2023, 4:35 PM
Hi Yaron, did you use
prefect block register
to register your block?
y

Yaron Levi

01/15/2023, 4:37 PM
I guess not (-: You are referring to this step?
r

Ryan Peden

01/15/2023, 4:47 PM
Yes, that's the one. If the block isn't registered, it won't show up in the UI and your agent also won't be able to find it. You may need to register it separately on the agent machine after you register it with Orion or Perfect Cloud. If the block is in its own package, there's a line you can add to
setup.py
to get your block to auto register when Prefect loads. I'm afk at the moment but can send examples soon if you'd like. To start, I'd suggest looking at
entryoints
in
setup.py
in either the prefect-aws or prefect-azure repositories on GitHub.
y

Yaron Levi

01/15/2023, 4:48 PM
Great! I’ll check it and update how it goes
👍 1
r

Ryan Peden

01/15/2023, 4:57 PM
Sounds good! Looking forward to hearing how it goes.
1
I marked this thread with a green check just to let others know it's being handled, but please feel free to keep posting here if you encounter any more blockers.
y

Yaron Levi

01/15/2023, 4:59 PM
I am also preparing an article how to take it end-2-end. Meaning building a RenderTask infra block
:gratitude-thank-you: 1
👍 1
r

Ryan Peden

01/15/2023, 5:03 PM
That sounds great! For a while now, I've wanted to write a general article to help users who want to add new infrastructure like this. So I'm very interested in reading about your experience creating the Rendet infra block! 😀
:gratitude-thank-you: 1
y

Yaron Levi

01/15/2023, 5:07 PM
great! I’ll send it once it’s ready
a

Anna Geller

01/15/2023, 6:36 PM
Adding an entrypoint is an excellent suggestion https://github.com/PrefectHQ/prefect/pull/7179 for the next time, please decide whether you post on Discourse or Slack, not both https://discourse.prefect.io/faq
thanks for volunteering to write a post about Render block, keep us posted whether you need help with a review or have questions 🙌
y

Yaron Levi

01/17/2023, 5:35 PM
@Ryan Peden So I run this to register the infrastructure block:
prefect block register --file jobs/test2/render_job_infrastructure.py
CleanShot 2023-01-17 at 19.35.55@2x.jpg
and it’s now showing in the catalog:
CleanShot 2023-01-17 at 19.36.26@2x.jpg
added a new block of this type:
CleanShot 2023-01-17 at 19.37.14@2x.jpg
copied this code:
CleanShot 2023-01-17 at 19.37.34@2x.jpg
and pasted it in the deployment script:
CleanShot 2023-01-17 at 19.38.21@2x.jpg
but when running the file to apply() the changes, I get this error:
CleanShot 2023-01-17 at 19.38.48@2x.jpg
No module named ‘__prefect_loader__’