| 1 |
From: Michael R. Crusoe <[email protected]> |
| 2 |
Subject: Increase reproducibility by removing local path from the docs |
| 3 |
Forwarded: https://github.com/joblib/joblib/pull/1761 |
| 4 |
--- joblib.orig/examples/serialization_and_wrappers.py |
| 5 |
+++ joblib/examples/serialization_and_wrappers.py |
| 6 |
@@ -11,9 +11,11 @@ |
| 7 |
# Code source: Thomas Moreau |
| 8 |
# License: BSD 3 clause |
| 9 |
|
| 10 |
+import os |
| 11 |
import sys |
| 12 |
import time |
| 13 |
import traceback |
| 14 |
+from io import StringIO |
| 15 |
|
| 16 |
from joblib import Parallel, delayed, parallel_config, wrap_non_picklable_objects |
| 17 |
from joblib.externals.loky import set_loky_pickler |
| 18 |
@@ -121,7 +123,11 @@ |
| 19 |
try: |
| 20 |
Parallel(n_jobs=2)(delayed(func_async)(21, large_list) for _ in range(1)) |
| 21 |
except Exception: |
| 22 |
|
| 23 |
+ tb_io = StringIO() |
| 24 |
+ traceback.print_exc(file=tb_io) |
| 25 |
+ tb_without_root_path = tb_io.getvalue().replace(os.getcwd().split("/examples")[0], "…") |
| 26 |
+ print(tb_without_root_path, file=sys.stderr) |
| 27 |
+ tb_io.close() |
| 28 |
|
| 29 |
|
| 30 |
############################################################################### |