Commit f2f3d269 authored by Baptiste CHOCOT's avatar Baptiste CHOCOT Committed by Jonathan Fiscus
Browse files

Bare excepts & Ctrl-C fixing

parent dcb64834
......@@ -97,7 +97,10 @@ class ActevCommand():
logging.info("%s done" % self.command)
StatusFactory.generate_status(self, 'done', args.__dict__)
except:
except KeyboardInterrupt:
logging.info("Ctrl-C detected. Exiting.")
sys.exit(0)
except Exception:
logging.exception("Issue during %s" % self.command)
StatusFactory.generate_status(self, 'issue', args.__dict__)
sys.exit(1)
......
......@@ -15,9 +15,15 @@ def entry_point():
path = os.path.dirname(__file__)
script = os.path.join(path, '../implementation/clear_logs/clear_logs.sh')
# execute the script
# status is the exit status code returned by the program
# status is a 16-bit long integer
# The 8 strongest bits are exit_code
# The 8 weakest bits are signal_number
status = os.system(script)
exit_code = status >> 8
signal_number = status & (2**8 - 1)
if status != 0:
raise Exception("Error occured in clear_logs.sh")
if signal_number == 2: # SIGINT
raise KeyboardInterrupt
else:
raise Exception("Error occured in clear_logs.sh")
......@@ -26,7 +26,7 @@ def entry_point(url, system_type, location=None, user=None, password=None, token
try:
command = system_types[system_type]()
script = command.entry_point
except:
except KeyError:
raise Exception("Unknown system type")
# Init the actev_cli_environemnt variables
......@@ -84,8 +84,14 @@ def entry_point(url, system_type, location=None, user=None, password=None, token
" " + sha + \
" " + name
# execute the script
# status is the exit status code returned by the program
# status is a 16-bit long integer
# The 8 strongest bits are exit_code
# The 8 weakest bits are signal_number
status = os.system(script)
exit_code = status >> 8
signal_number = status & (2**8 - 1)
if status != 0:
raise Exception("Error occured in %s" % command.entry_point)
if signal_number == 2: # SIGINT
raise KeyboardInterrupt
else:
raise Exception("Error occured in %s (error code: %d)" % (command.entry_point, exit_code))
......@@ -38,12 +38,18 @@ def entry_point(output, reference, activity_index, file_index, result, score):
if not result and score:
raise Exception("Please provide a -R option when using --score")
# execute the script
# status is the exit status code returned by the program
# status is a 16-bit long integer
# The 8 strongest bits are exit_code
# The 8 weakest bits are signal_number
cmd = 'cd ' + execution_validation_dir + ';' + ' . ' + installation_script + ';' + scoring_cmd
status = os.system(cmd)
exit_code = status >> 8
signal_number = status & (2**8 - 1)
if status != 0:
raise Exception("Error occured in install.sh or score.sh")
if signal_number == 2: # SIGINT
raise KeyboardInterrupt
else:
raise Exception("Error occured in install.sh or score.sh")
# If the system output is scored, make it also check the alignments
# Produced by the scorer. This is a reproducibility check made to compare
......
......@@ -45,14 +45,20 @@ output, chunk_result):
pre_process_chunk(chunk_id, system_cache_dir)
process_chunk(chunk_id, system_cache_dir)
post_process_chunk(chunk_id, system_cache_dir)
except:
except KeyboardInterrupt:
experiment_cleanup(system_cache_dir)
raise KeyboardInterrupt
except Exception:
reset_chunk(chunk_id, system_cache_dir)
continue
merge_chunks(system_cache_dir, output, chunk_result, None)
experiment_cleanup(system_cache_dir)
except:
except KeyboardInterrupt:
experiment_cleanup(system_cache_dir)
raise KeyboardInterrupt
except Exception:
experiment_cleanup(system_cache_dir)
raise Exception
......
......@@ -32,7 +32,7 @@ class StatusFactory():
if command in public_subcommands:
json_command_states['id'] += 1
json_command_states[command.command].append({'status': status, 'id': json_command_states['id'], 'args': args})
except:
except (json.JSONDecodeError, KeyError):
logging.warning("Status monitoring improperly terminated: status reset")
os.remove(command_states_log)
......
......@@ -74,7 +74,7 @@ def validate_cli(strict):
# Is entry point exist
try:
entry_point_module = importlib.import_module('diva_evaluation_cli.src.entry_points.{}'.format(actev_command))
except:
except ModuleNotFoundError:
handle_error("{} entry_point method removed".format(actev_command), strict)
entry_point_function = getattr(entry_point_module, 'entry_point')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment