mwouts / jupytext

Jupyter Notebooks as Markdown Documents, Julia, Python or R scripts

Home Page:https://jupytext.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

a way for a git repo to provide its own settings

parmentelat opened this issue · comments

EDIT

I am rephrasing parts of this post in the hope to bring more attention

<tl;dr>
I would need a way for a git repo to provide its own jupytext preferences
much like the jupytext repo itself has, for example, jupyterlab/.yarnrc.yml for its yarn config

the longer version

my practical use case is the following
we are teachers who write our course notebooks in a git repo
so as to avoid the noise related to versions, we have adopted standardized jupytext settings like e.g.

$ cat $HOME/.config/jupytext/jupytext.toml
cell_metadata_filter = """all,-hidden,-heading_collapsed,-run_control,-trusted"""
notebook_metadata_filter = """all, -jupytext.text_representation.jupytext_version, -jupytext.text_representation.format_version,-language_info.version, -language_info.codemirror_mode.version, -language_info.codemirror_mode,-language_info.file_extension, -language_info.mimetype, -toc, -rise, -version"""

currently this configuration is located in the homedir; and so each teacher has to copy it
plus, several projects might use different settings
so in this respect the location of the jupytext config file is suboptimal

thanks to the doc here
https://jupytext.readthedocs.io/en/latest/config.html#possible-locations-for-the-jupytext-configuration-files
I have determined that the config file in my case is searched in these places

In [1]: from jupytext.config import global_jupytext_configuration_directories
   ...: list(global_jupytext_configuration_directories())
Out[1]:
['<HOME>/.config/jupytext',
 '<HOME>/.config',
 '/<HOME>/jupytext',
 '/<HOME>',
 '/usr/local/share/jupytext',
 '/usr/local/share/',
 '/usr/share/jupytext',
 '/usr/share/']

I'd like a way to ship this configuration together with the git repo somehow, so that contributions are following this same scheme, without the need to mess with their own preferences, which may differ, and vary according to the context

I'd like to start a discussion to see if others would see some value in this direction

one rough way to achieve this would be to search in the current directory, and up to the root until a config is found
I'm sure there are other alternatives (e.g. pyproject.toml ?) but I am not familiar enough with these to elaborate much

now, there's also the question as to how to combine config files if multiple are found
(which to an extent is orthogonal to this proposal)
I take it right now it's first one wins all, which imho is good enough, but your mileage may vary..

thoughts welcome !

Hi @parmentelat , sorry I missed this one. In addition to the global configuration directories, you can place the jupytext.toml file in any directory that Jupyter can read. So you can probably save jupytext.toml at the root of the repository, assuming that you start Jupyter Lab there or in a parent directory.

ok, thanks for the clarification, it is indeed mentioned in the documentation but somehow I had missed that at first