Fix debug to never crash (would on some initialization steps)

This commit is contained in:
ebolam 2022-03-04 15:36:13 -05:00
parent 26b9268391
commit 321f45ccad
1 changed files with 29 additions and 5 deletions

View File

@ -5015,11 +5015,35 @@ if(vars.model in ("TPUMeshTransformerGPTJ",)):
def send_debug(): def send_debug():
if vars.debug: if vars.debug:
debug_info = "" debug_info = ""
for variable in [["Newline Mode", vars.newlinemode], try:
["Action Length", vars.actions.get_last_key()], ["Actions Metadata Length", max(vars.actions_metadata) if len(vars.actions_metadata) > 0 else 0], debug_info = "{}Newline Mode: {}\n".format(debug_info, vars.newlinemode)
["Actions", [k for k in vars.actions]], ["Actions Metadata", [k for k in vars.actions_metadata]], except:
["Last Action", vars.actions[vars.actions.get_last_key()]], ["Last Metadata", vars.actions_metadata[max(vars.actions_metadata)]]]: pass
debug_info = "{}{}: {}\n".format(debug_info, variable[0], variable[1]) try:
debug_info = "{}Action Length: {}\n".format(debug_info, vars.actions.get_last_key())
except:
pass
try:
debug_info = "{}Actions Metadata Length: {}\n".format(debug_info, max(vars.actions_metadata) if len(vars.actions_metadata) > 0 else 0)
except:
pass
try:
debug_info = "{}Actions: {}\n".format(debug_info, vars.actions.get_last_key())
except:
pass
try:
debug_info = "{}Actions Metadata: {}\n".format(debug_info, [k for k in vars.actions_metadata])
except:
pass
try:
debug_info = "{}Last Action: {}\n".format(debug_info, vars.actions[vars.actions.get_last_key()])
except:
pass
try:
debug_info = "{}Last Metadata: {}\n".format(debug_info, vars.actions_metadata[max(vars.actions_metadata)])
except:
pass
emit('from_server', {'cmd': 'debug_info', 'data': debug_info}, broadcast=True) emit('from_server', {'cmd': 'debug_info', 'data': debug_info}, broadcast=True)
#==================================================================# #==================================================================#