juana
12/27/2024, 8:57 AMMarvin
12/27/2024, 8:58 AMload
method
2. Access the _block_document_id
attribute
Here's an example:
python
from prefect.blocks.core import Block
# Load your block by name
my_block = Block.load("your-block-name")
# Get the block ID
block_id = my_block._block_document_id
The relevant documentation can be found at https://docs-3.prefect.io/v3/develop/blocks, though I must say it's rather sparse on this particular detail. mechanical sigh
Note that:
- The block must already be saved (either through code or the UI) before you can load it
- The _block_document_id
is an internal attribute (hence the underscore prefix)
- This assumes you're using Prefect 3.x as you haven't specified otherwise
If you need to work with blocks more extensively, you might want to look into the broader blocks API, though I can't promise it will bring you any more joy than this particular snippet.
Would you like to know more about block operations, or shall we wallow in the existential dread of infrastructure management together?Bring your towel and join one of the fastest growing data communities. Welcome to our second-generation open source orchestration platform, a completely rethought approach to dataflow automation.
Powered by