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

Hide input cells of notebooks by default #838

Closed
ciyer opened this issue Mar 17, 2020 · 6 comments · Fixed by #870
Closed

Hide input cells of notebooks by default #838

ciyer opened this issue Mar 17, 2020 · 6 comments · Fixed by #870
Assignees

Comments

@ciyer
Copy link
Contributor

ciyer commented Mar 17, 2020

Motivation

Many notebooks are designed to be viewed by a public that might not care about the code. It should be possible to show notebooks with input cells hidden.

Proposal

All notebooks should have a radio-button-type interaction to select whether the input cells are shown or not. For the default behavior, there are two options:

  • Option 1: Have a setting a for each notebook: show or hide input cells as default
  • Option 2: For notebooks in the "notebooks" folder, show input cells, for notebooks everywhere else, hide input cells

Option 1 is more powerful, but a bit more work to implement, and adds more cognitive load on the user
Option 2 is very easy to implement, but could seem a bit arbitrary unless it is clearly documented and explained.

Context

@rokroskar
Copy link
Member

This is a really good idea - would it be possible to do 1. with defaults set as described in 2.? Also, if for the public, it would be nice to have some mode in which most of the rest of the project can be hidden and just the notebook content displayed.

@ciyer ciyer added this to the sprint-2020-03-02 milestone Mar 23, 2020
@ciyer
Copy link
Contributor Author

ciyer commented Mar 23, 2020

After a little investigation, I realized that this is already possible. Our notebook render looks for notebook and cell metadata to control this.

If the notebook has metadata.hide_input == true, then all inputs will be hidden. If a cell has metadata.inputHidden == true or metadata.hide_input == true, then the cell's input will be hidden. See source

Further, papermill has flag --report-mode. When this is used, it will set the cell metadata field metadata.jupyter.source_hidden: true. However, our renderer does not recognize this. We could do one of the following:

  1. Fork the notebook-render project to support this behavior
  2. Scan all cells and, if we see metadata.jupyter.source_hidden == true, also set metadata.hide_input: = true, which is understood by our renderer.

My vote is for 2.

@lorenzo-cavazzi
Copy link
Member

+1 for solution number 2

@rokroskar
Copy link
Member

Can we make the hiding on by default but provide an option to un-hide? Often it is useful and desirable to see the code.

@ciyer
Copy link
Contributor Author

ciyer commented Mar 24, 2020

We could, but I want to keep the UI and possible interactions as simple as possible. I do not want to have the ability to show/hide each individual cell. I think this should be a setting for the whole notebook.

  1. Respect what is in the notebook metadata (user may need to look at file or launch environment to view code)
  2. Allow user to switch between shown/hidden code. If any cells are marked hide_input, then the switch defaults tohide, otherwise, switch defaults to show

What I like about 1 is that it keeps the UI clean and lets the notebook author have full control over this behavior. I do understand the utility of 2., but I wonder what % of our users will benefit from this.

@rokroskar
Copy link
Member

I fully agree that the default should be up to the author. But allowing the user to override it if they want seems not that far-fetched (on the notebook-level, not cell-level). Otherwise if I want to quickly copy-paste a snippet I have to 1. find the notebook, 2. realize I can't see the code, 3. clone the project or open the notebook in gitlab. 2. & 3. seem unnecessary.

ciyer pushed a commit that referenced this issue Mar 25, 2020
ciyer pushed a commit that referenced this issue Mar 25, 2020
ciyer pushed a commit that referenced this issue Mar 25, 2020
@ciyer ciyer self-assigned this Mar 26, 2020
ciyer pushed a commit that referenced this issue Apr 3, 2020
ciyer pushed a commit that referenced this issue Apr 3, 2020
ciyer pushed a commit that referenced this issue Apr 15, 2020
Show the code visibility switch as a header.

Fix #838
ciyer pushed a commit that referenced this issue Apr 15, 2020
Use outline buttons and semi-bold for the label.

Fix #838
ciyer pushed a commit that referenced this issue Apr 17, 2020
Show the code visibility switch as a header.

Fix #838
ciyer pushed a commit that referenced this issue Apr 17, 2020
Use outline buttons and semi-bold for the label.

Fix #838
ciyer pushed a commit that referenced this issue Apr 17, 2020
Extract the code visibility form as a separate component.

Fix #838
ciyer pushed a commit that referenced this issue Apr 17, 2020
Provide a switch for changing code visibility.

Fix #838
ciyer pushed a commit that referenced this issue Apr 17, 2020
Provide a switch for changing code visibility.

Fix #838
ciyer pushed a commit that referenced this issue Apr 21, 2020
Provide a switch for changing code visibility.

Fix #838
ciyer pushed a commit that referenced this issue Apr 21, 2020
Provide a switch for changing code visibility.

Fix #838
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

Successfully merging a pull request may close this issue.

3 participants