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

Outsource the "pure python notebook" lib #933

Open
smarie opened this issue Mar 22, 2022 · 8 comments
Open

Outsource the "pure python notebook" lib #933

smarie opened this issue Mar 22, 2022 · 8 comments

Comments

@smarie
Copy link

smarie commented Mar 22, 2022

Today while working on #930, thinking that I was going to duplicate the fix for mkdocs-gallery (#895),
I asked myself what could be the scope of a common core lib supporting both.

At least there is one thing that would make sense: the "pure python notebook engine", that currently

  • defines the syntax of docstring+code blocks
  • parses in-blocks directives
  • provides the per-block execution and output
  • provides the capability to export as an actual jupyter notebook

We could call such a shared lib "pynotebook" but the name is already used, so maybe something like "pure_notebook" ?
What do you think ?

@smarie smarie changed the title Outsource the "pute python notebook" lib Outsource the "pure python notebook" lib Mar 22, 2022
@larsoner
Copy link
Contributor

larsoner commented Apr 3, 2022

Instead of requiring a separate lib, could mkdocs-gallery just depend on sphinx-gallery, and we make the interface in this lib?

@smarie
Copy link
Author

smarie commented Apr 12, 2022

Not really, as mkdocs-gallery has not dependency to any sphinx lib, just mkdocs. The engine could be completely independent of any external dependency (thus, solving #421 by creating an autidable independent lib, that at least could be compared with the jupyter one based on common tests, for example)

EDIT: actually #421 was more about rich output (scrapers), my proposal is really much more focused on simple cell-by-cell execution and results collection. So, the two tickets are not that connected

@larsoner
Copy link
Contributor

Not really, as mkdocs-gallery has not dependency to any sphinx lib, just mkdocs.

Makes sense then!

EDIT: actually #421 was more about rich output (scrapers), my proposal is really much more focused on simple cell-by-cell execution and results collection

In some sense "rich scraping" could be considered a form of "results collection" / "output" capture. It really depends on what me mean by "output". If by "output" you mean stdout/stderr and not anything graphical, then scrapers would be excluded, and would stay in the sphinx-gallery scope. But would this really be optimal for mkdocs-gallery? I would assume that getting execution + prints + figures/images would be much more useful, no?

@smarie
Copy link
Author

smarie commented Apr 12, 2022

Yes, you are right. I guess that we could start with pure doc extraction + block-wise execution + config + raw output variables gathering, and then add an optional scrapers engine.

@smarie
Copy link
Author

smarie commented Mar 17, 2023

Hi @larsoner , long time no chat :) I was trapped in many other industrial activities unfortunately.
I came across https://jupytext.readthedocs.io/en/latest/using-library.html recently

Do you have an opinion about how this could possibly be a candidate to replace the "common core" that I was mentioning above ? Or is this lib "not independent enough" (from jupyter) in your mind to be a suitable core engine for sphinx-gallery ?

@larsoner
Copy link
Contributor

At least 4 years ago they used our code for conversion I think?

#424 (comment)

But maybe it's not that way today...

@GaelVaroquaux
Copy link
Contributor

GaelVaroquaux commented Mar 17, 2023 via email

@smarie
Copy link
Author

smarie commented Mar 17, 2023

Very clear @GaelVaroquaux thanks ! So better an independent lib in charge of managing this rst (and possibly md in the future) representation and execution of a notebook, than trying to reuse jupytext because of its dependency to nbformat.
The "refactored" engine clone in mkdocs-gallery, or the original engine itself in sphinx-gallery, could be a good source for this, but someone still needs to extract it, define a clear API and publish it. Hopefully one of these days someone motivated enough could try that move. For now I do not have visible bandwidth in the upcoming months, but "you never know" :)

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

No branches or pull requests

3 participants