keep cell metadata in a copy of a jupyter notebook? - copy

I'm working on a jupyter notebook (from a local installation of jupyterhub) that I want to be able to copy and distribute to my coworkers. Some of them are a little 'code-phobic' so I want to be able to portions of the code from them.
I can use the hide input extension to very prettily hide the code in my own notebook, however when I make a copy the cell meta-data for hide input reverts to "hide_input": false, and the code is all automatically visible.
Is there a way to keep cell meta data in the copying process?
I can find a lot of online discussions/documentation about keeping hide input functionality with nbconvert, however I don't want to convert to html because I still need the users to be able to actually run code.
Is there a way to use nbconvert to make a copy of a notebook and not actually convert it?
Thanks.

I'm confused - because for me cell metadata is preserved when copied. Are you sure you are actually saving the notebook after you have changed the cell metadata?
Regardless, you can use nbconvert to "convert" a notebook into a notebook; use the command:
jupyter nbconvert --to notebook --execute mynotebook.ipynb
From the docs: https://nbconvert.readthedocs.io/en/latest/usage.html#notebook-and-preprocessors

If you use the Toggle selected cell input button or individually edit cell metadata the individual cell hide input status was not preserved. But when I used the Hide codecell inputs to hide the input of all the cells; then it was preserved after copying.

Related

What is Jupyter cell tag in VSCode?

I've googled a bit but everything points to the Jupyter notebook, not vscode and was just wondering if there are any resources available on how to use these cell tags in VSCode. Simply copying a tag in doesnt seem to do anything in my notebook.
So basically 2 questions:
How do you use this tab?
What do cell tags do?

Jupyter in vscode - convert to raw NBCovert or deactivate cell?

I'm used to hitting the R key in jupyter to change it to raw NbConvert type which deactivates it, but I don't see that option in the shortcuts for vscode. Is there a way to change a cell to raw nbconvert in vscode, or some equivalent way of preventing a cell from accidentally being run? raw format is perfect because it's easy to tell
apparently (from what I know) there's no shortcut key to change a cell to raw. However it's possible to change a cell to raw NbConvert from the GUI.
From the picture above, you can see that this Python/raw is shown at the bottom right of a cell. Just simply click on the Python word and choose raw from the pop out selection and boom. You get a raw NbConvert cell. Hope this helps! :)

GitHub is not showing output cells from .ipynb files

I am using VsCode to write my .ipynb codes, and GitHub Desktop to push the files to repositories in GitHub.
When opening the code file in VsCode I can see both input and output cells. Meanwhile after pushing the files to GitHub I can see all input cells and some output cells only when they contain figures or tables, otherwise the output cells are not shown.
For example when the input cell contains (print command) I can see the result printed on VsCode in an output cell, but in Github the output cell will be either empty or does not exist.
Previously I did not face this problem, and I do not recall changing anything in the settings in GitHub, VsCode, GitHub Desktop.
Anyone has an idea what could be the problem ? Thanks alot in advance.
I'll attach some screenshots :
1-1- Input and output in VsCode:
1-2- same input cell in GitHub with no output cell at all!
2-1- Anthore input and output cell at VsCode:
2-2 - Same input cell in GitHub with empty output cell :
I cut a ticket with GitHub for the same issue. They have confirmed it to be a bug with their renderer. You can verify it's the same problem by checking the raw notebook file for an output block. If text is there but not rendered, GitHub say they have a few reports of the problem and are working on a fix.

jupyter notebook display cells horizontal

I have issues on jupyter notebook conversion. It looks fine on jupyter notebook. However if I convert it to html or upload to github, it displays like photo above.
Instead of vertical(scroll up and down), I have to scroll left and right and each cell are really narrowed.
Any suggestion?
Thanks in advance!
This is typical of a library you use emitting invalid HTML. I would suggest opening an issue or contacting the Jupyter mailing list to help you debug this as StackOverflow will not be the right place to have a back and forth.
You should be able to narrow down which library does that by:
- backup your notebook.
- Delete cells one and until notebook looks normal. (tip use nbconvert locally instead of uploading, and use python -m http.server)
- the last cell you delete have a issue.
It may be a bug in nbconvert but I doubt it.

how to make a single slide with markdown and code in ipython notebook?

In this tutorial presentation they use this, but, apparently, they don't show you how to do it.
http://www.damian.oquanta.info/posts/make-your-slides-with-ipython.html
Thanks,
I am sorry, I completely misunderstood your question.
If you mean embedding code which you do not execute, then you can use simple markdown syntax (similar to StackOverflow for example). To include inline code, just but it between backticks:
For example `a[::2]` selects every second element of the list `a`.
If you want to include a code block, either indent the whole block by 4 spaces, or put the block between 3 backticks (the latter also supports syntax highlighting if you specify the language):
a = foo()
b = bar(a)
or
```python
a = foo()
b = foo(a)
```
For more, see this markdown tutorial.
If you want to include executable cells and markdown on the same slide, then you need to put your code and markdown into different cells, and for slide type select slide for the topmost cell, and - for the subsequent cells that you want to have on the same slide. - means "do not start a new slide for this cell".
Old answer (how to convert a notebook to a reveal.js presentation)
You can convert your ipython notebook to a Reveal.js presentation using nbconvert.
First you have to specify the structure of the presentation. For that click on View -> Cell Toolbar -> Slideshow. Then at the top of every cell you can select whether you want it to be a new slide (horizontal direction), a subslide (vertical direction), a fragment (appear on the same slide with a fade-in) and some others.
Once you are set, you can use the nbconvert utility to transform your notebook into a presentation. The basic usage is
jupyter nbconvert example.ipynb --to slides
Then you get a HTML which you can serve up later using some web server.
If you want to show off your slides right away, jupyter provides a shortcut: you can do
jupyter nbconvert example.ipynb --to slides --post serve
Using this jupyter starts a local server after the conversion and opens the presentation in your default browser.
Last, if you want to easily share your presentation online, you can upload the notebook to some online repository (for example to github as a gist), and you can use nbviewer to share it. It will have a box-like icon in the top right corner. If you press it, it will change from notebook mode to presentation mode (I don't understand the box analogy either).
For more info please consult the jupyter documentation.