Milan Valadou
08/05/2022, 10:29 AM---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [1], in <cell line: 6>()
3 secret_block = Secret.load("etlharvestqaspassword")
5 # Access the stored secret
----> 6 secret_block.get()
AttributeError: 'coroutine' object has no attribute 'get'
I defined the block within the Orion UI, because when I tried to define it via code in a simple script (as suggested here), I get the following kind of error:
prefect.exceptions.PrefectHTTPStatusError: Client error '422 Unprocessable Entity' for url '<http://ephemeral-orion/api/block_documents/>'
Response: {'exception_message': 'Invalid request received.', 'exception_detail': [{'loc': ['body', 'name'], 'msg': 'name must only contain lowercase letters, numbers, and dashes', 'type': 'value_error'}, {'loc': ['body', '__root__'], 'msg': 'Names must be provided for block documents.', 'type': 'value_error'}], 'request_body': {'name': 'test2_password', 'data': {'value': 'test2'}, 'block_schema_id': '8019abd6-409a-4f91-9367-bc8343c31763', 'block_type_id': '29fb0ec8-f7e9-4527-984c-48f8675f2bc4', 'is_anonymous': False}}
For more information check: <https://httpstatuses.com/422>
I’m mostly using Prefect within a jupyter notebook and from within a virtualenv.
Thanks in advance for anyone who could point me to what’s going on 🙂Mason Menges
08/05/2022, 2:57 PMblock = Secret.load("blockname")
block["nameofsecret"]
There's no get method on a secret block
You can checkout more about it here https://docs.prefect.io/concepts/blocks/
As for the error you received it looks like the name you passed in contained an underscore(_) when it should only contain lowercase letters, numbers and dashes(-).Milan Valadou
08/05/2022, 3:07 PM.get()
on a loaded Secret? I’m probably missing something, so thanks for clearing that up if it is the case 🙂Mason Menges
08/05/2022, 3:08 PMMilan Valadou
08/05/2022, 3:08 PMMilan Valadou
08/05/2022, 3:11 PMMason Menges
08/05/2022, 3:15 PMKhuyen Tran
08/05/2022, 3:16 PMfrom prefect.blocks.system import Secret
Milan Valadou
08/08/2022, 11:52 AM.get()
works on a Block in jupyter notebooks, if you use await
when creating the Block. Similarly, using await
in a ‘normal’ flow (via a script) does result in an error.Mason Menges
08/08/2022, 8:57 PMSam Garvis
08/16/2022, 4:19 PMfrom prefect.blocks.system import Secret
secret_block = Secret.load("slackbot-oauth")
secret_block.get()
results in AttributeError: 'coroutine' object has no attribute 'get'
But
from prefect.blocks.system import Secret
secret_block = await Secret.load("slackbot-oauth")
secret_block.get()
works. However, I would prefer my functions to not be asynchronous, but I have to make them asynchronous to use await.
It would also be very nice to continue using jupyter lab, but for now I will use something else to dev in 2.0Bring 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