-
Notifications
You must be signed in to change notification settings - Fork 85
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
Feature Request: doctest for code-cell #290
Comments
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
I think this is a cool idea...I wonder if this could also be part of the spec of |
If the team is open to it, I'd like to work on adding Jupyter notebooks can have multiple outputs per cell; this could be represented in myst-nb by having multiple I think it would make sense for the spec to be something like this:
If a Note that this is tabling the idea of doctesting for the time being, but this seems like a good foundation on which doctesting could be built. Would the team support an approach along these lines? |
Heya, Perhaps
this is probably the tricky part, note I'm changing how the AST works quite a bit soon (currently on a personal branch), so I would be wary of relying on exactly how it is now. Just to note some other potential solutions (not to say they are better than your one); with pytest-notebook and nbval you can have a fully populated notebook then test that the same outputs are present on re-execution.
|
I was imagining this as a more general thing than asserting outputs. Currently This would allow approaches like Does that make sense? |
eurgh, personally I don't think its a good idea to be storing outputs in a Markdown file; trying to store heirarchical data in a non-heirarchical format is just going to lead to overly verbose, unreadable files. At any rate, I would not really want to support this until it was supported in jupytext, i.e. there has to be two-way conversion between the Markdown files and Notebooks: see mwouts/jupytext#220 for discussion |
I'm open to discussion, I'm just not convinced it is a good idea to basically try to turn a Markdown file into a JSON one |
OK, fair enough. If you’re not open to storing outputs in markdown, are you open to potentially supporting a different way to validate code output in-situ, since the testing tools you mentioned require the presence of outputs in the file? |
good point about jupytext @chrisjsewell - agreed that this is probably where text-based outputs should be instead of something that myst-specific @jakevdp for context, we use jupytext for all of the Perhaps we could brainstorm a bit in that issue? Or @mwouts could provide his latest thinking on this topic? I do think it warrants a bit of thought and discussion that'd benefit from multiple perspectives, since we do run the risk of just re-creating all of the problems with Shall we take conversation around "generic outputs for text-based notebooks" into a different issue (or the jupytext one) so that we can continue discussing the right way to handle assert-style statements in a myst notebook? back to testing now One other thought that we could consider following for the output tests is something similar to |
Thanks for the context, @choldgraf. I was aware of the code at jupytext, but I thought that this repo was the source of truth for the myst-nb spec. If it makes sense to discuss there instead, then we can do that. |
I do think that this repo is the "source of truth", it's just that one of MyST's principles is to piggy-back off of other projects and their patterns/standards as much as possible, rather than invent things that are myst-specific. I think it'd potentially be a more wide-reaching and impactful feature if outputs were supported in Jupytext, and then we could inherit those into MyST-NB and start upstreaming improvements. Does that make sense? |
Hi everyone, yes the project to add outputs to Jupytext's Markdown formats mwouts/jupytext#220 has been there for a while! What I am waiting for is the following: I'd like to find a satisfactory way to include a text file within a Markdown file. By satisfactory I mean that (just like for images, and for HTML files)
Do you think this will happen? |
Re: |
It would be useful to be able to doctest myst-nb notebooks within a sphinx project. For example, sphinx.ext.doctest provides the
testcode
andtestoutput
directives that let you do something like this inmyst-md
:It would be nice if a similar mechanism existed to specify expected outputs for myst-nb code-cells; e.g.
If this were automatically tested in the same way that
testcode
andtestoutput
are, it would make it easier to detect when myst-nb docs get stale.The text was updated successfully, but these errors were encountered: