Alejandro
10/24/2022, 4:49 PMBlock
inside the class in which another Block
is defined using the Python API?
class Foo(Block):
target_name: str
_block_type_slug = "foo-block"
def block_initialization(self) -> None:
bar_block = JSON.load("bar-block").value
another_block = JSON.load(target_name).value
I have tried with the above code but I get the following warning, which results in a coroutine being returned instead of a block:
RuntimeWarning: coroutine 'Block.load' was never awaited
Andrew Huang
10/24/2022, 5:05 PMasync def block_initialization(self) -> None:
bar_block = await JSON.load("bar-block").value
another_block = await JSON.load(target_name).value
but maybe it’ll just have another coroutine output since https://github.com/PrefectHQ/prefect/blob/ab5310827e88124538d8e9e5e9b63c427edd5d28/src/prefect/blocks/core.py#L176 is not async
perhaps you can try to use sync()? https://github.com/PrefectHQ/prefect/blob/main/src/prefect/utilities/asyncutils.py#L221Alejandro
10/31/2022, 8:54 AM