kynan / nbstripout

strip output from Jupyter and IPython notebooks
Other
1.19k stars 95 forks source link

please add -r flag #127

Open AndrewLouw opened 4 years ago

AndrewLouw commented 4 years ago

It'd be a nice feature to clear outputs recursively in a folder instead of listing all the files when doing this manually Thanks

kynan commented 4 years ago

You can the really easily by just recursively finding all the files you want and pass them to nbstripout:

find . -name *.ipynb -exec nbstripout {} +

I'd prefer to leave functionality for selecting input out of nbstripout.

kynan commented 3 years ago

@AndrewLouw Is that sufficient for your use case? Can we close this?

AndrewLouw commented 3 years ago

I mean, it works, but I'd still recommend a -r flag to have it built in. There are lots of people out there that don't feel comfortable chaining command line programs together and I don't imagine it'd be a hard feature to add. But it's your project and if you'd rather keep it as a one in one out tool then that's fine with me.

kynan commented 3 years ago

nbstripout is not a one-in-one-out tool: you can already specify any number of notebooks on the command line.

Adding a flag for searching directories recursively may sound simple, but it opens up a whole host of other issues nbstripout may need to deal with: what if the next persona wants to exclude certain subdirectories or certain file patterns? I don't want to re-implement functionality for which there are better tools (and find is a much better tool to find files in a particular directory).

If you (or someone else) feels strongly about this feature and wants to implement it I'll happily accept a PR.

For now I feel there are good enough workarounds to make this not a high priority feature. I'll add it to the backlog.

WolfEYc commented 2 months ago

bump

kynan commented 2 months ago

@WolfEYc My position on this has not changed :) I don't consider recursively walking a directory tree nbstripout's responsibility. See previous comments for workarounds. I'm not going to implement this.

AndrewLouw commented 2 months ago

I was young and naive when I asked for this feature, kynan is right. Using find is the most appropriate way to achieve this. But perhaps an example in the docs would help people out?

kynan commented 2 months ago

That is a fair request 👍🏽 Done in c6c1067.