-
Notifications
You must be signed in to change notification settings - Fork 392
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
Metadata for hiding input/output or cells #337
Comments
Hello @grst , thank you for this review, this is very helpful! The current mapping of the R Markdown options to the Jupyter notebook ones dates from one year ago (at that time Jupyter Book was not yet available). The cell metadata inserted by Jupytext are intended to be compatible with the runtools extension for Jupyter Notebook: jupytext/jupytext/cell_metadata.py Lines 24 to 28 in 4c1f817
I agree with your point that I should have mapped So let me summarize: we'd like to be able to
Maybe I would also like to select only certain types of outputs (only text, or only HTML, etc, like the The different contexts in which we want to be able to do that are
I think we're seeing more tags here than boolean, so maybe we can choose the current tags used by Jupyter Book as the reference. Regarding the removal of outputs, I'd be curious to know if @choldgraf thinks there's a use case for that? Is anyone (other than me!) interested by the filtering of outputs (my use case is selecting png over js before sending Markdown over email)? |
Thanks for looping me in - a few quick thoughts:
|
Ah, I wasn't aware of that. It adds the following metadata: {
"jupyter": {
"source_hidden": true
}
} collapse output {
"jupyter": {
"source_hidden": true
}
} collapssing both is simply a combination of the two {
"jupyter": {
"source_hidden": true,
"outputs_hidden": true
},
"collapsed": true
} However, I'm not sure if when I just hide away a big output in jupyterlab, I also wouldn't want it to be included in a report that I create using papermill or nbconvert. |
I'd really appreciate if a common standard could be established in the jupyter world! |
Yeah I agree - that's why for Jupyter Book I just decided to make people explicitly state it with a tag.
IMO we should try to pick a flavor of markdown to adopt, rather than create our own standard. Either RMarkdown or Pandoc Markdown seems reasonable to me. The trick is that I don't know of any python machinery to process these kinds of markdown, we'd need to use Pandoc (or R, I suppose) |
I know at least two of them: https://github.com/jankatins/knitpy, https://github.com/pystitch/stitch
Are there any pandoc arguments to hide inputs/outputs? I wouldn't guess so, because in plain markdown it's not even clear what "output" belongs to which code block... One the one hand, I'd opt to go for the Rmarkdown syntax, because it's pretty established. On the other hand I don't like it because it's neither intuitive nor consistent. ( |
@grst very cool! I remember seeing these some time ago but had forgotten about them. I wonder if there are pieces in there that could be pulled out for the md->html generation re: the RMarkdown syntax - I agree with you that the options for parameterization etc can be unintuitive. I'd probably opt to agree on the basic syntax structure (e.g. how parameters for code blocks are defined) rather than on the specific parameter key/values themselves. E.g., I like the idea of curly brackets for defining tags, something like
|
What for? Jupytext already does a great job converting (R)markdown to notebooks. And for notebooks to html there is FWIW, I stitched together jupytext, papermill and nbconvert in a quite straightforward python script to obtain that functionality.
I would have rather said the opposite :D. How to format the parameters in markdown etc. is pretty much given by the formats supported by jupytext. Independent of the format, they end up as json-formatted
Personally, I like the tags, because as @choldgraf mentioned, they are easy to add via UI and are supported by |
Right now the flavor of Markdown that Jupyter supports is extremely vanilla - it doesn't support things like footnotes, citations, or other extensions of any kind. Some of that we can store in cell metadata, but some of it needs to be in-line with the text and we'll need to improve the markdown -> html renderer in nbconvert for that. I agree that I think cell metadata is the way to go for storing most information and that jupytext can be the way to package that information with a notebook text file - I think that the (and yes, I agree tags are good as well!) |
Good point! Actually, once jupytext supports storing outputs in markdown format (#220), then |
@grst actually, pandoc already supports Jupyter Notebooks, you can do |
Hi @grst , @choldgraf , that's a very promising discussion! I agree with everything that was said above. And I do prefer tags over additional cell metadata. Regarding the @choldgraf , it's an interesting point that you're not fan of the "region" comments, and sure I'd like to use a more Markdown-ish approach. Pandoc's approach here could be of some inspiration, as they use nested divs ( Also, I would be interested to see an example notebook with notes. Would you like to share a link? Thanks! |
I checked the source code. Apparently outputs can have their own metadata and, therefore, tags. It checks |
yeah - I'm still unsure of how exactly we can easily add tags to outputs, but I thought that was kinda cool that you can filter outputs by mimetype :-) re: the "region" comments - I think they are totally fine to read, I just find them cumbersome to type. The reason I like the |
Hello @grst , @choldgraf , I think I'm good with the cell tags that we're discussing here, i.e.
@grst , I see that R Markdown now has an option to hide (collapse) all the inputs in the HTML rendering of an Rmd document, see here. Do you know if this is something we can configure per cell? If yes, maybe I'd like to do the mapping of the Also, @choldgraf , when I compare to R Markdown I see that they give the option to change the default value for including inputs/outputs globally. Is this something that we would be interested to have? Should we have a |
@mwouts, I couldn't figure out a way of setting Good initiative to get the |
Hey all - a few thoughts to your questions:
|
I'm not sure if this is the correct issue for this, but it riffs on the idea of "hiding" cells. In particular, I'm trying out a workflow where I author a module in a notebook as an I can pair the Is there a jupytext filter that lets me do this? |
Hello Tony, there's no jupytext filter for this. But maybe you could use Then we create a custom template for nbconvert with a file
and finally we call
|
@mwouts Great - thanks... that looks like it'll do the trick... I'll try to do a post on a workflow that includes this to try to explain why I think it might be useful! PS post here: Rescuing Python Module Code From Cluttered Jupyter Notebooks |
I'll soon address this issue. Is everyone OK if I map the R Markdown options to the Jupyter Book ones by default? I also plan to offer an option for those who prefer to map them to the runtool ones. |
Hello @grst , I've updated the mapping between the R Markdown options and the runtools ones. Can you confirm that the mapping below is what you would have expected? jupytext/tests/test_hide_remove_input_outputs_rmarkdown.py Lines 8 to 27 in e519249
Soon I will add the translation between the R Markdown options and the Jupyter Book tags (and that will become the default translation). Would the test below fit your specifications? Do you prefer to map the R Markdown options to
|
By default. And a `use_runtools` option is provided to map them to the runtools options instead. Closes #337
By default. And a `use_runtools` option is provided to map them to the runtools options instead. Closes #337
Sorry the delay. The test LGTM. For the jupyter book tags, I think it doesn't matter too much. |
Thanks Gregor. Sure, I agree. And anyway if later on someone wants to map the Jupyter Book |
Hello @grst, I have just released a new rc ( |
Actually, now I get a parsing error on a file that used to work fine:
|
Just to try to provide some linkage between related issues across several projects, I notice that In terms of workflows and generalising publishing opportunities outside the production of documentation (which has its own set of concerns) I think it's useful if conventions for tagging cells are in place so that the same documents can be published via different workflows. I don't think |
Thanks @grst for reporting this, I'll have a look. |
Gregor, indeed the backward compatibility switch (triggered by 'format_version: 1.1') for the Markdown format was also affecting the R Markdown format... I've fixed that with 17c9d34. |
Thanks for fixing!
I confirm it works as expected now on the current master branch.
…On Sat, 9 Nov 2019 at 11:23, Marc Wouts ***@***.***> wrote:
Closed #337 <#337>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#337?email_source=notifications&email_token=ABVZRV4FQJ6M76YL3ZCKJODQS2FR3A5CNFSM4I2I4V5KYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOUYBSRVY#event-2785224919>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABVZRV7ZQ2CC2EFVIDLSQZLQS2FR3ANCNFSM4I2I4V5A>
.
|
Hi @mwouts,
I am currently working on a pipeline that chains together jupyter/jupytext notebooks into a reproducible workflow. I created two 'render engines', one based on
papermill
and one onknitr
.Ideally, using jupytext, one could use them interchangeably on the same notebook.
I am currently struggling with the cell metadata to control the visibility of cell inputs/outputs. I have seen that you have been experimenting with both papermill and jupyterbook. I also observed that you implemented some conversion of cell metadata for Rmarkdown. Ideally, there would be common conventions between jupytext, jupyterbook, Rmarkdown etc.
First, my observations:
include=FALSE
to hide an entire cell,results='hide'
to hide output andecho=FALSE
to hide input.hide_input
andremove_input
to hide the input,remove_cell
for an entir cell, and to my knowledge no option to hide output only.hide_output
andhide_input
when converting from Rmarkdown.Now, my questions/suggestsions:
hide_output
andhide_input
, or are they supposed to be compatible with another project?include=FALSE
translates currently intohide_output
. I believe it should translate intoremove_cell
or equivalent.results='hide'
is currently not converted. It should translate intohide_output
.Let me know what you think!
Best,
Gregor
The text was updated successfully, but these errors were encountered: