Skip to content

Instantly share code, notes, and snippets.

@vestalisvirginis
Last active November 8, 2023 17:44
Show Gist options
  • Save vestalisvirginis/3a1b4f5bd89e1f27f90dd4677e39e3df to your computer and use it in GitHub Desktop.
Save vestalisvirginis/3a1b4f5bd89e1f27f90dd4677e39e3df to your computer and use it in GitHub Desktop.
add image to Dagster as asset metadata
# 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