returnn 1.20250618.1520__py3-none-any.whl → 1.20250620.102515__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of returnn might be problematic. Click here for more details.
- returnn/PKG-INFO +1 -1
- returnn/_setup_info_generated.py +2 -2
- returnn/util/better_exchook.py +135 -69
- {returnn-1.20250618.1520.dist-info → returnn-1.20250620.102515.dist-info}/METADATA +1 -1
- {returnn-1.20250618.1520.dist-info → returnn-1.20250620.102515.dist-info}/RECORD +8 -8
- {returnn-1.20250618.1520.dist-info → returnn-1.20250620.102515.dist-info}/LICENSE +0 -0
- {returnn-1.20250618.1520.dist-info → returnn-1.20250620.102515.dist-info}/WHEEL +0 -0
- {returnn-1.20250618.1520.dist-info → returnn-1.20250620.102515.dist-info}/top_level.txt +0 -0
returnn/PKG-INFO
CHANGED
returnn/_setup_info_generated.py
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
version = '1.
|
|
2
|
-
long_version = '1.
|
|
1
|
+
version = '1.20250620.102515'
|
|
2
|
+
long_version = '1.20250620.102515+git.98f67ee'
|
returnn/util/better_exchook.py
CHANGED
|
@@ -58,6 +58,7 @@ import threading
|
|
|
58
58
|
import keyword
|
|
59
59
|
import inspect
|
|
60
60
|
import contextlib
|
|
61
|
+
import types
|
|
61
62
|
from weakref import WeakKeyDictionary
|
|
62
63
|
|
|
63
64
|
try:
|
|
@@ -98,6 +99,10 @@ PY3 = sys.version_info[0] >= 3
|
|
|
98
99
|
|
|
99
100
|
cfg_print_builtins = False
|
|
100
101
|
cfg_print_not_found = False
|
|
102
|
+
cfg_print_bound_methods = False
|
|
103
|
+
cfg_print_modules = False
|
|
104
|
+
cfg_print_module_functions = False
|
|
105
|
+
cfg_print_module_classes = False
|
|
101
106
|
|
|
102
107
|
|
|
103
108
|
def parse_py_statement(line):
|
|
@@ -1054,7 +1059,12 @@ class _OutputLinesCollector:
|
|
|
1054
1059
|
:param typing.Any obj:
|
|
1055
1060
|
:rtype: str
|
|
1056
1061
|
"""
|
|
1057
|
-
|
|
1062
|
+
if isinstance(obj, types.FunctionType) and hasattr(obj, "__module__") and hasattr(obj, "__qualname__"):
|
|
1063
|
+
s = "<function %s.%s>" % (obj.__module__, obj.__qualname__)
|
|
1064
|
+
elif isinstance(obj, type) and hasattr(obj, "__module__") and hasattr(obj, "__qualname__"):
|
|
1065
|
+
s = "<class %s.%s>" % (obj.__module__, obj.__qualname__)
|
|
1066
|
+
else:
|
|
1067
|
+
s = repr(obj)
|
|
1058
1068
|
limit = output_limit()
|
|
1059
1069
|
if len(s) > limit:
|
|
1060
1070
|
if self.dom_term:
|
|
@@ -1085,18 +1095,24 @@ def format_tb(
|
|
|
1085
1095
|
clear_frames=True,
|
|
1086
1096
|
):
|
|
1087
1097
|
"""
|
|
1088
|
-
|
|
1098
|
+
Formats a traceback into a list of strings, each corresponding to one frame.
|
|
1099
|
+
|
|
1100
|
+
Replacement for traceback.format_tb.
|
|
1101
|
+
|
|
1102
|
+
:param types.TracebackType|types.FrameType|StackSummary tb: traceback. If None, will use sys._getframe
|
|
1089
1103
|
:param int|None limit: limit the traceback to this number of frames. by default, will look at sys.tracebacklimit
|
|
1090
1104
|
:param dict[str,typing.Any]|None allLocals: if set, will update it with all locals from all frames
|
|
1091
1105
|
:param dict[str,typing.Any]|None allGlobals: if set, will update it with all globals from all frames
|
|
1092
1106
|
:param bool withTitle:
|
|
1093
1107
|
:param bool|None with_color: output with ANSI escape codes for color
|
|
1094
|
-
:param bool with_vars: will print var
|
|
1108
|
+
:param bool with_vars: will print var contents that are referenced in the source code line. by default enabled.
|
|
1095
1109
|
:param bool clear_frames: whether to call frame.clear() after processing it.
|
|
1096
1110
|
That will potentially fix some mem leaks regarding locals, so it can be important.
|
|
1097
1111
|
Also see https://github.com/python/cpython/issues/113939.
|
|
1098
|
-
However, any further access to frame locals will not work (e.g
|
|
1099
|
-
:return: list of strings
|
|
1112
|
+
However, any further access to frame locals will not work (e.g., if you want to use a debugger afterward).
|
|
1113
|
+
:return: list of strings, each corresponding to one frame in the traceback.
|
|
1114
|
+
Each string contains the file name, line number, function name, source code line, maybe relevant variables,
|
|
1115
|
+
etc., and a final newline.
|
|
1100
1116
|
:rtype: list[str]
|
|
1101
1117
|
"""
|
|
1102
1118
|
color = Color(enable=with_color)
|
|
@@ -1166,41 +1182,6 @@ def format_tb(
|
|
|
1166
1182
|
n = 0
|
|
1167
1183
|
_tb = tb
|
|
1168
1184
|
|
|
1169
|
-
class NotFound(Exception):
|
|
1170
|
-
"""
|
|
1171
|
-
Identifier not found.
|
|
1172
|
-
"""
|
|
1173
|
-
|
|
1174
|
-
def _resolve_identifier(namespace, keys):
|
|
1175
|
-
"""
|
|
1176
|
-
:param dict[str,typing.Any] namespace:
|
|
1177
|
-
:param typing.Sequence[str] keys:
|
|
1178
|
-
:return: namespace[name[0]][name[1]]...
|
|
1179
|
-
"""
|
|
1180
|
-
if keys[0] not in namespace:
|
|
1181
|
-
raise NotFound()
|
|
1182
|
-
obj = namespace[keys[0]]
|
|
1183
|
-
for part in keys[1:]:
|
|
1184
|
-
obj = getattr(obj, part)
|
|
1185
|
-
return obj
|
|
1186
|
-
|
|
1187
|
-
# noinspection PyShadowingNames
|
|
1188
|
-
def _try_set(old, prefix, func):
|
|
1189
|
-
"""
|
|
1190
|
-
:param None|str old:
|
|
1191
|
-
:param str prefix:
|
|
1192
|
-
:param func:
|
|
1193
|
-
:return: old
|
|
1194
|
-
"""
|
|
1195
|
-
if old is not None:
|
|
1196
|
-
return old
|
|
1197
|
-
try:
|
|
1198
|
-
return add_indent_lines(prefix, func())
|
|
1199
|
-
except NotFound:
|
|
1200
|
-
return old
|
|
1201
|
-
except Exception as e:
|
|
1202
|
-
return prefix + "!" + e.__class__.__name__ + ": " + str(e)
|
|
1203
|
-
|
|
1204
1185
|
while _tb is not None and (limit is None or n < limit):
|
|
1205
1186
|
if isframe(_tb):
|
|
1206
1187
|
f = _tb
|
|
@@ -1260,38 +1241,77 @@ def format_tb(
|
|
|
1260
1241
|
for token in [splitted_token[0:i] for i in range(1, len(splitted_token) + 1)]:
|
|
1261
1242
|
if token in already_covered_locals:
|
|
1262
1243
|
continue
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
color("<local> ", color.fg_colors[0])
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1244
|
+
already_covered_locals.add(token)
|
|
1245
|
+
if token[0] in f.f_locals:
|
|
1246
|
+
token_base_dict = f.f_locals
|
|
1247
|
+
token_prefix_str = color("<local> ", color.fg_colors[0])
|
|
1248
|
+
elif token[0] in f.f_globals:
|
|
1249
|
+
token_base_dict = f.f_globals
|
|
1250
|
+
token_prefix_str = color("<global> ", color.fg_colors[0])
|
|
1251
|
+
if (
|
|
1252
|
+
not cfg_print_module_functions
|
|
1253
|
+
and len(token) == 1
|
|
1254
|
+
and _is_module_function(token_base_dict, token[0], obj_is_dict=True)
|
|
1255
|
+
):
|
|
1256
|
+
continue
|
|
1257
|
+
if (
|
|
1258
|
+
not cfg_print_module_classes
|
|
1259
|
+
and len(token) == 1
|
|
1260
|
+
and _is_module_class(token_base_dict, token[0], obj_is_dict=True)
|
|
1261
|
+
):
|
|
1262
|
+
continue
|
|
1263
|
+
elif token[0] in f.f_builtins:
|
|
1264
|
+
if not cfg_print_builtins:
|
|
1265
|
+
continue
|
|
1266
|
+
token_base_dict = f.f_builtins
|
|
1267
|
+
token_prefix_str = color("<builtin> ", color.fg_colors[0])
|
|
1268
|
+
else:
|
|
1269
|
+
if not cfg_print_not_found:
|
|
1270
|
+
continue
|
|
1271
|
+
token_base_dict = None
|
|
1272
|
+
token_prefix_str = None
|
|
1273
|
+
|
|
1289
1274
|
prefix = " %s " % color(".", color.fg_colors[0], bold=True).join(
|
|
1290
1275
|
token
|
|
1291
1276
|
) + color("= ", color.fg_colors[0], bold=True)
|
|
1292
|
-
|
|
1293
|
-
|
|
1277
|
+
|
|
1278
|
+
if token_prefix_str is None: # not found
|
|
1279
|
+
token_repr = color("<not found>", color.fg_colors[0])
|
|
1280
|
+
else:
|
|
1281
|
+
try:
|
|
1282
|
+
token_parent_obj = None
|
|
1283
|
+
token_obj = token_base_dict[token[0]]
|
|
1284
|
+
for attr in token[1:]:
|
|
1285
|
+
token_parent_obj = token_obj
|
|
1286
|
+
token_obj = getattr(token_obj, attr)
|
|
1287
|
+
except Exception as e:
|
|
1288
|
+
token_repr = token_prefix_str + "!" + e.__class__.__name__ + ": " + str(e)
|
|
1289
|
+
else: # found
|
|
1290
|
+
if (
|
|
1291
|
+
not cfg_print_bound_methods
|
|
1292
|
+
and token_parent_obj is not None
|
|
1293
|
+
and _is_bound_method(token_parent_obj, token[-1])
|
|
1294
|
+
):
|
|
1295
|
+
continue
|
|
1296
|
+
if not cfg_print_modules and isinstance(token_obj, types.ModuleType):
|
|
1297
|
+
continue
|
|
1298
|
+
if (
|
|
1299
|
+
not cfg_print_module_functions
|
|
1300
|
+
and token_parent_obj is not None
|
|
1301
|
+
and _is_module_function(token_parent_obj, token[-1])
|
|
1302
|
+
):
|
|
1303
|
+
continue
|
|
1304
|
+
if (
|
|
1305
|
+
not cfg_print_module_classes
|
|
1306
|
+
and token_parent_obj is not None
|
|
1307
|
+
and _is_module_class(token_parent_obj, token[-1])
|
|
1308
|
+
):
|
|
1309
|
+
continue
|
|
1310
|
+
token_repr = add_indent_lines(token_prefix_str, format_py_obj(token_obj))
|
|
1311
|
+
|
|
1312
|
+
output(prefix, token_repr)
|
|
1294
1313
|
num_printed_locals += 1
|
|
1314
|
+
|
|
1295
1315
|
if num_printed_locals == 0:
|
|
1296
1316
|
if output.lines and output.lines[-1].endswith(locals_start_str + "\n"):
|
|
1297
1317
|
output.lines[-1] = output.lines[-1][: -len(locals_start_str) - 1]
|
|
@@ -1299,7 +1319,8 @@ def format_tb(
|
|
|
1299
1319
|
output.lines[-1] = output.lines[-1][:-1] + color(" none", color.fg_colors[0]) + "\n"
|
|
1300
1320
|
else:
|
|
1301
1321
|
output(color(" no locals", color.fg_colors[0]))
|
|
1302
|
-
|
|
1322
|
+
|
|
1323
|
+
else: # no source code available
|
|
1303
1324
|
output(color(" -- code not available --", color.fg_colors[0]))
|
|
1304
1325
|
|
|
1305
1326
|
if clear_frames:
|
|
@@ -1336,6 +1357,8 @@ def format_tb(
|
|
|
1336
1357
|
|
|
1337
1358
|
def print_tb(tb, file=None, **kwargs):
|
|
1338
1359
|
"""
|
|
1360
|
+
Prints the traceback to stderr, or the given file.
|
|
1361
|
+
|
|
1339
1362
|
Replacement for traceback.print_tb.
|
|
1340
1363
|
|
|
1341
1364
|
:param types.TracebackType|types.FrameType|StackSummary tb:
|
|
@@ -1836,6 +1859,49 @@ def _StackSummary_extract(frame_gen, limit=None, lookup_lines=True, capture_loca
|
|
|
1836
1859
|
return result
|
|
1837
1860
|
|
|
1838
1861
|
|
|
1862
|
+
def _is_bound_method(obj, attr_name):
|
|
1863
|
+
if not PY3:
|
|
1864
|
+
return False # not properly supported in Python 2
|
|
1865
|
+
|
|
1866
|
+
meth = getattr(obj, attr_name, None)
|
|
1867
|
+
meth = inspect.unwrap(meth)
|
|
1868
|
+
|
|
1869
|
+
if isinstance(meth, types.MethodType):
|
|
1870
|
+
if meth.__self__ is not obj:
|
|
1871
|
+
return False
|
|
1872
|
+
cls = type(obj)
|
|
1873
|
+
func = getattr(cls, attr_name, None)
|
|
1874
|
+
return meth.__func__ is func
|
|
1875
|
+
|
|
1876
|
+
elif isinstance(meth, (types.BuiltinMethodType, getattr(types, "MethodWrapperType", types.BuiltinMethodType))):
|
|
1877
|
+
if meth.__self__ is not obj:
|
|
1878
|
+
return False
|
|
1879
|
+
return meth.__name__ == attr_name
|
|
1880
|
+
|
|
1881
|
+
else:
|
|
1882
|
+
return False
|
|
1883
|
+
|
|
1884
|
+
|
|
1885
|
+
def _is_module_function(obj, attr_name, obj_is_dict=False):
|
|
1886
|
+
if obj_is_dict:
|
|
1887
|
+
func = obj.get(attr_name, None)
|
|
1888
|
+
else:
|
|
1889
|
+
if not isinstance(obj, types.ModuleType):
|
|
1890
|
+
return False
|
|
1891
|
+
func = getattr(obj, attr_name, None)
|
|
1892
|
+
return isinstance(func, types.FunctionType)
|
|
1893
|
+
|
|
1894
|
+
|
|
1895
|
+
def _is_module_class(obj, attr_name, obj_is_dict=False):
|
|
1896
|
+
if obj_is_dict:
|
|
1897
|
+
cls = obj.get(attr_name, None)
|
|
1898
|
+
else:
|
|
1899
|
+
if not isinstance(obj, types.ModuleType):
|
|
1900
|
+
return False
|
|
1901
|
+
cls = getattr(obj, attr_name, None)
|
|
1902
|
+
return isinstance(cls, type)
|
|
1903
|
+
|
|
1904
|
+
|
|
1839
1905
|
def install():
|
|
1840
1906
|
"""
|
|
1841
1907
|
Replaces sys.excepthook by our better_exchook.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
returnn/PKG-INFO,sha256=
|
|
1
|
+
returnn/PKG-INFO,sha256=SukecFA543t3-WlWN1ENSGlUCNa735c92GHdnePY8xg,5215
|
|
2
2
|
returnn/__init__.py,sha256=biBtRsM0WZ406vShaeH-9WFoqJ8XwTbn6g0EeFJ7l8E,1012
|
|
3
3
|
returnn/__main__.py,sha256=lHyZcu_0yc9f7Vf_Kfdy9PmeU0T76XVXnpalHi5WKro,31740
|
|
4
4
|
returnn/__old_mod_loader__.py,sha256=nvsNY-xELdS_IPNkv66Q9Rmvg4dbGW0-EBRDcCmctos,7654
|
|
5
5
|
returnn/__setup__.py,sha256=22kQn2fh11iPM0hLb2Fy5sLmoU1JGvmDxXRYuRgQkwU,4659
|
|
6
|
-
returnn/_setup_info_generated.py,sha256=
|
|
6
|
+
returnn/_setup_info_generated.py,sha256=uxrxbQLCrAPLaZOlKmpyxV4GhL1oM1RdNC4IrcYNdJw,77
|
|
7
7
|
returnn/config.py,sha256=3tmKhB6FnQZaNdtcYsiB61JnEY--iZ2qmJ4yq0b6tE0,29140
|
|
8
8
|
returnn/forward_iface.py,sha256=A_OJiaXsX4MlXQRzST86ylyxSUZbC402PQL1REcqHjM,911
|
|
9
9
|
returnn/learning_rate_control.py,sha256=ZvWryAn_tv9DhV8sh1LV3eE34Yltl3On3mYZAG4hR9s,34684
|
|
@@ -234,7 +234,7 @@ returnn/torch/util/module.py,sha256=MXHIrF9Isu575DDJIa81212ULKwdqu1oOLxDVZecVSk,
|
|
|
234
234
|
returnn/torch/util/scaled_gradient.py,sha256=C5e79mpqtxdtw08OTSy413TSBSlOertRisc-ioiFIaU,3191
|
|
235
235
|
returnn/util/__init__.py,sha256=UIG1qw4idqhW71BV60ha7h9PktxvEVcBIu0lYRossK8,336
|
|
236
236
|
returnn/util/basic.py,sha256=Ep67bFPbxiaMKgsjrUqF0seoswghAqLsUQYcpgQGeyE,142570
|
|
237
|
-
returnn/util/better_exchook.py,sha256=
|
|
237
|
+
returnn/util/better_exchook.py,sha256=39yvRecluDgYhViwSkaQ8crJ_cBWI63KeEGuK4RKe5w,70843
|
|
238
238
|
returnn/util/bpe.py,sha256=LWFhICZsEOnMwNws0lybPNzKRX6rSr8yKCvP65vjl9Y,19656
|
|
239
239
|
returnn/util/debug.py,sha256=wuRzdg9zB84WWCGyTjmRR_zYypu8gXxlc0nZ6si9OC8,28224
|
|
240
240
|
returnn/util/debug_helpers.py,sha256=0EINLK4uLtoSt5_kHs1M2NIFpMd0S7i4c4rx90U4fJk,2914
|
|
@@ -253,8 +253,8 @@ returnn/util/sig_proc.py,sha256=Tjz0VOAVyqu2qDCF5HZ1JjALjcFsHcNkcd96WgZeKfE,7265
|
|
|
253
253
|
returnn/util/task_system.py,sha256=y4sMVXQ25Qd2z0rx03uOlXlkE-jbCYC1Sjfn-XlraVU,26003
|
|
254
254
|
returnn/util/train_proc_manager.py,sha256=Pjht28k6uz6BNQ47uW6Gf880iyq5q4wx7P_K2tmoAM8,3266
|
|
255
255
|
returnn/util/watch_memory.py,sha256=BR5P2kvBN6UI81cE0_1WAA6Hd1SByLbBaiDxvLhPOew,4213
|
|
256
|
-
returnn-1.
|
|
257
|
-
returnn-1.
|
|
258
|
-
returnn-1.
|
|
259
|
-
returnn-1.
|
|
260
|
-
returnn-1.
|
|
256
|
+
returnn-1.20250620.102515.dist-info/LICENSE,sha256=ywBD_U2aD4vpuoIgNAsjIGBYydl0tVKll3De0Z8s77c,11041
|
|
257
|
+
returnn-1.20250620.102515.dist-info/METADATA,sha256=SukecFA543t3-WlWN1ENSGlUCNa735c92GHdnePY8xg,5215
|
|
258
|
+
returnn-1.20250620.102515.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
|
|
259
|
+
returnn-1.20250620.102515.dist-info/top_level.txt,sha256=Lsn4WZc5Pbfk0-xDQOgnFCxOoqxL4CyeM3N1TFbJncw,8
|
|
260
|
+
returnn-1.20250620.102515.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|