https://prefect.io logo
Title
a

Alex

02/06/2023, 9:42 AM
Hi. I am registered custom block. Then I try import it:
from __prefect_loader__ import CustomBlockName
But I get an error: ModuleNotFoundError: No module named '__prefect_loader__' How can I fix it?
j

Jason Noxon

02/15/2023, 1:06 PM
Hi! I am also running into this. Same exact scenario - did you ever find a fix for it?
e

Eric Sexton

02/20/2023, 10:18 PM
@Emil Christensen this is also the error that I am running into that was in regards to custom blocks mentioned in our call last week. Do you have any insight for this?
e

Emil Christensen

02/21/2023, 2:16 PM
My understanding is that
__prefect_loader__
is just a placeholder there. The
CustomBlockName
needs to be imported and available wherever you’re using it (i.e. in your flow code). You can also set
PREFECT_EXTRA_ENTRYPOINTS
(doc) to force loading the block.
:party-parrot: 1
👍 1
j

Jason Noxon

02/21/2023, 2:23 PM
Now that I saw how this is done, the block needs to be imported from the python file (apparently Prefect doesn't want to run random code in their system, sheesh!) So, the import would just be
import MyCustomBlock
having the python file for that custom block handy. Prefect will store the parameters for the block, but not the block code. SO - suggestion: as a default, this info should probably be on the block screen when a custom block is created...maybe?