|
9 | 9 | manifest. Nothing is written back unless --save is given, and then only for notebooks that |
10 | 10 | passed and already keep outputs. Output printed here is safe for public CI logs: notebook, |
11 | 11 | status, seconds, failing cell index and exception type, never the exception message or any |
12 | | -cell output (--verbose adds the message for local debugging). --check fails if a tracked |
| 12 | +cell output, and the kernel's own stdout/stderr is discarded (--verbose adds the message |
| 13 | +and lets the kernel's stdout/stderr through, for local debugging). --check fails if a tracked |
13 | 14 | notebook is missing from the manifest. Exit code 1 if any notebook fails. |
14 | 15 | """ |
15 | 16 |
|
@@ -97,8 +98,12 @@ def run(entry, save, verbose): |
97 | 98 | start = time.time() |
98 | 99 | result = {"notebook": entry["path"], "status": "pass", "failed_cell": None, "error_type": None} |
99 | 100 | message = "" |
| 101 | + # The kernel inherits this process's stdout/stderr, so anything a cell writes there |
| 102 | + # directly (subprocess.run without capture, logging to sys.__stderr__, native CLIs) |
| 103 | + # would land in the log. Discard it unless --verbose. |
| 104 | + quiet = {} if verbose else {"stdout": subprocess.DEVNULL, "stderr": subprocess.DEVNULL} |
100 | 105 | try: |
101 | | - client.execute() |
| 106 | + client.execute(**quiet) |
102 | 107 | except CellExecutionError as e: |
103 | 108 | result.update(status="fail", error_type=getattr(e, "ename", None) or "CellExecutionError") |
104 | 109 | message = str(getattr(e, "evalue", "")) |
@@ -138,7 +143,8 @@ def main(): |
138 | 143 | parser.add_argument("--only", nargs="+", metavar="PATH", help="run just these manifest paths") |
139 | 144 | parser.add_argument("--results", type=Path, help="write a JSON list of results here") |
140 | 145 | parser.add_argument("--save", action="store_true", help="write outputs back for notebooks that pass") |
141 | | - parser.add_argument("--verbose", action="store_true", help="also print exception messages (not for CI)") |
| 146 | + parser.add_argument("--verbose", action="store_true", |
| 147 | + help="also print exception messages and kernel stdout/stderr (not for CI)") |
142 | 148 | parser.add_argument("--list", action="store_true", help="print the selection without running it") |
143 | 149 | parser.add_argument("--check", action="store_true", help="verify the manifest lists every notebook") |
144 | 150 | parser.add_argument("--before-each", metavar="COMMAND", |
|
0 commit comments