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

Using jupytext and jupyterlab-execute-time #656

Closed
marcglobality opened this issue Oct 12, 2020 · 8 comments
Closed

Using jupytext and jupyterlab-execute-time #656

marcglobality opened this issue Oct 12, 2020 · 8 comments
Milestone

Comments

@marcglobality
Copy link

Cross-posting as not sure where the problem can be fixed: deshaw/jupyterlab-execute-time#15

Mainly, I would like Jupytext to ignore the execution stuff for the .py file (and in general for any extension, or at least make it configurable)

@marcglobality
Copy link
Author

finally found the answer to this

The solution is to add a jupytext.toml to one of the places where jupytext looks for a config file. In my case:

  • Create the file in ~/.config/jupytext
  • Add the line default_cell_metadata_filter = "-execution"

It works for new files, not sure it will work for old ones

@mwouts
Copy link
Owner

mwouts commented Oct 12, 2020

Glad you found it! Thanks @marcglobality for sharing the answer.

I was having a look at this and at the moment it's not easy to find the default value for the cell filter. I'd like to

  • improve the documentation and document explicitly the default value
  • maybe include execution in the list of cell metadata that are excluded by default.

FYI the default values are found, at the moment, in this file:

_JUPYTEXT_CELL_METADATA = [
# Pre-jupytext metadata
"skipline",
"noskipline",
# Jupytext metadata
"cell_marker",
"lines_to_next_cell",
"lines_to_end_of_cell_marker",
]
_IGNORE_CELL_METADATA = ",".join(
"-{}".format(name)
for name in [
# Frequent cell metadata that should not enter the text representation
# (these metadata are preserved in the paired Jupyter notebook).
"autoscroll",
"collapsed",
"scrolled",
"trusted",
"ExecuteTime",
]
+ _JUPYTEXT_CELL_METADATA
)

Maybe I'll move together with the default notebook metadata filter in a default_metadata_filter.py and improve the corresponding part of the documentation. You don't mind if I reopen this issue to keep track of this?

@marcglobality
Copy link
Author

marcglobality commented Oct 12, 2020

sure, btw it seems like even having that setting, if there are execution headers in the .py, the setting gets from -execution to execution. Is this possible or I'm doing something wrong? can this be fixed?

Otherwise I'll have to fix all notebooks by hand :(

@marcglobality marcglobality reopened this Oct 12, 2020
@mwouts
Copy link
Owner

mwouts commented Oct 12, 2020

btw it seems like even having that setting, if there are execution headers in the .py, the setting gets from -execution to execution. Is this possible or I'm doing something wrong? can this be fixed?

Maybe there is a bug? I'll have a look soon

Otherwise I'll have to fix all notebooks by hand :(

If you're in a hurry that may be the way to go. Rather than 'by hand', I suggest you use jupytext --update-metadata, with something like

jupytext --update-metadata '{"jupytext": {"cell_metadata_filter": "-execution"}}' *.py

@marcglobality
Copy link
Author

nice! the latter worked great. thank you so much

@mwouts
Copy link
Owner

mwouts commented Nov 8, 2020

I am trying to wrap things up for 1.7.0. With #666 we have added execution to the list of cell metadata that are filtered by default, so I think we're done with this issue... Hopefully the new version will ship soon.

@mwouts mwouts closed this as completed Nov 8, 2020
@marcglobality
Copy link
Author

that's amazing! thanks

@mwouts
Copy link
Owner

mwouts commented Nov 11, 2020

Thank you! And, BTW, a release candidate is available at https://pypi.org/project/jupytext/1.7.0rc1/. If everything goes well the new version could ship by the end of the week.

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

No branches or pull requests

2 participants