How do we use the prefect string and secret blocks...
# prefect-community
n
How do we use the prefect string and secret blocks in an ipynb file? It works fine in py files, but when using then in notebooks i get following error
1
j
Hi Nic. It will work fine in a Notebook also, if you use in a flow or task. For example.
Copy code
from prefect.blocks.system import String
from prefect import flow

@flow()
def get_vals():
    ds_server = String.load("ds-server").value
    ds_user = String.load("ds-user").value
    print(ds_server)
    print(ds_user)

get_vals()
Returns.
Copy code
07:45:55.538 | INFO    | prefect.engine - Created flow run 'cautious-tapir' for flow 'get-vals'
07:45:56.174 | INFO    | Flow run 'cautious-tapir' - Finished in state Completed()
I believe it has something to do with how a Notebook uses processes, such as described here.
n
Great, will change it around then - thanks for the very descriptive reponse
👍 1