returnn 1.20250603.232135__py3-none-any.whl → 1.20250618.1520__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 CHANGED
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: returnn
3
- Version: 1.20250603.232135
3
+ Version: 1.20250618.1520
4
4
  Summary: The RWTH extensible training framework for universal recurrent neural networks
5
5
  Home-page: https://github.com/rwth-i6/returnn/
6
6
  Author: Albert Zeyer
@@ -1,2 +1,2 @@
1
- version = '1.20250603.232135'
2
- long_version = '1.20250603.232135+git.5b262ae'
1
+ version = '1.20250618.001520'
2
+ long_version = '1.20250618.001520+git.6fa3e10'
@@ -96,6 +96,10 @@ except NameError: # Python3
96
96
  PY3 = sys.version_info[0] >= 3
97
97
 
98
98
 
99
+ cfg_print_builtins = False
100
+ cfg_print_not_found = False
101
+
102
+
99
103
  def parse_py_statement(line):
100
104
  """
101
105
  Parse Python statement into tokens.
@@ -111,6 +115,10 @@ def parse_py_statement(line):
111
115
  """
112
116
  state = 0
113
117
  cur_token = ""
118
+ str_prefix = None
119
+ str_is_f_string = False # whether we are in an f-string
120
+ str_quote = None
121
+ f_str_expr_opening_brackets = 0
114
122
  spaces = " \t\n"
115
123
  ops = ".,;:+-*/%&!=|(){}[]^<>"
116
124
  i = 0
@@ -133,29 +141,36 @@ def parse_py_statement(line):
133
141
  yield "op", c
134
142
  elif c == "#":
135
143
  state = 6
136
- elif c == '"':
144
+ elif c in "\"'":
137
145
  state = 1
138
- elif c == "'":
139
- state = 2
140
- else:
141
- cur_token = c
142
- state = 3
143
- elif state == 1: # string via "
144
- if c == "\\":
145
- state = 4
146
- elif c == '"':
147
- yield "str", cur_token
146
+ str_prefix = None
147
+ str_is_f_string = False
148
+ str_quote = c
148
149
  cur_token = ""
149
- state = 0
150
150
  else:
151
- cur_token += c
152
- elif state == 2: # string via '
151
+ cur_token = c
152
+ state = 3 # identifier
153
+ elif state == 1: # string
153
154
  if c == "\\":
154
- state = 5
155
- elif c == "'":
156
- yield "str", cur_token
155
+ cur_token += _escape_char(line[i : i + 1])
156
+ i += 1
157
+ elif c == str_quote:
158
+ yield "str" if not str_prefix else "%s-str" % str_prefix, cur_token
157
159
  cur_token = ""
158
160
  state = 0
161
+ elif str_is_f_string and c == "{": # f-string
162
+ if line[i - 1 : i + 1] == "{{":
163
+ cur_token += "{"
164
+ i += 1
165
+ else:
166
+ yield "str" if not str_prefix else "%s-str" % str_prefix, cur_token
167
+ yield "f-str-expr-open", "{"
168
+ cur_token = ""
169
+ f_str_expr_opening_brackets = 0
170
+ state = 4
171
+ elif str_is_f_string and c == "}" and line[i - 1 : i + 1] == "}}":
172
+ cur_token += "}"
173
+ i += 1
159
174
  else:
160
175
  cur_token += c
161
176
  elif state == 3: # identifier
@@ -164,20 +179,40 @@ def parse_py_statement(line):
164
179
  cur_token = ""
165
180
  state = 0
166
181
  i -= 1
167
- elif c == '"': # identifier is string prefix
168
- cur_token = ""
182
+ elif c in "\"'": # identifier is string prefix
169
183
  state = 1
170
- elif c == "'": # identifier is string prefix
184
+ str_prefix = cur_token
185
+ str_is_f_string = "f" in str_prefix or "F" in str_prefix
186
+ str_quote = c
171
187
  cur_token = ""
172
- state = 2
173
188
  else:
174
189
  cur_token += c
175
- elif state == 4: # escape in "
176
- cur_token += _escape_char(c)
177
- state = 1
178
- elif state == 5: # escape in '
179
- cur_token += _escape_char(c)
180
- state = 2
190
+ elif state == 4: # f-string expression (like state 0 but simplified)
191
+ if c in spaces:
192
+ pass
193
+ elif c in ops:
194
+ if f_str_expr_opening_brackets == 0 and c == "}":
195
+ yield "f-str-expr-close", "}"
196
+ state = 1 # back into the f-string
197
+ cur_token = ""
198
+ else:
199
+ yield "op", c
200
+ if c in "([{":
201
+ f_str_expr_opening_brackets += 1
202
+ elif c in ")]}":
203
+ if f_str_expr_opening_brackets > 0:
204
+ f_str_expr_opening_brackets -= 1
205
+ else:
206
+ cur_token = c
207
+ state = 5 # identifier in f-string expression
208
+ elif state == 5: # identifier in f-string expression (like state 3 but simplified)
209
+ if c in spaces + ops:
210
+ yield "id", cur_token
211
+ cur_token = ""
212
+ state = 4
213
+ i -= 1
214
+ else:
215
+ cur_token += c
181
216
  elif state == 6: # comment
182
217
  cur_token += c
183
218
  if state == 3:
@@ -234,6 +269,7 @@ def set_linecache(filename, source):
234
269
  """
235
270
  import linecache
236
271
 
272
+ # noinspection PyTypeChecker
237
273
  linecache.cache[filename] = None, None, [line + "\n" for line in source.splitlines()], filename
238
274
 
239
275
 
@@ -245,7 +281,7 @@ def simple_debug_shell(globals, locals):
245
281
  :return: nothing
246
282
  """
247
283
  try:
248
- import readline
284
+ import readline # noqa: F401
249
285
  except ImportError:
250
286
  pass # ignore
251
287
  compile_string_fn = "<simple_debug_shell input>"
@@ -253,7 +289,7 @@ def simple_debug_shell(globals, locals):
253
289
  try:
254
290
  s = raw_input("> ")
255
291
  except (KeyboardInterrupt, EOFError):
256
- print("breaked debug shell: " + sys.exc_info()[0].__name__)
292
+ print("broke debug shell: " + sys.exc_info()[0].__name__)
257
293
  break
258
294
  if s.strip() == "":
259
295
  continue
@@ -307,9 +343,6 @@ def debug_shell(user_ns, user_global_ns, traceback=None, execWrapper=None):
307
343
  if not ipshell and traceback and have_ipython:
308
344
  # noinspection PyBroadException
309
345
  try:
310
- # noinspection PyPackageRequirements,PyUnresolvedReferences
311
- from IPython.core.debugger import Pdb
312
-
313
346
  # noinspection PyPackageRequirements,PyUnresolvedReferences
314
347
  from IPython.terminal.debugger import TerminalPdb
315
348
 
@@ -1123,6 +1156,8 @@ def format_tb(
1123
1156
  output("(Exclude vars because we are on a GC stack.)")
1124
1157
  if with_vars is None:
1125
1158
  with_vars = True
1159
+ locals_start_str = color(" locals:", color.fg_colors[0])
1160
+
1126
1161
  # noinspection PyBroadException
1127
1162
  try:
1128
1163
  if limit is None:
@@ -1170,10 +1205,11 @@ def format_tb(
1170
1205
  if isframe(_tb):
1171
1206
  f = _tb
1172
1207
  elif is_stack_summary(_tb):
1173
- if isinstance(_tb[0], ExtendedFrameSummary):
1174
- f = _tb[0].tb_frame
1208
+ _tb0 = _tb[0]
1209
+ if isinstance(_tb0, ExtendedFrameSummary):
1210
+ f = _tb0.tb_frame
1175
1211
  else:
1176
- f = DummyFrame.from_frame_summary(_tb[0])
1212
+ f = DummyFrame.from_frame_summary(_tb0)
1177
1213
  else:
1178
1214
  f = _tb.tb_frame
1179
1215
  if allLocals is not None:
@@ -1216,12 +1252,13 @@ def format_tb(
1216
1252
  elif isinstance(f, DummyFrame) and not f.have_vars_available:
1217
1253
  pass
1218
1254
  else:
1219
- with output.fold_text_ctx(color(" locals:", color.fg_colors[0])):
1220
- already_printed_locals = set() # type: typing.Set[typing.Tuple[str,...]]
1255
+ with output.fold_text_ctx(locals_start_str):
1256
+ already_covered_locals = set() # type: typing.Set[typing.Tuple[str,...]]
1257
+ num_printed_locals = 0
1221
1258
  for token_str in grep_full_py_identifiers(parse_py_statement(source_code)):
1222
1259
  splitted_token = tuple(token_str.split("."))
1223
1260
  for token in [splitted_token[0:i] for i in range(1, len(splitted_token) + 1)]:
1224
- if token in already_printed_locals:
1261
+ if token in already_covered_locals:
1225
1262
  continue
1226
1263
  token_value = None
1227
1264
  token_value = _try_set(
@@ -1234,19 +1271,34 @@ def format_tb(
1234
1271
  color("<global> ", color.fg_colors[0]),
1235
1272
  lambda: format_py_obj(_resolve_identifier(f.f_globals, token)),
1236
1273
  )
1274
+ if not token_value and (
1275
+ (not cfg_print_not_found and not cfg_print_builtins)
1276
+ or (not cfg_print_builtins and token[0] in f.f_builtins)
1277
+ ):
1278
+ already_covered_locals.add(token)
1279
+ continue
1237
1280
  token_value = _try_set(
1238
1281
  token_value,
1239
1282
  color("<builtin> ", color.fg_colors[0]),
1240
1283
  lambda: format_py_obj(_resolve_identifier(f.f_builtins, token)),
1241
1284
  )
1285
+ if not token_value and not cfg_print_not_found:
1286
+ already_covered_locals.add(token)
1287
+ continue
1242
1288
  token_value = token_value or color("<not found>", color.fg_colors[0])
1243
1289
  prefix = " %s " % color(".", color.fg_colors[0], bold=True).join(
1244
1290
  token
1245
1291
  ) + color("= ", color.fg_colors[0], bold=True)
1246
1292
  output(prefix, token_value)
1247
- already_printed_locals.add(token)
1248
- if len(already_printed_locals) == 0:
1249
- output(color(" no locals", color.fg_colors[0]))
1293
+ already_covered_locals.add(token)
1294
+ num_printed_locals += 1
1295
+ if num_printed_locals == 0:
1296
+ if output.lines and output.lines[-1].endswith(locals_start_str + "\n"):
1297
+ output.lines[-1] = output.lines[-1][: -len(locals_start_str) - 1]
1298
+ elif output.lines and output.lines[-1].endswith("\n"):
1299
+ output.lines[-1] = output.lines[-1][:-1] + color(" none", color.fg_colors[0]) + "\n"
1300
+ else:
1301
+ output(color(" no locals", color.fg_colors[0]))
1250
1302
  else:
1251
1303
  output(color(" -- code not available --", color.fg_colors[0]))
1252
1304
 
@@ -1685,10 +1737,11 @@ def iter_traceback(tb=None, enforce_most_recent_call_first=False):
1685
1737
  if is_frame(_tb):
1686
1738
  frame = _tb
1687
1739
  elif is_stack_summary(_tb):
1688
- if isinstance(_tb[0], ExtendedFrameSummary):
1689
- frame = _tb[0].tb_frame
1740
+ _tb0 = _tb[0]
1741
+ if isinstance(_tb0, ExtendedFrameSummary):
1742
+ frame = _tb0.tb_frame
1690
1743
  else:
1691
- frame = DummyFrame.from_frame_summary(_tb[0])
1744
+ frame = DummyFrame.from_frame_summary(_tb0)
1692
1745
  else:
1693
1746
  frame = _tb.tb_frame
1694
1747
  yield frame
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: returnn
3
- Version: 1.20250603.232135
3
+ Version: 1.20250618.1520
4
4
  Summary: The RWTH extensible training framework for universal recurrent neural networks
5
5
  Home-page: https://github.com/rwth-i6/returnn/
6
6
  Author: Albert Zeyer
@@ -1,9 +1,9 @@
1
- returnn/PKG-INFO,sha256=Czm99-scfCrrKroopNZwjhabe7FeAhoGDQlNAwo5Nw0,5215
1
+ returnn/PKG-INFO,sha256=jUoMM8GhaYU7CQrz2W5oJVkXENef7qUHHgtyatgBC04,5213
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=2gwgouUoAt0DDVP1iuzwI5kqXkN4kDxgXM5X8ZpjBPg,77
6
+ returnn/_setup_info_generated.py,sha256=mVNyqStWOyZte0dqEGLW_uDC6n0niI0dyfvztRNMJZ4,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=98XnUZIWpYN7NfklSGt_5hYNplADVFQnh857esKxjdI,64475
237
+ returnn/util/better_exchook.py,sha256=el1N699ynWI3xHqSQaHz1jbWvPJRv8PFdpwWAZl-EiA,67267
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.20250603.232135.dist-info/LICENSE,sha256=ywBD_U2aD4vpuoIgNAsjIGBYydl0tVKll3De0Z8s77c,11041
257
- returnn-1.20250603.232135.dist-info/METADATA,sha256=Czm99-scfCrrKroopNZwjhabe7FeAhoGDQlNAwo5Nw0,5215
258
- returnn-1.20250603.232135.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
259
- returnn-1.20250603.232135.dist-info/top_level.txt,sha256=Lsn4WZc5Pbfk0-xDQOgnFCxOoqxL4CyeM3N1TFbJncw,8
260
- returnn-1.20250603.232135.dist-info/RECORD,,
256
+ returnn-1.20250618.1520.dist-info/LICENSE,sha256=ywBD_U2aD4vpuoIgNAsjIGBYydl0tVKll3De0Z8s77c,11041
257
+ returnn-1.20250618.1520.dist-info/METADATA,sha256=jUoMM8GhaYU7CQrz2W5oJVkXENef7qUHHgtyatgBC04,5213
258
+ returnn-1.20250618.1520.dist-info/WHEEL,sha256=iAkIy5fosb7FzIOwONchHf19Qu7_1wCWyFNR5gu9nU0,91
259
+ returnn-1.20250618.1520.dist-info/top_level.txt,sha256=Lsn4WZc5Pbfk0-xDQOgnFCxOoqxL4CyeM3N1TFbJncw,8
260
+ returnn-1.20250618.1520.dist-info/RECORD,,