https://prefect.io logo
Title
n

Nico Neumann

05/26/2023, 1:05 AM
I upgraded to the latest
prefect==2.10.11
version because of sqlalchemy 2.0 support. Thanks for the fast support there! 🚀 Now I have a problem with my custom block when I try to run my flows:
KeyError: "No class found for dispatch key 'my-custom-block' in registry for type 'Block'."
prefect_aws==0.3.2
is installed and
PREFECT_EXTRA_ENTRYPOINTS
is set. I’m using prefect cloud and the agent is updated to the latest version. I downgraded my prefect docker image to version 2.10.10 and it works fine again. Full log attached in the thread
Flow could not be retrieved from deployment.
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/prefect/engine.py", line 310, in retrieve_flow_then_begin_flow_run
    flow = await load_flow_from_flow_run(flow_run, client=client)
  File "/usr/local/lib/python3.10/site-packages/prefect/client/utilities.py", line 40, in with_injected_client
    return await fn(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/prefect/deployments.py", line 191, in load_flow_from_flow_run
    storage_block = Block._from_block_document(storage_document)
  File "/usr/local/lib/python3.10/site-packages/prefect/blocks/core.py", line 618, in _from_block_document
    else cls.get_block_class_from_schema(block_document.block_schema)
  File "/usr/local/lib/python3.10/site-packages/prefect/blocks/core.py", line 672, in get_block_class_from_schema
    return cls.get_block_class_from_key(block_schema_to_key(schema))
  File "/usr/local/lib/python3.10/site-packages/prefect/blocks/core.py", line 683, in get_block_class_from_key
    return lookup_type(cls, key)
  File "/usr/local/lib/python3.10/site-packages/prefect/utilities/dispatch.py", line 185, in lookup_type
    raise KeyError(
KeyError: "No class found for dispatch key 'my-custom-block' in registry for type 'Block'."
Minimal example of my Block:
class MyCustomBlock(S3Bucket):
    _block_type_name = "My Custom Block"
    _block_type_slug = "my-custom-block"

    @sync_compatible
    async def put_directory(
        self,
        local_path: Optional[str] = None,
        to_path: Optional[str] = None,
        ignore_file: Optional[str] = None,
    ) -> int:
        # ...

    @sync_compatible
    async def get_directory(self, from_path: Optional[str] = None, local_path: Optional[str] = None) -> None:
        # ...
I tried to fix it but was not able to do that. So I opened an issue with steps on how to reproduce it: https://github.com/PrefectHQ/prefect/issues/9754