-
Notifications
You must be signed in to change notification settings - Fork 83
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
add config to raise error when (any) notebook execution fails #248
Comments
Thanks for bringing this up. I'm not quite sure the right path forward here, since the way that Sphinx generally handles this is the I wonder if you could suppress some "expected warnings" using something like either or these:
Otherwise, I guess we could special-case myst-nb execution even if |
With the execution data now captured in: https://myst-nb.readthedocs.io/en/latest/use/execute.html#execution-statistics, we could add a configuration and |
I'm going to move this to myst-nb then, as I think we can do that there 😄 |
Thanks for opening your first issue here! Engagement like this is essential for open source projects! 🤗 |
I'd just like to second this feature request. We have a very similar use-case where we're relying on sphinx+myst-nb to execute the notebooks in a CI system, and would like the CI to fail if notebook execution fails. I too initially tried the I've tried several workarounds, including the two listed above (AFAICT these only work for nitpicky mode and built-in sphinx warnings, respectively) and adding |
We're exploring using myst-nb in the JAX project (see jax-ml/jax#5426), and this issue is a hard blocker: we need failed notebook executions to trigger a CI failure, otherwise we risk publishing broken code & outputs to the docs. Like other users, in our case the Please let me know if you have any other suggestions for surfacing notebook execution errors to CI - thanks! |
Thanks for the feedback, this definitely in the plans. |
Thanks! |
I started working on this in #296. Feedback appreciated! |
In the meantime, I've found one (quite brittle) workaround: monkeypatch the logger used in from myst_nb import execution
class _FakeLogger:
def __init__(self, logger):
self._logger = logger
def verbose(self, *args, **kwargs):
return self._logger.verbose(*args, **kwargs)
def info(self, *args, **kwargs):
return self._logger.info(*args, **kwargs)
def error(self, *args, **kwargs):
if str(args[0]).lower().startswith("execution failed"):
raise ValueError(args[0])
return self._logger.error(*args, **kwargs)
execution.LOGGER = _FakeLogger(execution.LOGGER) It's not pretty, but it gets the job done 😁 |
Is your feature request related to a problem? Please describe.
When I try to build my book using Github actions, there is no way to specifically cause the build to return an error when a notebook fails to execute. The -W flag would achieve this, but it also would error out for other warnings (e.g. those about heading levels) that are not fatal.
Describe the solution you'd like
Either add a flag that causes
jb build
to raise an error when any of the notebooks fail to properly execute, or (preferably) change the default behavior so that the build fails whenever a notebook fails to execute. The latter is what I would have expected.The text was updated successfully, but these errors were encountered: