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

Skip failing notebooks #44

Merged
merged 33 commits into from
May 20, 2024
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
e528e97
Initial sequential implementation of notebook failure detection
Yoshanuikabundi Mar 22, 2024
1eecb6f
More verbose summary
Yoshanuikabundi Mar 22, 2024
0878ff7
Merge branch 'main' into skip-failing-notebooks
Yoshanuikabundi Mar 25, 2024
4ae10b0
Keep log of failed notebooks
Yoshanuikabundi Apr 4, 2024
adf7c50
Make failure log configurable
Yoshanuikabundi Apr 4, 2024
a27987d
Report failed notebooks in PR
Yoshanuikabundi Apr 4, 2024
7dc329f
Improve formatting and fix log filename
Yoshanuikabundi Apr 4, 2024
b55d75b
Fixes
Yoshanuikabundi Apr 4, 2024
3119734
str -> path
Yoshanuikabundi Apr 4, 2024
bb7c666
Keep failing notebooks env on one line
Yoshanuikabundi Apr 4, 2024
4ce82d3
Try reporting failing notebooks as JSON
Yoshanuikabundi Apr 5, 2024
b51f0b1
Provide a clearer report to PRs
Yoshanuikabundi Apr 5, 2024
aa39667
Replace \n with literal newline
Yoshanuikabundi Apr 5, 2024
ee3d5c9
Run notebooks in multiple processes
Yoshanuikabundi Apr 26, 2024
7f3399d
Exit with error code 1 if exceptions were encountered
Yoshanuikabundi May 1, 2024
9bd8f48
Make early exit on failure optional
Yoshanuikabundi May 1, 2024
c2a6e21
fix allow_failures logic bug
Yoshanuikabundi May 1, 2024
fbbade5
Ensure errors come at end of github CI log
Yoshanuikabundi May 1, 2024
d6f426f
Try to fail fast in inline shell scripts in cookbook_preproc.yaml
Yoshanuikabundi May 1, 2024
e33c395
Revert "Try to fail fast in inline shell scripts in cookbook_preproc.…
Yoshanuikabundi May 1, 2024
7860526
Add fallback status report for when json log is not generated
Yoshanuikabundi May 1, 2024
b4f3cf3
Propagate preproc failure to workflow
Yoshanuikabundi May 1, 2024
83dc6a9
Attempt to ensure status always reported to PR
Yoshanuikabundi May 1, 2024
90733e7
Skip failing notebook
Yoshanuikabundi May 2, 2024
46833e2
More info for debugging
Yoshanuikabundi May 2, 2024
e215404
Write long even on success
Yoshanuikabundi May 2, 2024
0e1fb8a
Fix link in status report fallback
Yoshanuikabundi May 2, 2024
e275219
typo
Yoshanuikabundi May 2, 2024
5efbc7d
Add OPTIONAL_NOTEBOOKS setting
Yoshanuikabundi May 3, 2024
2f469dc
Logic error
Yoshanuikabundi May 3, 2024
43020bf
Report ignored notebooks
Yoshanuikabundi May 3, 2024
d26515c
Logic error
Yoshanuikabundi May 3, 2024
3af7121
Merge branch 'main' into skip-failing-notebooks
Yoshanuikabundi May 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Run notebooks in multiple processes
  • Loading branch information
Yoshanuikabundi committed Apr 26, 2024
commit ee3d5c9573f6ce2efd23f2e1e164bafefc68dba6
6 changes: 3 additions & 3 deletions devtools/conda-envs/examples_env.yml
Original file line number Diff line number Diff line change
@@ -13,8 +13,8 @@ dependencies:
- requests
- packaging
# Examples
- openff-toolkit-examples>=0.15.2
- openff-interchange>=0.3.18
- openff-toolkit-examples>=0.16.0
- openff-interchange>=0.3.26
- openff-nagl
# - openff-fragmenter
# - openff-qcsubmit
@@ -23,4 +23,4 @@ dependencies:
- rich
- jax
- parmed<4
- nglview>=3.0.6
- nglview>=3.0.6,<3.1.0
9 changes: 7 additions & 2 deletions source/_ext/cookbook/utils.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
from types import FunctionType
from typing import (
Callable,
Generic,
Iterable,
Iterator,
Optional,
@@ -10,6 +11,7 @@
ParamSpec,
Union,
)
import abc
import contextlib
import os

@@ -32,7 +34,9 @@ def next_or_none(iterator: Iterator[T]) -> Optional[T]:
return ret


def _result_inner(fn, exception, *args, **kwargs):
def result(
fn: Callable[P, T], exception: type[E], *args: P.args, **kwargs: P.kwargs
) -> Union[T, E]:
try:
return fn(*args, **kwargs)
except exception as e:
@@ -42,7 +46,8 @@ def _result_inner(fn, exception, *args, **kwargs):
def to_result(
fn: Callable[P, T], exception: type[E] = Exception
) -> Callable[P, Union[T, E]]:
return partial(_result_inner, fn, exception)
# partial's type stub is not precise enough to work here
return partial(result, fn, exception) # type: ignore [reportReturnType]


@contextlib.contextmanager
40 changes: 19 additions & 21 deletions source/_ext/proc_examples.py
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@
)
from cookbook.github import download_dir, get_tag_matching_installed_version
from cookbook.globals_ import *
from cookbook.utils import set_env, to_result
from cookbook.utils import set_env, result, to_result


class NotebookExceptionError(ValueError):
@@ -310,26 +310,24 @@ def main(
# Execute notebooks in parallel for rendering as HTML
if do_exec:
shutil.rmtree(EXEC_IPYNB_ROOT, ignore_errors=True)
# # Context manager ensures the pool is correctly terminated if there's
# # an exception
# with Pool(processes=processes) as pool:
# # Wait a second between launching subprocesses
# # Workaround https://github.com/jupyter/nbconvert/issues/1066
# exec_results = [
# *pool.imap(
# to_result(partial(execute_notebook, cache_branch=cache_branch)),
# delay_iterator(notebooks),
# )
# ]
# for result in exec_results:
# if isinstance(result, Exception):
# traceback.print_exception(result)
exceptions: list[NotebookExceptionError] = []
for notebook in notebooks:
try:
execute_notebook(notebook, cache_branch=cache_branch)
except NotebookExceptionError as e:
exceptions.append(e)
# Context manager ensures the pool is correctly terminated if there's
# an exception
with Pool(processes=processes) as pool:
# Wait a second between launching subprocesses
# Workaround https://github.com/jupyter/nbconvert/issues/1066
exec_results = [
*pool.imap(
to_result(
partial(execute_notebook, cache_branch=cache_branch),
NotebookExceptionError,
),
delay_iterator(notebooks),
)
]

exceptions: list[NotebookExceptionError] = [
result for result in exec_results if isinstance(result, Exception)
]

for exception in exceptions:
print(
Loading