Bryan
08/12/2024, 10:32 PM"No class found for dispatch key 'secure-generic-credentials' in registry for type 'Block'."
Marvin
08/12/2024, 10:33 PMBlock
and register the block appropriately.
2. Documentation on Creating and Using Blocks: The process of creating and registering custom blocks is outlined in the Prefect documentation. You can follow the instructions here to properly declare and register your custom block.
To help you further, please provide more details on how you're creating and using your custom block. If you've already followed the documentation and still face issues, verifying the block's registration or checking for typos in the dispatch key might be necessary.
For more in-depth guidance, refer to the provided documentation link.Bryan
08/12/2024, 11:02 PMprefect block type ls
. I created a block from the custom block type using the Prefect Cloud UI. I can see that the block is registered when I run prefect block ls
. I am getting an error when loading the block in my code. The code I am using is:
from prefect.blocks.core import Block
some_creds = Block.load("generic-credentials/some-usage-of-creds")
When I execute the code I am presented with this error: KeyError: "No class found for dispatch key 'generic-credentials' in registry for type 'Block'."
How can I fix this error?Marvin
08/12/2024, 11:02 PMpython
from your_custom_module import GenericCredentials
from prefect.blocks.core import Block
some_creds = Block.load("generic-credentials/some-usage-of-creds")
2. Check the Naming and Registration:
Verify that the name used in Block.load
matches exactly with the registered block type, including case sensitivity.
3. Re-register the Block Type:
Ensure that the block type is registered in the current Python environment where you are running your script:
python
from prefect.blocks.core import Block
from your_custom_module import GenericCredentials
GenericCredentials.register_type()
some_creds = Block.load("generic-credentials/some-usage-of-creds")
4. Manual Loading Using Custom Class:
Instead of using Block.load
, you can directly use the class name to load the block:
python
from your_custom_module import GenericCredentials
some_creds = GenericCredentials.load("generic-credentials/some-usage-of-creds")
To see a detailed guide on creating, registering, and using custom block types, refer to the Prefect documentation here.
Give these steps a try and let me know if you still face issues.Kevin Grismore
08/12/2024, 11:08 PMKevin Grismore
08/12/2024, 11:09 PMfrom my_custom_block import MyCustomBlockType
my_block = MyCustomBlockType.load("name")
Nate
08/12/2024, 11:09 PMBryan
08/12/2024, 11:10 PMKevin Grismore
08/12/2024, 11:10 PMNate
08/12/2024, 11:11 PMKevin Grismore
08/12/2024, 11:11 PMBryan
08/12/2024, 11:13 PMKevin Grismore
08/12/2024, 11:14 PMKevin Grismore
08/12/2024, 11:15 PMNate
08/12/2024, 11:16 PMBryan
08/12/2024, 11:18 PMNate
08/12/2024, 11:19 PMSecretDict
which stores a value: Dict[str, SecretStr]
or something like that
you can open an issue here if that sounds like what you needBryan
08/12/2024, 11:20 PM