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

Better handling of cells that contain string 'nbdev_export(' #1490

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ozpau
Copy link

@ozpau ozpau commented Feb 5, 2025

Currently, if you just happen to include string nbdev_export( in your code cell, the whole cell will be silently ignored by nbdev_prepare, nbdev_test, nbdev_proc_nbs and nbdev_preview. If this cell happens to contain code that is exported or rendered in docs, it would result in the corresponding command failing with hard to decipher error.

I have removed the corresponding check from the nbdev code. I am not sure we need it, but I can make a version of this pull request that handles that more gracefully by injecting monkey patching code into notebooks, something like this:

k.run_cell('import nbdev\ndef noop(*args, **kw): pass\nnbdev.nbdev_export = noop')

I imagine the check was there to prevent infinite loops of nbdev_prepare calling itself, but this doesn't happen because the check is for nbdev_export and not for nbdev_prepare.

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

Successfully merging this pull request may close these issues.

1 participant