GithubHelp home page GithubHelp logo

Comments (14)

kynan avatar kynan commented on August 20, 2024

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.

rsvp avatar rsvp commented on August 20, 2024

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.

jpeacock29 avatar jpeacock29 commented on August 20, 2024

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.

rsvp avatar rsvp commented on August 20, 2024

@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.

kynan avatar kynan commented on August 20, 2024

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.

jpeacock29 avatar jpeacock29 commented on August 20, 2024

What would the regex flag be matched against? Every key in the ipynb?

from nbstripout.

rsvp avatar rsvp commented on August 20, 2024

@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.

kynan avatar kynan commented on August 20, 2024

Feel free to have a go at this, I'm not sure when I might find time to work on it myself.

from nbstripout.

kynan avatar kynan commented on August 20, 2024

One of you interested in working on this @rsvp @jpeacock29 ?

from nbstripout.

kynan avatar kynan commented on August 20, 2024

Are you still interested in this @rsvp @jpeacock29 ?

from nbstripout.

rsvp avatar rsvp commented on August 20, 2024

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.

kynan avatar kynan commented on August 20, 2024

@rsvp do you still have this use case?

from nbstripout.

kynan avatar kynan commented on August 20, 2024

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.

kynan avatar kynan commented on August 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.