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

Merciful validation #243

Open
ivanov opened this issue Jan 20, 2022 · 1 comment
Open

Merciful validation #243

ivanov opened this issue Jan 20, 2022 · 1 comment

Comments

@ivanov
Copy link
Member

ivanov commented Jan 20, 2022

This is related to #235 but provides for an alternative path. There are instances when users would want to fixup the notebook, so we should provide a way for them to do so.

Right now, if you have a validation error for non-unique cells, you will get a validation error informing you that a cell had a duplicate cell_id, and also the notebook that you passed in will be modified with only the first instance of a non-unique cell. I agree with the approach @Carreau outlines in #235, but want it to be possible to opt-in to fixing the validation errors that are fixable (such as replacing all non-unique cell ids with unique ones). I think it would makes sense to do this via a new repair kwarg that would default to False, and keep with either current behavior, or non-modifying behavior as per #235, but when repair=True we would fix up the errors and do a best effort of massaging the notebook into one that is compliant with a given nbformat version.

@Carreau
Copy link
Member

Carreau commented Jun 8, 2022

Sorry for the late reply, the problem with the kwarg, and the approach of fixing in validate is the following.

notebook = get_notebook()
notebook_backup = deepcopy(notebook)
do_stuff(notebook) # like for example compute signature.
validate(notebook)
assert notebook_backup == notebook

This is an assumption many codebase do, that validate is not mutating notebook, and that validate()/do_stuff() can be reordered. And no keyword are going to fix that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants