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

Configurable metadata filter options in .jupytext don't appear to be in effect #543

Closed
rsokl opened this issue Jun 13, 2020 · 4 comments · Fixed by #607
Closed

Configurable metadata filter options in .jupytext don't appear to be in effect #543

rsokl opened this issue Jun 13, 2020 · 4 comments · Fixed by #607
Milestone

Comments

@rsokl
Copy link

rsokl commented Jun 13, 2020

Hello! I'm trying out the new config options and it doesn't seem like things are adding up for me.

My config file contains the following

default_notebook_metadata_filter = "-all"
default_cell_metadata_filter = "-all"

My ipynb file has the following metadata

{
  "kernelspec": {
    "display_name": "Python [conda env:.conda-week1]",
    "language": "python",
    "name": "conda-env-.conda-week1-py"
  },
  "language_info": {
    "codemirror_mode": {
      "name": "ipython",
      "version": 3
    },
    "file_extension": ".py",
    "mimetype": "text/x-python",
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
    "version": "3.8.3"
  },
  "nbsphinx": {
    "execute": "never"
  }
}

When I run

jupytext --to md WorkingWithMic.ipynb

the resulting markdown file has the metadata

---
jupyter:
  jupytext:
    text_representation:
      extension: .md
      format_name: markdown
      format_version: '1.2'
      jupytext_version: 1.5.0
  kernelspec:
    display_name: Python [conda env:.conda-week1]
    language: python
    name: conda-env-.conda-week1-py
---

I double checked that find_jupytext_configuration_file('.') returned the appropriate file. Is there something off with how I am doing things here? I should expect all of the metadata to be absent from the .md file, correct?

I tried introducing some random characters in the config file, and it does cause the toml reader to crash, so it does appear that my config file is being parsed during the conversion.

My OS is Windows and I am running jupytext 1.5.0

@mwouts
Copy link
Owner

mwouts commented Jun 19, 2020

Hello @rsokl , well... in Jupytext 1.5.0, the configuration file is used by jupytext --sync, but not by jupytext --to.

Looking back, the reason for this debatable implementation it that the --sync mode is closer to how Jupytext works in Jupyter, and configs were first used in Jupyter (I am not saying this is a good reason!).

So we have a couple options... can you tell me what you think of them?

  1. we make it clear in the documentation that jupytext --to does not use the config files, and you use jupytext --sync instead
  2. we change the implementation, and default_notebook_metadata_filter = "-all" in the config results in notebook_metadata_filter = "-all" in the notebook when you do jupytext --to if there was no previous filter.
  3. or, more similar to what we do for default_jupytext_formats... maybe jupytext --to should act according to the default value, but not write it to the text file?

@rsokl
Copy link
Author

rsokl commented Jun 22, 2020

Hi @mwouts

To me, it seems like option 2 makes the most sense – it seems intuitive to have my .jupytext file control all transformations created by jupytext. Option 3 is a little hard for me to wrap my head around; specifically it is hard to predict whether or not that would create confusing situations for unwitting users.

@mwouts
Copy link
Owner

mwouts commented Aug 30, 2020

Hi @rsokl , sorry it has been a while since you reported this. I have added a test to make sure that the config file is taken into account, and with the development version the test is green. I'll include this in the upcoming release 1.6.0.

@mwouts
Copy link
Owner

mwouts commented Aug 30, 2020

A release candidate is available here:

pip install jupytext==1.6.0rc0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants