https://prefect.io logo
Title
t

Tan Li

10/04/2022, 11:50 PM
hi folks, first of all, wanna thank you for creating such a great tool! I recently realized that besides the workflow orchestration, the block is a really convenient feature for me to store sensitive data. I am wondering, if it possible to use the Prefect block as a standalone module? e,g. using
Secret.load("github-access-token").get()
in normal python scripts?
1
m

Matt Conger

10/05/2022, 12:14 AM
Hi Tan, I have included the documentation below for our blocks section. Blocks are usually called during a flow or task run, but they can also be loaded with a unique slug. https://docs.prefect.io/concepts/blocks/
🙌 1
t

Tan Li

10/05/2022, 6:20 PM
Thanks @Matt Conger! Maybe I should just try it out, but I am curious, if we are using block in a standalone way, as stated in the docs, how does the script know the URL of the orion server? i.e. where to fetch the block data?
from prefect.blocks.core import Block

json_block = Block.load("json/life-the-universe-everything")
print(json_block.value["the-answer"]) #42
m

Matt Conger

10/05/2022, 10:57 PM
Tan, I think even with this method we would still need to have the script integrated with Prefect. I personally have only been using the blocks inside flows but it's definitely worth checking out.
🙌 1