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

Stripping other metadata (execute time) #34

Closed
jdriordan opened this issue Aug 15, 2016 · 6 comments · Fixed by #39
Closed

Stripping other metadata (execute time) #34

jdriordan opened this issue Aug 15, 2016 · 6 comments · Fixed by #39

Comments

@jdriordan
Copy link
Contributor

I'm using the (hugely useful) Execute Time nbextension, which produces cell metadata like this:

{
 "cell_type": "code",
 "execution_count": null,
 "metadata": {
  "ExecuteTime": {
   "end_time": "2016-08-15T11:49:40.736068",
   "start_time": "2016-08-15T11:49:40.145965"
  },
  "code_folding": [],
  "collapsed": false
 },
 "outputs": [],
 "source": []
}

But naturally I end up with a load of changes seen by git after running nbstripout because of re-running the cells and updating the ExecuteTime field. Would you accept a pull request explicitly stripping this out, or alternatively one which strips all but whitelisted metadata entries?

@kynan
Copy link
Owner

kynan commented Aug 18, 2016

I suppose stripping all but whitelisted metadata would make sense. How do you envision configuring that whitelist?

@kynan
Copy link
Owner

kynan commented Sep 19, 2016

@jdriordan, are you still planning to submit a pr for this?

@jdriordan
Copy link
Contributor Author

Sorry for the delay. One way to do a whitelist would be to start with those given in the format spec, i.e.

  • kernelspec
  • collapsed
  • autoscroll
  • deletable
  • format
  • name
  • tags
  • isolated

along with those used by nbstripout,

  • init_cell
  • keep_output
  • scrolled

People seem to be using metadata for other various things in the wild (author/description etc.) and it's also used by some extensions (which could register themselves on the whitelist, in theory).

Having looked at all this I've managed to convince myself a blacklist is a more sensible option (since other metadata doesn't change in a useless way like this does. So I've ended up making a really simple change that just strips this one field (but could trivially do others too).

PR submitted.

@kynan kynan added this to the 0.2.9 milestone Sep 27, 2016
@kynan kynan closed this as completed in #39 Sep 27, 2016
@kynan
Copy link
Owner

kynan commented Sep 27, 2016

I agree with your rationale about blacklisting rather than whitelisting. PR merged!

@michaelaye
Copy link
Contributor

time to release maybe? ;)

@kynan
Copy link
Owner

kynan commented Feb 23, 2017

@michaelaye This is actually already released in 0.2.9

ooiM added a commit to ooiM/nbstripout that referenced this issue Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants