Moe
03/20/2024, 5:56 PMJeff Hale
03/20/2024, 6:32 PMMoe
03/20/2024, 6:36 PMNate
03/20/2024, 7:14 PMIn [1]: from prefect.blocks.core import Block
14:12:12.038 | DEBUG | prefect.profiles - Using profile 'pong'
In [2]: from prefect.blocks.fields import SecretDict
In [3]: class MyVault(Block):
...: values: SecretDict
...:
In [4]: MyVault(values={"foo": 42})
Out[4]: MyVault(values=SecretDict('{'foo': '**********'}'))
In [5]: _.values.get_secret_value()
Out[5]: {'foo': 42}Nate
03/20/2024, 7:16 PMMyVault someplace and then prefect block register -f where_its_defined.py and then that block would be available in your workspace. You'd just need the class definition wherever you want to load itNate
03/20/2024, 7:19 PMdict and store it in a Secret block and deserialize it after doing Secret.load("my-secret-dict-str")Moe
03/20/2024, 7:22 PMMoe
06/04/2024, 5:28 PMSecret block?Moe
06/04/2024, 6:12 PMNate
06/04/2024, 6:38 PMSecret specifically
In [1]: from prefect.blocks.system import Secret
In [2]: import json
In [3]: d = {"b": 1, "a": 2}
In [4]: Secret(value=json.dumps(d)).save("test", overwrite=True)
Out[4]: UUID('e3f1b4a1-0844-4659-88da-806b7fa003b5')
In [5]: assert json.loads(Secret.load("test").value.get_secret_value()) == dMoe
06/06/2024, 2:53 PM