File: reproducible_exception

package info (click to toggle)
joblib 1.5.2-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,284 kB
  • sloc: python: 15,669; sh: 124; makefile: 39
file content (30 lines) | stat: -rw-r--r-- 1,043 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
From: Michael R. Crusoe <crusoe@debian.org>
Subject: Increase reproducibility by removing local path from the docs
Forwarded: https://github.com/joblib/joblib/pull/1761
--- joblib.orig/examples/serialization_and_wrappers.py
+++ joblib/examples/serialization_and_wrappers.py
@@ -11,9 +11,11 @@
 # Code source: Thomas Moreau
 # License: BSD 3 clause
 
+import os
 import sys
 import time
 import traceback
+from io import StringIO
 
 from joblib import Parallel, delayed, parallel_config, wrap_non_picklable_objects
 from joblib.externals.loky import set_loky_pickler
@@ -121,7 +123,11 @@
 try:
     Parallel(n_jobs=2)(delayed(func_async)(21, large_list) for _ in range(1))
 except Exception:
-    traceback.print_exc(file=sys.stdout)
+    tb_io = StringIO()
+    traceback.print_exc(file=tb_io)
+    tb_without_root_path = tb_io.getvalue().replace(os.getcwd().split("/examples")[0], "…")
+    print(tb_without_root_path, file=sys.stderr)
+    tb_io.close()
 
 
 ###############################################################################