def test_set_multiple_loglevels(self): print('isEnabledFor(logging.DEBUG) is False with ' 'CapiceManager().critical_logging_only set to True') self.manager.critical_logging_only = True self.manager.loglevel = 10 log = Logger().logger self.assertFalse(log.isEnabledFor(logging.DEBUG))
def __init__(self, model): """ :param model: XGBClassifier, the custom pickled model instance of user provided model. """ self.log = Logger().logger self.model = model self.log.info('Starting prediction.')
def __init__(self, impute_values: dict): """ :param impute_values: dict, Dictionary containing all features to be imputed as keys and the fill value as value. Can come from either the model or a loaded json. """ self.log = Logger().logger self.log.info('Imputer started.') self.impute_values = impute_values self.pre_dtypes = {} self.dtypes = {}
def capture_stderr_call(self): old_stderr = sys.stderr listener = io.StringIO() sys.stderr = listener log = Logger().logger log.critical('SomeString') log.error('SomeString') out = listener.getvalue() sys.stderr = old_stderr self.assertGreater(len(out), 0) return out
def capture_stdout_call(self): old_stdout = sys.stdout listener = io.StringIO() sys.stdout = listener log = Logger().logger log.info('SomeString') log.debug('SomeString') out = listener.getvalue() sys.stdout = old_stdout self.assertGreater(len(out), 0) return out
def __init__(self, file_path, output_given): self.log = Logger().logger self.capice_filename = CapiceManager().output_filename self.file_path = file_path self.output_given = output_given self.export_cols = [ Column.chr.value, Column.pos.value, Column.ref.value, Column.alt.value, Column.gene_name.value, Column.gene_id.value, Column.id_source.value, Column.feature.value, Column.feature_type.value, Column.score.value, Column.suggested_class.value ]
def test_stdout(self): print('Levels WARNING, ERROR and CRITICAL not present in stdout') old_stdout = sys.stdout listener = io.StringIO() sys.stdout = listener log = Logger().logger log.warning(self.not_present_string) log.error(self.not_present_string) log.critical(self.not_present_string) out = listener.getvalue() sys.stdout = old_stdout self.assertNotIn(self.not_present_string, out)
def test_stderr(self): print('Levels INFO and DEBUG not present in stderr') self.manager.loglevel = 10 old_stderr = sys.stderr listener = io.StringIO() sys.stderr = listener log = Logger().logger log.info(self.not_present_string) log.debug(self.not_present_string) out = listener.getvalue() sys.stderr = old_stderr self.assertNotIn(self.not_present_string, out)
def __init__(self, required_attributes: list, path): """ Dynamic Loader for both the imputer and preprocessor :param required_attributes: list, list containing all the required attritubes the loaded modules have to have. :param path: Path-like, path to the potential modules. Use `load_impute_preprocess_modules()` to load the modules required for the imputer and preprocessor. Use `load_manual_annotators()` to load the manual VEP annotation processors. """ self.log = Logger().logger self.path = path self._check_dir_exists() self.required_attributes = required_attributes self.modules = {}
def __init__(self, exclude_features: list, model_features: list = None): """ :param exclude_features: list, all the features that the preprocessor should not process. Features that are already excluded include: chr_pos_ref_alt, chr and pos. :param model_features: list (default None), a list containing all the features present within a model file. """ self.log = Logger().logger self.manager = CapiceManager() self.log.info('Preprocessor started.') self.train = False self.exclude_features = [ Column.chr_pos_ref_alt.value, Column.chr.value, Column.pos.value ] self.exclude_features += exclude_features self.model_features = model_features self.objects = []
def __init__(self, input_path, output_path, output_given): # Assumes CapiceManager has been initialized & filled. self.manager = CapiceManager() self.log = Logger().logger self.log.info('Initiating selected mode.') # Input file. self.infile = input_path self.log.debug('Input argument -i / --input confirmed: %s', self.infile) # Output file. self.output = output_path self.log.debug('Output directory -o / --output confirmed: %s', self.output) self.output_given = output_given # Preprocessor global exclusion features # Overwrite in specific module if features are incorrect self.exclude_features = [Column.gene_name.value, Column.gene_id.value, Column.id_source.value, Column.feature.value, Column.feature_type.value]
def __init__(self): super(Consequence, self).__init__( name='Consequence', usable=True ) self.log = Logger().logger
def test_isenabled_true_debug(self): print('isEnabledFor(logging.DEBUG) is True') self.manager.loglevel = 10 log = Logger().logger self.assertTrue(log.isEnabledFor(logging.DEBUG))
def __init__(self, dataset: pd.DataFrame): self.log = Logger().logger self.dataset = dataset
def __init__(self, model, output_path, output_given): super().__init__(input_path=None, output_path=output_path, output_given=output_given) self.model = model self.output = output_path self.log = Logger().logger
def __init__(self): self.log = Logger().logger
def test_logger_class(self): print('Logger class') self.assertEqual(str(Logger().logger.__class__), "<class 'logging.RootLogger'>")
def test_isenbaled_false_debug(self): print('isEnabledFor(logging.DEBUG) is False') self.manager.loglevel = 20 log = Logger().logger self.assertFalse(log.isEnabledFor(logging.DEBUG))
def __init__(self): self.log = Logger().logger self.sep = '\t'
def test_isenabled_false_warning(self): print('isEnabledFor(logging.WARNING) is False') self.manager.critical_logging_only = True log = Logger().logger self.assertFalse(log.isEnabledFor(logging.WARNING))
def __init__(self, model): self.model = model self.log = Logger().logger
def test_isenabled_true_warning(self): print('isEnabledFor(logging.WARNING) is True') log = Logger().logger self.assertTrue(log.isEnabledFor(logging.WARNING)) self.assertFalse(log.isEnabledFor(logging.INFO))