Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for alternative notebook PDF converters (e.g. webpdf) #675

Closed
edublancas opened this issue Mar 22, 2022 · 5 comments
Closed

support for alternative notebook PDF converters (e.g. webpdf) #675

edublancas opened this issue Mar 22, 2022 · 5 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@edublancas
Copy link
Contributor

(see #672 and #658 for context)

There are a few engines to convert .ipynb to .pdf, however, we only support the default one provided by nbconvert, which depends on pandoc and text. It has a few downsides such as not being able to render embedded charts (see #658), we should add support for other engines

@edublancas edublancas changed the title support for alternative PDF converters support for alternative notebook PDF converters (e.g. webpdf) Mar 31, 2022
@neelasha23
Copy link
Contributor

Can I work on this issue?

@idomic
Copy link
Contributor

idomic commented Apr 1, 2022

Go ahead! Thank you for contributing and reach out if you have any issues.

@edublancas
Copy link
Contributor Author

A few pointers:

This is the implementation of the task that runs scripts. the nbconvert_exporter_name can switch to webpdf

And this is where the notebook conversion logic happens - we rely on nbconvert for format conversion so please check the docs.

Parameters from the pipeline.yaml are passed to the NotebookConverter.
example:

  - source: fit.py
    nbconvert_exporter_name: webpdf
    name: fit
    product:
        model: output/model.pickle
        nb: output/report.pdf

If you try this, it'll fail and ask you to run pip install nbconvert[webpdf], that's ok, the user can install it once they see the message.

If you try again, it'll complain that chromium is missing. The exporter has an option to automatically download it so we need to ensure that when we instantiate the webpdf exporter, we set that to true. So you'll need to dig into nbconvert's docs/surce code

@neelasha23
Copy link
Contributor

@edublancas Thanks a lot for the pointers!

@edublancas
Copy link
Contributor Author

edublancas commented Apr 11, 2022

(this will be part of the next release, coming up in a few days)

closing this. thanks to @neelasha23 for putting this together!

I'll create a new section in the docs to show this and a few extra things, for the moment being, this is how to use webpdf:

  - source: scripts/fit.py
    product:
      nb: products/report.pdf
    nbconvert_exporter_name: webpdf  

This will download chromium if needed, note that this requires: pip install "nbconvert[webpdf]"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants