0

I have a Jupyter notebook that I'm using for data analysis, everything is working exactly as I expect as far as the actual analysis part. I'm trying to get my output to a simple report on the analysis, without showing the code that I used to generate the results / maps. I've tried adding a "hide-input" tag to the code block per https://jupyterbook.org/en/stable/interactive/hiding.html, but the code block is still being rendered as if the tag isn't there.

The metadata on the code block is:

{
  "trusted": true,
  "tags": [
    "hide-input"
  ]
}

I don't care as much about the display inside the Jupyter notebook, but when I render a PDF, I don't want the code input block showing, since it will only serve to confuse my audience (said audience has no experience with or even knowledge of Python and uses computers only to check email).

John
  • 727
  • 5
  • 15
  • You are pointing to documentation for JupyterBook yet everything else you discuss is referencing Jupyter Notebook? What and how are you actually using things? I think you want to make the notebook and then run in the terminal alongside the notebook, `jupyter nbconvert --to pdf--no-input Example.ipynb`. See my comment [here](https://stackoverflow.com/questions/76217599/how-to-obtain-a-shrink-wrapped-jupyter-document/76220558#comment134410287_76217599) and links therein. The more modern options are covered in my answer there & includes JupterBook but you have to run commands to render the book. – Wayne May 14 '23 at 20:29
  • I am running Jupyter Book. In interactive mode, I run my entire notebook, I am prompted for a datafile, and the notebook generates data summaries and map images from it. I want all of that output and none of the input to be in a PDF. When I run the `jupyter nbconvert` command, it does not prompt me, there is no data analysis, and the PDF is effective blank. When I export from the interactive window, the code shows up in the PDF. Neither is what I want. – John May 15 '23 at 11:49
  • Okay, except for linking to documentation, I hope you can see how your first sentence in your comment was not clear in your original post. The title and the categories in now way make that clear. And I can understand now that you cannot execute your notebook as is from the command line using `jupyter nbconvert` because of the way you designed things. That was also not made clear in your original post. There are ways to parameterize a notebook so that you can execute it from a command. However, understandably you are close to having this working and not looking to redesign. Addressing your .... – Wayne May 15 '23 at 15:24
  • code block: `"trusted": true,` is shown as part of your metadata for a cell but I thought the trusted setting is for an entire notebook? (Maybe though different for Jupyter Book, which I am less familiar with than notebooks?) Are you viewing the HTML of the Jupyter Book made from your notebook? I would expect that would add a toggle according to [the documentation](https://jupyterbook.org/en/stable/interactive/hiding.html#removing-code-cell-content): "In the above examples, we are only hiding parts of the cell, with the option that readers can reveal them if they wish. ... – Wayne May 15 '23 at 15:28
  • However, if you’d like to completely remove the respective parts, so that their contents do not make it into the book’s HTML...". From that and what follows it makes me think you aren't using the correct tags, and that you want `remove-input`. I still don't know enough about Jupyter Book to know for sure if that is relayed to the PDF producing step. I suspect it is; however, definitely start with examining the HTML produced before you move onto trying the PDF. – Wayne May 15 '23 at 15:30
  • These two issues (one being a duplicate of a still open one!), [here](https://github.com/executablebooks/jupyter-book/issues/1080) and [here](https://github.com/executablebooks/jupyter-book/issues/619#issue-622906990), have me questioning if what you expect to happen is currently supported in JupyterBook. ... Earlier, I had a typo in my first reply today. A sentence in there should read, "The title and the categories in **no** way make that clear." The former typo word is in bold. – Wayne May 15 '23 at 15:37
  • I can understand easily how anything I say about Jupyter is unclear - I'm very new to it, and honestly I'm only using it because it's proven impossible to get the rendered maps I want without it. I'm completely open to redesigning to make things work better, I simply have no idea where to begin changing anything. – John May 15 '23 at 16:15
  • Oh, your workflow doesn't sound too complex then and you'll be controlling it? So one idea is to run a notebook where you specify the content for the notebook that will end up making the PDF, and that "set-up/organizing" notebook walks through that set-up and actually runs code to programmatically produce a resulting notebook with the content you need. That "set-up/organizing" notebook also executes that produced notebook with `jupyter nbconvert` settings that will run the notebook but leave out the input. Email is in my Github profile, linked from SO profile, for help in fleshing that out. – Wayne May 15 '23 at 17:57
  • I'm unsure why my suggestions to use `jupyter nbconvert` with `--no-input` were unsuccessful [as noted in the comment above](https://stackoverflow.com/questions/76248901/jupyter-rendering-code-even-with-hide-input-tag#comment134470057_76248901)? **That worked for me to make a PDF from the notebook with no input cells shown.** The folium map issue is a separate thing. There was no mention of that in the OP and only 'rendered maps' mentioned yesterday. I've been trying to assist more offline and that was how I came to learn that what is posted about directly was handled by my very first comment. – Wayne May 17 '23 at 16:56

0 Answers0