From 0c2b61e7b92b4de1e2be3fcd7bed52aae32d73dd Mon Sep 17 00:00:00 2001 From: justine Date: Tue, 6 Aug 2024 10:46:56 -0400 Subject: [PATCH] add ipython display for yaml recipe --- code_data_science/yaml_recipe.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 code_data_science/yaml_recipe.py diff --git a/code_data_science/yaml_recipe.py b/code_data_science/yaml_recipe.py new file mode 100644 index 0000000..6c3dbf0 --- /dev/null +++ b/code_data_science/yaml_recipe.py @@ -0,0 +1,15 @@ +from IPython.display import display as ipython_display +import base64 + + +def display(yaml_recipe:str): + """ + Converts YAML recipe as a string to a format that can be visualized as a code snippet. + """ + + # Create the output dictionary + ipython_display({ + "application/vnd.moderne.yamlrecipe": { + "code": base64.b64encode(yaml_recipe) + } + }, raw=True)