Comments (14)
Interesting, that sounds like a useful option. How do you see the "UI" of this option?
Suppose this could even be easily generalized to support any data type to either keep or strip out.
from nbstripout.
As an example, how about along these lines?
$ nbstripout --only=images [notebook(s)]
# where images is just an alias for *.png, *.jpg, etc.
$ nbstripout --only='tmp-*.png' [notebook(s)]
# _wildcard support_, say, for inconsequential images labeled as such by user.
from nbstripout.
I thought about this as I was implementing --keep-count
and --keep-output
and considered an options structure:
--keep-count, -c
--keep-output, -o
--keep-text-output, -t
--keep-image-output, -i
--keep-metadata, -m
Thus nbstripout -o
would be equivalent to nbstripout -ti
. Stripping only images would use nbstripout -ctm
. For more fine-grained control at the cell level, keep_output
-type metadata would suffice. That said, this doesn't scale well as maybe there are more output types we'd consider in the future. (Widgets?)
from nbstripout.
@jpeacock29 Re: more output types. Consider a flag like --regex, -r
where a user can implement their custom stripout by giving a regular expression.
This is what I did with sed
-- then understood that an edited notebook
must leave in a trusted state. Going from regex to images would
then be a one-liner.
from nbstripout.
Sounds quite sensible! Let's start with images since this seems to be the most important case.
One of you happy to have a go at this @rsvp @jpeacock29 ?
from nbstripout.
What would the regex flag be matched against? Every key in the ipynb?
from nbstripout.
@jpeacock29 here's a mock example for PNG images: $ nbstripout --regex='png": "i'
That should get rid of the super long lines encoding PNG images for now.
I question the permanence of that regular expression since it is subject
to the formatting whims upstream. Historically, both "image/png":
and "png":
have been used as keys, so my example would fortunately
work for both cases.
But --regex would be a handy tool in any case.
from nbstripout.
Feel free to have a go at this, I'm not sure when I might find time to work on it myself.
from nbstripout.
One of you interested in working on this @rsvp @jpeacock29 ?
from nbstripout.
Are you still interested in this @rsvp @jpeacock29 ?
from nbstripout.
hi @kynan my spare cycles are going to refactoring https://git.io/fecon235
so realistically maybe later this year.
Interestingly, one of the reasons leading to the spin-off of the source code
to another repository https://git.io/fecon236 was to leave behind all
the archival bulky images preserved in the .git for notebooks.
So this issue is still pertinent.
from nbstripout.
@rsvp do you still have this use case?
from nbstripout.
There's an in flight pull request (#135) that's somewhat related: only strip outputs that are larger than a certain size. Would that fit the bill?
from nbstripout.
Given #135 has been released in nbstripout 0.5.0 and is arguably even more flexible than what's requested here I'll close this as fixed.
from nbstripout.
Related Issues (20)
- Should be agnosting on trailing blank lines HOT 9
- [Feature Request] Process Folders (Batch / Bulk) HOT 1
- Doesn't strip out pycharm metadata HOT 9
- New release HOT 2
- Replace cram with prysk HOT 2
- Read config from `setup.cfg` HOT 1
- Option to error on cell outputs exceeding `--max-size` HOT 4
- It is recommended to remove pytest-runnner from setup_requires in setup.py HOT 4
- Strip output_type=stderr only, with keep_output? HOT 4
- Possible nbstripout-fast integration HOT 6
- Prevent committing notebooks with errors in cell outputs HOT 6
- Specifying Python executable path in `nbstripout --install`
- 'nbstripout' is not recognized as an internal or external command, operable program or batch file. HOT 2
- Not compatible with `pre-commit-hooks/pretty-format-json` hook HOT 4
- `git config filter.nbstripout.extrakeys ` support for `attachments`? HOT 4
- Support setting defaults for command line arguments via git config
- No valid notebook detected HOT 4
- required = true by default or make doc more explicit about it HOT 5
- Support git-filter-repo HOT 2
- Any examples for --keep-id option? HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nbstripout.