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

Proposal: separate template and config #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

abravalheri
Copy link
Contributor

The existence of a notebook template is a very nice thing, since we can define common blocks of code that we always rely on...

However the current implementation have a huge chunk right in the beginning of the file with all the boilerplate code (e.g. configuring jupyter extensions and the way things are displayed in the notebook).

I wonder if using a single file to centralise all this "boilerplate jupyter configuration" makes sense... The idea is not to replace the template, but rather get unimportant things (like configuring how many columns pandas will display), out of the way.

This way a person can have a single line on top of the file:

%run ./config.ipynb

and start writing some text for good'old literal programming, and the readers will not be distracted by the usual chores... (that is what I find myself doing these days: my template is just %run ./config.ipynb...)

This approach also allow users to change things in one place (e.g. font size for the graphs) and have it automatically changing in all the notebooks, which can be quite neat.

The existence of a notebook template is a very nice thing, since we can
define common blocks of code that we always rely on...

However the current implementation have a huge chunk right in the
beginning of the file with all the boilerplate code (e.g. configuring
jupyter extensions and the way things are displayed in the notebook).

I wonder if using a single file to centralise all this "boilerplate
jupyter configuration" makes sense... The idea is not to replace the
template, but rather get unimportant things (like configuring how many
columns pandas will display), out of the way.

This way a person can have a single line on top of the file:

```ipynb
%run ./config.ipynb
```

and start writing some text for good'old literal programming, and the
readers will not be distracted by the usual chores...

This approach also allow users to change things in one place (e.g.
font size for the graphs) and have it automatically changing in all the
notebooks, which can be quite neat.
@FlorianWilhelm
Copy link
Member

Thanks for this PR @abravalheri. I am a bit hesitant since I often change the defaults on a per notebook basis. For instance, I decrease the default plot size if I have many plots in a notebook. The same goes for the default settings of Pandas regarding the display options, seaborn and other things. Having a global config for all my notebooks might have unintended effects, i.e. I might be happy with one notebook by tweaking the settings in the global config while an older notebook suddenly starts looking strange when I rerun it later.

So from my point of view and workstyle, I would rather not use a global config notebook. How about we open up a discussion about it, maybe we get some feedback from the users of this extension?

This might be also related to the usage of JupyText which splits notebooks up a content and visualization part where only the content part goes into Git. I am not experienced enough with it and just wanted to point it out.

@abravalheri
Copy link
Contributor Author

No problems @FlorianWilhelm, I am just brainstorming here :) -- in the end of the day, it is very easy for the users to adapt the default template with their own conventions, being them configuration per notebook or a global config file.

I stumbled upon jupytext when I was writing this PR, because editing the .ipynb templates was a bit painful (in the end of the day I renamed the files to have a .ipynb extension, changed them in jupyterlab and them renamed back to .template), but did not explored them a lot... It might make sense to use a more conventional literate programming format as an intermediate though... it does improve the experience with Pull Requests or diffing in general... or is Github already supporting diffs for .ipynb files?

Looking on the internet, I found: https://dev.to/canas/get-jupyter-notebook-diff-with-github-actions-4b90, which does not seem that bad, but I supposing diffing markdown is much easier.

I am completely in favour of a community discussion... what would be the best way of doing that? Github discussions? Twitter?

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 this pull request may close these issues.

2 participants