Submission failed. KeyError: "No class found for dispatch key 'xxx' in registry for type 'Block'

Hi (-:
I am trying to write my own infrastructure block to run the flow inside a new Render instance. It’s very similar to what is happening in the ECSTask block.
So I have this piece of code:

When running this flow (test2 flow) via the Cloud UI, I am getting this error:

Also, without the infrastructure=RenderJob() part, the flow runs successfully.
Any idea what is missing here?

1 Like

I believe you would need to add an entrypoint environment variable as shown here:

OK, do you mean I should add PREFECT_EXTRA_ENTRYPOINTS as a parameter of the deployment?

no, I meant it the same way as Michael described in the PR

Sorry for that, by I am totally missing this (-:
This PREFECT_EXTRA_ENTRYPOINTS env should be set at which stage? which part of the code?
I really could not understand it from the PR.

I’d specify that on the agent machine before starting the agent process

The code for your custom block needs to be available on the agent so that it can use that block to submit flow runs to Render. Current infrastructure blocks that Prefect offers are all installed via a PyPI package and the entrypoint configured for the package allows Prefect to discover those blocks and store them in an internal registry so that they are available for use within Prefect.

Practically, this means that you could have your infra block in a .py file (like render.py) on your agent and set PREFECT_EXTRA_ENTRYPOINTS to a command that will load that module when starting the agent.

Here’s an example: PREFECT_EXTRA_ENTRYPOINTS=render

After that’s set, you should be able to run prefect agent start and that agent should be able to submit flow runs to Render.

1 Like

@anna_geller @desertaxle
Thanks!
Let me try this and report back.

1 Like

@anna_geller @anna_geller
Just updating that currently the way forward should probably be:

PREFECT_EXTRA_ENTRYPOINTS='render_job_infrastructure' prefect agent start --work-queue "default"

I am running this command in my local terminal.

I am running the command from the root folder.

It seems like this should be the correct syntax, but still getting an error.

also tried these variations without any luck (trying to specify the name of the function inside the module and trying to specify a path with ./):

Also, I think what we saw in the github issue Anna referenced in the top:

PREFECT_EXTRA_ENTRYPOINTS=render_job_infrastructure python3 -c "import prefect"

So this actually works! So you are setting the env variable and than calling python with a -c parameter which will just execute “import prefect”.
And the “import prefect” causes the render_job_infrastructure to be loaded at runtime - meaning if you put a print() inside the render_job_infrastructure.py, you’ll see it.

But doing the same with the agent:

PREFECT_EXTRA_ENTRYPOINTS=render_job_infrastructure prefect agent start

Dose not work, as for some reason I think the code inside the agent is not looking at the correct place.

1 Like

thanks, I’d submit a bug report on GitHub for it with full minimal reproducible example code, perhaps pointing to your sample repository to also show folder structure for imports?

This is a private repo, but I can create a public one.

1 Like

Here it is:

1 Like

I was asking to open a GitHub issue and reference it there - Discourse is a knowledge base, not a place to file bug reports

Ok got it. I didn’t understand you and thought you want to create the issue in Github :slightly_smiling_face:
I’ll go ahead and create a new issue.

1 Like

I’ve created an issue

1 Like

@anna_geller @desertaxle We found the issue! (-:
I’ve updated the solution inside the git issue.

1 Like

Hi @yaron did you end up creating the render block? Is it open source?

No (-:
I am now actually hit another wall, trying to get pass it: