Erik
09/22/2022, 7:48 AMEmail/test
I have tried two different methods to access the block in my code.
Method 1:
from prefect.blocks.notifications import NotificationBlock
email = NotificationBlock().load('Email/test')
and I get the following error
File PYTHON/site-packages/prefect/blocks/core.py:836, in Block.__new__(cls, **kwargs)
834 return m
835 else:
--> 836 m = super().__new__(cls)
837 object.__setattr__(m, "__dict__", kwargs)
838 object.__setattr__(m, "__fields_set__", set(kwargs.keys()))
TypeError: Can't instantiate abstract class NotificationBlock with abstract method notify
It turns out this error comes from any attempt to instantiate NotificationBlock()
. Can anyone else confirm this error when instantiating?
Method 2:
from prefect.blocks.core import Block
email = Block().load('Email/test')
and I get the following error
File PYTHON/site-packages/prefect/blocks/core.py:646, in Block.load(cls, name)
642 block_document = await client.read_block_document_by_name(
643 name=block_document_name, block_type_slug=block_type_slug
644 )
645 except prefect.exceptions.ObjectNotFound as e:
--> 646 raise ValueError(
647 f"Unable to find block document named {block_document_name} for block type {block_type_slug}"
648 ) from e
649 return cls._from_block_document(block_document)
ValueError: Unable to find block document named test for block type Email
even though the block has def been created in the UI.
Have I tried the right things? Is there some other way to access my Email block? Or is this a real bug?
PS (I see Mohamed Alaa write about a similar bug in this thread a few hours ago)Mohamed Alaa
09/22/2022, 7:59 AMErik
09/22/2022, 8:00 AMMohamed Alaa
09/22/2022, 8:02 AMJeff Hale
09/22/2022, 11:30 AMNotificationBlock().load
and you should be good to go. 🙂Erik
09/22/2022, 9:25 PMBlock.load('Email/test')
ValueError: Unable to find block document named test for block type Email
Block.load('email/test')
(lowercase) I get this.
KeyError: "No class found for dispatch key 'email' in registry for type 'Block'."
even though the prefect CLI prefect block ls
says that is the “slug”Jeff Hale
09/22/2022, 9:33 PMErik
09/22/2022, 9:37 PMprefect.blocks.system
I can import JSON
, String
, Datetime
, and Secret
Block types, but how do I import the Email
block class type, I can’t seem to find it.Jeff Hale
09/22/2022, 10:21 PMErik
09/22/2022, 10:22 PMJeff Hale
09/22/2022, 10:44 PMErik
09/23/2022, 12:15 AM