From 56ce88ad31dec3cece63e9370ca4e4c02139753b Mon Sep 17 00:00:00 2001 From: Alexander Kabui Date: Tue, 16 Mar 2021 11:38:13 +0300 Subject: delete unwanted correlation stuff (#5) * delete unwanted correlation stuff * Refactor/clean up correlations (#4) * initial commit for Refactor/clean-up-correlation * add python scipy dependency * initial commit for sample correlation * initial commit for sample correlation endpoint * initial commit for integration and unittest * initial commit for registering correlation blueprint * add and modify unittest and integration tests for correlation * Add compute compute_all_sample_corr method for correlation * add scipy to requirement txt file * add tissue correlation for trait list * add unittest for tissue correlation * add lit correlation for trait list * add unittests for lit correlation for trait list * modify lit correlarion for trait list * add unittests for lit correlation for trait list * add correlation metho in dynamic url * add file format for expected structure input while doing sample correlation * modify input data structure -> add trait id * update tests for sample r correlation * add compute all lit correlation method * add endpoint for computing lit_corr * add unit and integration tests for computing lit corr * add /api/correlation/tissue_corr/{corr_method} endpoint for tissue correlation * add unittest and integration tests for tissue correlation Co-authored-by: BonfaceKilz * update guix scm file * fix pylint error for correlations api Co-authored-by: BonfaceKilz --- gn3/utility/logger.py | 163 -------------------------------------------------- 1 file changed, 163 deletions(-) delete mode 100644 gn3/utility/logger.py (limited to 'gn3/utility/logger.py') diff --git a/gn3/utility/logger.py b/gn3/utility/logger.py deleted file mode 100644 index 4245a02..0000000 --- a/gn3/utility/logger.py +++ /dev/null @@ -1,163 +0,0 @@ -""" -# GeneNetwork logger -# -# The standard python logging module is very good. This logger adds a -# few facilities on top of that. Main one being that it picks up -# settings for log levels (global and by module) and (potentially) -# offers some fine grained log levels for the standard levels. -# -# All behaviour is defined here. Global settings (defined in -# default_settings.py). -# -# To use logging and settings put this at the top of a module: -# -# import utility.logger -# logger = utility.logger.getLogger(__name__ ) -# -# To override global behaviour set the LOG_LEVEL in default_settings.py -# or use an environment variable, e.g. -# -# env LOG_LEVEL=INFO ./bin/genenetwork2 -# -# To override log level for a module replace that with, for example, -# -# import logging -# import utility.logger -# logger = utility.logger.getLogger(__name__,level=logging.DEBUG) -# -# We'll add more overrides soon. -""" -# todo incomplete file - -# pylint: disable-all -import logging -import datetime -from inspect import isfunction -from inspect import stack - -from pprint import pformat as pf - - -# from utility.tools import LOG_LEVEL, LOG_LEVEL_DEBUG, LOG_SQL - -LOG_SQL = True - - -class GNLogger: - """A logger class with some additional functionality, such as - multiple parameter logging, SQL logging, timing, colors, and lazy - functions. - - """ - - def __init__(self, name): - self.logger = logging.getLogger(name) - - def setLevel(self, value): - """Set the undelying log level""" - self.logger.setLevel(value) - - def debug(self, *args): - """Call logging.debug for multiple args. Use (lazy) debugf and -level=num to filter on LOG_LEVEL_DEBUG. - - """ - self.collect(self.logger.debug, *args) - - def debug20(self, *args): - """Call logging.debug for multiple args. Use level=num to filter on -LOG_LEVEL_DEBUG (NYI). - - """ - if level <= LOG_LEVEL_DEBUG: - if self.logger.getEffectiveLevel() < 20: - self.collect(self.logger.debug, *args) - - def info(self, *args): - """Call logging.info for multiple args""" - self.collect(self.logger.info, *args) - - def warning(self, *args): - """Call logging.warning for multiple args""" - self.collect(self.logger.warning, *args) - # self.logger.warning(self.collect(*args)) - - def error(self, *args): - """Call logging.error for multiple args""" - now = datetime.datetime.utcnow() - time_str = now.strftime('%H:%M:%S UTC %Y%m%d') - l = [time_str]+list(args) - self.collect(self.logger.error, *l) - - def infof(self, *args): - """Call logging.info for multiple args lazily""" - # only evaluate function when logging - if self.logger.getEffectiveLevel() < 30: - self.collectf(self.logger.debug, *args) - - def debugf(self, level=0, *args): - """Call logging.debug for multiple args lazily and handle - LOG_LEVEL_DEBUG correctly - - """ - # only evaluate function when logging - if level <= LOG_LEVEL_DEBUG: - if self.logger.getEffectiveLevel() < 20: - self.collectf(self.logger.debug, *args) - - def sql(self, sqlcommand, fun=None): - """Log SQL command, optionally invoking a timed fun""" - if LOG_SQL: - caller = stack()[1][3] - if caller in ['fetchone', 'fetch1', 'fetchall']: - caller = stack()[2][3] - self.info(caller, sqlcommand) - if fun: - result = fun(sqlcommand) - if LOG_SQL: - self.info(result) - return result - - def collect(self, fun, *args): - """Collect arguments and use fun to output""" - out = "."+stack()[2][3] - for a in args: - if len(out) > 1: - out += ": " - if isinstance(a, str): - out = out + a - else: - out = out + pf(a, width=160) - fun(out) - - def collectf(self, fun, *args): - """Collect arguments and use fun to output one by one""" - out = "."+stack()[2][3] - for a in args: - if len(out) > 1: - out += ": " - if isfunction(a): - out += a() - else: - if isinstance(a, str): - out = out + a - else: - out = out + pf(a, width=160) - fun(out) - -# Get the module logger. You can override log levels at the -# module level - - -def getLogger(name, level=None): - """method to get logger""" - gnlogger = GNLogger(name) - _logger = gnlogger.logger - - # if level: - # logger.setLevel(level) - # else: - # logger.setLevel(LOG_LEVEL) - - # logger.info("Log level of "+name+" set to "+logging.getLevelName(logger.getEffectiveLevel())) - return gnlogger -- cgit v1.2.3