diff --git a/README.rst b/README.rst index 8114c15b..8196d908 100755 --- a/README.rst +++ b/README.rst @@ -14,13 +14,6 @@ SIERRA (reSearch pIpEline for Reproducibility, Reusability, and Automation) .. |linux-supported| image:: https://svgshare.com/i/Zhy.svg .. |osx-supported| image:: https://svgshare.com/i/ZjP.svg -.. - .. image:: https://img.shields.io/badge/python-3.8-blue.svg - :target: https://www.python.org/downloads/release/python-380/ - - .. image:: https://img.shields.io/badge/python-3.9-blue.svg - :target: https://www.python.org/downloads/release/python-390/ - .. |ci-integration-master| image:: https://github.com/jharwell/sierra/actions/workflows/integration-all.yml/badge.svg?branch=master .. |ci-analysis-master| image:: https://github.com/jharwell/sierra/actions/workflows/static-analysis.yml/badge.svg?branch=master .. |ci-coverage-master| image:: https://coveralls.io/repos/github/jharwell/sierra/badge.svg?branch=master diff --git a/docs/conf.py b/docs/conf.py index f3ffa7e3..23fc611c 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -51,7 +51,7 @@ 'xref', 'sphinx_last_updated_by_git', 'sphinx_rtd_theme', - 'sphinxcontrib.napoleon', + 'sphinx.ext.napoleon', 'autoapi.sphinx', 'sphinx.ext.autosummary'] diff --git a/setup.py b/setup.py index 65578565..fd798a52 100644 --- a/setup.py +++ b/setup.py @@ -88,6 +88,7 @@ "psutil", "distro", "netifaces", + "haggis", "coloredlogs", "implements", @@ -98,7 +99,7 @@ extras_require={ "devel": [ # checkers, CI, etc. - 'pylint', + 'pylint==2.14.5', # Temporarily, until the default 2.15.0 is fixed/superseded 'pytype', 'pydocstyle', 'xenon', diff --git a/sierra/core/logging.py b/sierra/core/logging.py index 5322ae01..b5e27501 100755 --- a/sierra/core/logging.py +++ b/sierra/core/logging.py @@ -28,25 +28,16 @@ # 3rd party packages import coloredlogs +from haggis import logs # Project packages -TRACE = logging.DEBUG - 5 - - -def initialize(log_level): - def log_for_level(self, message, *args, **kwargs): - if self.isEnabledFor(TRACE): - self._log(TRACE, message, args, **kwargs) - - def log_to_root(message, *args, **kwargs): - logging.log(TRACE, message, *args, **kwargs) - - logging.addLevelName(TRACE, "TRACE") - setattr(logging, "TRACE", TRACE) - setattr(logging.getLoggerClass(), "trace", log_for_level) - setattr(logging, "trace", log_to_root) +def initialize(log_level: str): + logs.add_logging_level(level_name='TRACE', + level_num=logging.DEBUG - 5, + method_name=None, + if_exists=logs.RAISE) # Needed for static analysis (mypy and/or pylint) setattr(logging, '_HAS_DYNAMIC_ATTRIBUTES', True) diff --git a/sierra/main.py b/sierra/main.py index 4cffc42b..732484e2 100755 --- a/sierra/main.py +++ b/sierra/main.py @@ -37,6 +37,8 @@ import sierra.core.startup import sierra.version +kIssuesURL = "https://github.com/jharwell/sierra/issues" + class SIERRA(): """Initialize SIERRA and then launch the pipeline.""" @@ -138,12 +140,31 @@ def __call__(self) -> None: sys.exit() +def excepthook(exc_type, exc_value, exc_traceback): + logging.fatal(("SIERRA has encountered an unexpected error and will now " + "terminate.\n\n" + "If you think this is a bug, please report it at:\n\n%s\n\n" + "When reporting, please include as much information as you " + "can. Ideally:\n\n" + "1. The below traceback.\n" + "2. The exact command you used to run sierra-cli.\n" + "3. sierra-cli's logging output in the terminal.\n\n" + "In some cases, creating a Minimum Working Example (MWE) " + "reproducing the error with specific input files and/or " + "data is also helpful for quick triage and fix.\n"), + kIssuesURL, + exc_info=(exc_type, exc_value, exc_traceback)) + + def main(): # Necessary on OSX, because python > 3.8 defaults to "spawn" which does not # copy loaded modules, which results in the singleton plugin managers not # working. mp.set_start_method("fork") + # Nice traceback on unexpected errors + sys.excepthook = excepthook + # Bootstrap the cmdline to print version if needed bootstrap = cmd.BootstrapCmdline() bootstrap_args, _ = bootstrap.parser.parse_known_args() diff --git a/sierra/version.py b/sierra/version.py index 7795d36a..b4c53636 100644 --- a/sierra/version.py +++ b/sierra/version.py @@ -20,4 +20,4 @@ # Project packages -__version__ = "1.2.22" +__version__ = "1.2.23" diff --git a/todo.org b/todo.org index d7820faa..fc953125 100644 --- a/todo.org +++ b/todo.org @@ -27,8 +27,8 @@ files. This will allow me to easily parameterize multiple versions of python, AND reduce the # of jobs I need/total workflow runtime on github by a good bit. -** TODO Switch from cmdopts dictionary to a data class with fields--I will get -WAY better help from the static analyzer +** TODO Switch from cmdopts dictionary to a data class with fields +I will get WAY better help from the static analyzer ** TODO Add quick quick start: a linux VM with SIERRA all set up and ready to go @@ -161,3 +161,9 @@ This really should be there.... And not require a valid --project to be passed. cohesion ** DONE Make bivariate inter-experiment heatmaps renderable into videos CLOSED: [2022-08-25 Thu 12:56] +** DONE Switch from my logging hack to haggis module +CLOSED: [2022-10-18 Tue 15:02] +Does what I do, but much better + +** DONE Add sys.excepthook hook asking the user to file a bug. +CLOSED: [2022-10-18 Tue 15:02]