https://prefect.io logo
Title
n

Nic

10/27/2022, 10:50 AM
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

Jeff Hale

10/27/2022, 11:52 AM
Hi Nic. It will work fine in a Notebook also, if you use in a flow or task. For example.
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.
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

Nic

10/27/2022, 11:54 AM
Great, will change it around then - thanks for the very descriptive reponse
👍 1