Last active
November 8, 2023 17:44
-
-
Save vestalisvirginis/3a1b4f5bd89e1f27f90dd4677e39e3df to your computer and use it in GitHub Desktop.
add image to Dagster as asset metadata
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# For metadata | |
buffer = BytesIO() | |
_gd_diagram.write(buffer, "png") | |
image_data = base64.b64encode(buffer.getvalue()) | |
# Asset metadata | |
context.add_output_metadata( | |
metadata={ | |
"text_metadata": "A synteny diagram had been created.", | |
"num_sqcs": len(_records), | |
"path": _path_output, | |
"sequences": MetadataValue.json(_record_names), | |
"synteny_overview": MetadataValue.md( | |
f"![img](data:image/png;base64,{image_data.decode()})" | |
), | |
} | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment