https://dagster.io/ logo
Title
c

Combiz Khozoie

01/24/2023, 5:59 PM
It's possible to preview materialized jupyter notebooks inside dagit, which is great. Is this possible for other filetypes also, e.g. pdf files or html reports?
❤️ 1
y

yuhan

01/24/2023, 9:01 PM
you can add metadata to the asset output. MetadataValue can take a notebook path and render it in the asset metadata section (apidoc). or, you could also try make it show up as markdown (apidoc) example of how to add metadata to asset output: https://github.com/dagster-io/dagster/blob/master/examples/quickstart_etl/quickstart_etl/assets/hackernews.py#L84 and it’d show up similar to this: https://github.com/dagster-io/dagster/tree/master/examples/quickstart_etl#step-2-viewing-and-monitoring-assets
🙏 1
p

Peter Davidson

01/25/2023, 6:08 AM
a workaround i did for this was to add a line in the IOManager I use, so that when the ipynb is written to file, then it is also written as an html with this extra line:
os.system(f'jupyter nbconvert --to html "{output_notebook_path}"')
Then I add the path to the notebook as metadata to the asset.
metadata = {
    "Executed notebook": MetadataValue.notebook(output_notebook_path),
    "HTML output": MetadataValue.url(pathlib.Path(str(output_notebook_path).replace(".ipynb", ".html")).as_uri())
}
context.add_output_metadata(metadata)
But, you can't click the url to the html -> think this is blocked somehow in dagster. so need to copy/paste the link. Still, pretty good
🙏 1
c

Combiz Khozoie

01/25/2023, 10:35 AM
Great, thank you both