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

Convert code in Frozen Cell as comments in .py #101

Closed
erdnaavlis opened this issue Oct 16, 2018 · 4 comments
Closed

Convert code in Frozen Cell as comments in .py #101

erdnaavlis opened this issue Oct 16, 2018 · 4 comments

Comments

@erdnaavlis
Copy link
Contributor

I'm currently test-driving jupytext and I like its potential! Thanks for this neat tool!

I like to use the Freeze Cells extension in my notebooks.
Is it possible to configure jupytext to convert the code in frozen cells as comments in the associated .py file?

@mwouts
Copy link
Owner

mwouts commented Oct 16, 2018

Hello Andre, thanks for suggesting. There is no such option currently. Yet it would be easy to implement support for frozen cells. Would you like to submit a sample notebook with just one frozen cell ? Please send it either by email, or using a PR (put the notebook in tests/notebooks). Thanks!

@erdnaavlis
Copy link
Contributor Author

Hi @mwouts ,

Thanks for your reply.

Created a PR as you requested containing the notebook and the generated .py with a Frozen Cell.

You will notice in the .py the "run_control": {"frozen": true} part:

# + {"editable": false, "deletable": false, "run_control": {"frozen": true}}
# This is an frozen cell
print("I'm frozen so Im not executed :(")
# -

In such cases, I would like that the code (the print()) to be commented in the .py.

Offtopic:
Since we at it, if you notice the regular cell that I also included in the notebook:

# + {"ExecuteTime": {"start_time": "2018-10-17T10:31:56.157308Z", "end_time": "2018-10-17T10:31:56.160823Z"}}
# This is an unfrozen cell. Works as usual.
print("I'm a regular cell so I run and print!")

It has a ExecuteTime metadata. This is a metadata used by another notebook extension to track when a cell was executed and how long it took.

Would it be possible for the jupytext user to specify which metadata to keep track of and which to ignore?
In my case I don't need this info in the .py and, in fact, I don't want it because it adds noise to git diff...
But maybe other users would like to keep it in the scripts.

Please let me know your thoughts.

@mwouts
Copy link
Owner

mwouts commented Oct 17, 2018

Thanks @andrethrill . The PR will be very helpful to implement and test your initial request - I will try to do that soon.

As for your comment on metadata, I like very much the idea of filtering cell metadata. Would you like to open another issue? As a start we could skip the 'ExecuteTime' cell metadata for everyone (there are already a few cell metadata that jupytext does not include, cf. https://github.com/mwouts/jupytext/blob/master/jupytext/cell_metadata.py#L32). Unless you think it is important that for every notebook, one can tell which cell metadata to include/exclude? Please let me know your preference.

mwouts added a commit to erdnaavlis/jupytext that referenced this issue Oct 18, 2018
mwouts added a commit to erdnaavlis/jupytext that referenced this issue Oct 18, 2018
mwouts added a commit to erdnaavlis/jupytext that referenced this issue Oct 18, 2018
mwouts added a commit to erdnaavlis/jupytext that referenced this issue Oct 18, 2018
mwouts added a commit to erdnaavlis/jupytext that referenced this issue Oct 18, 2018
mwouts added a commit to erdnaavlis/jupytext that referenced this issue Oct 18, 2018
mwouts added a commit to erdnaavlis/jupytext that referenced this issue Oct 18, 2018
@mwouts mwouts mentioned this issue Oct 18, 2018
mwouts added a commit that referenced this issue Oct 18, 2018
mwouts added a commit that referenced this issue Oct 18, 2018
mwouts added a commit that referenced this issue Oct 18, 2018
@mwouts
Copy link
Owner

mwouts commented Oct 18, 2018

Available in version 0.8.3:

  • support for frozen cells
  • ExecuteTime metadata excluded from text representations.

Thanks @andrethrill for suggesting these two improvements. And welcome as a contributor!

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