-
Notifications
You must be signed in to change notification settings - Fork 96
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
Creating a branch with notebook outputs stripped #71
Comments
By its nature, a git filter can only act on the commit about to be made. It's not designed to "spawn" another commit in a different branch (I suppose it could be made to do that with some trickery, but I rather wouldn't like to implement such a "hack" in nbstripout). You can however emulate the behaviour you want by installing nbstripout only in a Create an orphan release branch and install nbstripout in that branch only:
You can then cherry-pick notebook commits as follows (you will probably have to do this in order to avoid merge conflicts, unless each commit is entirely self contained):
From my quick test those 2 stages are necessary for the filter to kick in i.e. if you just do a plain cherry pick the filter is not applied. Hope this helps! |
Not easily: as mentioned, npstripout uses a git clean/smudge filter and operates purely on the file level. No cells are ever executed. You would need to look at a pre-commit hook, however I expect that's not too easy to set up: you'd need to start a notebook server, run the notebook and deal with failures. This would also take very long. If you only want to verify the output is populated, that's easier to do (and you could potentially reuse some of |
@kynan Thanks for that - will give it a try. For generating newly run notebooks, could that be done elsewhere in a Github managed repository, eg using CI hooks to run something to create the new notebooks? (Apols - this is going off-topic for |
There's another option I didn't think of earlier: you can use the By creating "new" notebooks, do you mean creating stripped versions from "full" versions? Or the other way round? You presumably could use CI hooks to automate either variant, but I don't have anything to suggest since I haven't tried anything of that sort. If you haven't come across https://mybinder.org before, I wonder if that could be a starting point. |
@psychemedia have you found a suitable workflow for your needs? |
@kynan I've actually moved to a workflow around jupytext now that uses a text based representation for notebooks (no cell outputs). Reflecting back, I think that a Here's another example of that approach: rewriting the contents of a branch as text files using
|
Is there a way of using
nbstripout
that would allow me to create a branch of cleaned notebooks from a branch that contains notebooks with populated output cells (eg ones with output cells populated that can be used for testing withnbval
).I'm thinking of a private github repo workflow where there is a testing-master branch containing executed notebooks with populated test output cells that begets a release branch containing notebooks that can be zipped and distributed to students.
Presumably, a variant of
nbstripout
could also be used to add a git filter that would automatically run a notebook when commiting it to a repository to ensure that all its output cells are populated?The text was updated successfully, but these errors were encountered: