Skip to content

Commit

Permalink
CI: use tutorial's own directory as working directory
Browse files Browse the repository at this point in the history
  • Loading branch information
schlegelp committed Sep 5, 2024
1 parent 03479ac commit d405fdf
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion tests/test_tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
Code to execute code examples notebooks in /docs/examples.
This will not be run through pytest but is meant to be run in a separate CI job.
A couple notes:
- it's possible that any notebook that spawns another child process (e.g. the SWC I/O tutorial)
will hang indefinitely. This is because of the ominous "An attempt has been made to start a new
process before the current process has finished its bootstrapping phase." error which typically
means that the script has to be run in a `if __name__ == "__main__":` block.
Set `capture_output=True` to see the error message.
"""

import subprocess
Expand All @@ -17,14 +24,16 @@

files = list(path.rglob("*.py"))
for i, file in enumerate(files):

if not file.is_file():
continue
if file.name in SKIP:
continue

print(f"Executing {file.name} [{i+1}/{len(files)}]... ", end="", flush=True)
try:
p = subprocess.run(["python", str(file)], check=True, capture_output=True, timeout=600)
# Set `capture_output=True` to see e.g. error messages.
p = subprocess.run(["python", str(file)], check=True, capture_output=True, timeout=600, cwd=file.parent)
except subprocess.CalledProcessError as e:
print("Failed.")
print(e.stdout.decode())
Expand Down

0 comments on commit d405fdf

Please sign in to comment.