robustify code with try/except constructions
[now a coding rule for new code]
-
as a user, it is not very nice to have to analyze a python backtrace to find what (s)he did wrong (e.g.: network component not running)
-> use the try/except construction everywhere
-> provide a helpfull message with the exception
-> make the try component as small as possible to provide the most adequate feedback to the user. Most of the code will be a suite of try/excepts blocks.
-> when a piece of code get an exception it should either deal with it (correct the issue itself) or propagate the exception to the above level
-> we may propagate some exceptions from the node to the researcher (specially during the training phase) -> write a logger.error() or logger.critical() above the raise in node/.py and common/.py
-> replace assert() by proper test/raise
-> maybe: provide a catalog of Exceptions (we already provide StrategyException, not sure we catch it)
list of files already refactored this way:
- common/constants (no need)
- common/exceptions (no need)
- common/logger.py
- common/environ.py
- common/message.py
- common/messaging.py
- common/repository [DOING/YB]
- common/taskqueue
- researcher/experiment.py