diff --git a/src/epmt/epmt_cmd_dbcare.py b/src/epmt/epmt_cmd_dbcare.py index ba4075ab..f747bf34 100644 --- a/src/epmt/epmt_cmd_dbcare.py +++ b/src/epmt/epmt_cmd_dbcare.py @@ -24,8 +24,9 @@ def _get_dead_row_stats(): "ORDER BY relname" ) result = orm_raw_sql(sql) - rows = result.fetchall() - return rows + logger.debug('result = %s', result) + #logger.debug('type(result) = %s', type(result)) + return result def _vacuum_tables(): @@ -47,7 +48,9 @@ def _vacuum_tables(): 'last_vacuum=%s last_autovacuum=%s', row[0], row[1], row[2], row[3], row[4]) except Exception as e: - logger.warning('could not query dead row stats: %s', e) + logger.error('could not query dead row stats: %s', e) + raise Exception from e + # VACUUM requires autocommit — use a raw DBAPI connection raw_conn = engine.raw_connection() diff --git a/src/epmt/epmt_cmd_help.py b/src/epmt/epmt_cmd_help.py index 93168aba..5b5f98cf 100644 --- a/src/epmt/epmt_cmd_help.py +++ b/src/epmt/epmt_cmd_help.py @@ -1,7 +1,6 @@ """ EPMT help command module - provides help functionality. """ -# from __future__ import print_function from inspect import signature from sys import stderr diff --git a/src/epmt/epmt_cmd_list.py b/src/epmt/epmt_cmd_list.py index d8a2bc16..0865b09d 100644 --- a/src/epmt/epmt_cmd_list.py +++ b/src/epmt/epmt_cmd_list.py @@ -2,7 +2,6 @@ EPMT list command module - handles job listing functionality. """ -# from __future__ import print_function from sys import stderr from logging import getLogger diff --git a/src/epmt/epmt_cmd_show.py b/src/epmt/epmt_cmd_show.py index 2b95c45b..a4ca3800 100644 --- a/src/epmt/epmt_cmd_show.py +++ b/src/epmt/epmt_cmd_show.py @@ -2,12 +2,12 @@ EPMT show command module - handles job display functionality. """ -# from __future__ import print_function from logging import getLogger -logger = getLogger(__name__) import epmt.epmt_query as eq +logger = getLogger(__name__) + def epmt_show_job(jobid, key=None): if isinstance(jobid, list): jobid = jobid[0] diff --git a/src/epmt/epmt_concat.py b/src/epmt/epmt_concat.py index 958c627f..a3ca7b82 100755 --- a/src/epmt/epmt_concat.py +++ b/src/epmt/epmt_concat.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python3 ''' Data Flow: Always Check for and Store comments @@ -18,7 +17,6 @@ Jobid: `goodSample_123` ''' -from __future__ import unicode_literals from epmt.epmtlib import epmt_logging_init, logfn from sys import exit as sysexit @@ -375,35 +373,3 @@ def csvjoiner(indir, return False, None, badfiles_renamed -if __name__ == '__main__': - # inl: remove this entry point? - from argparse import ArgumentParser - parser = ArgumentParser(description="Concatenate CSV files. It returns 0 on success and < 0 on error") - parser.add_argument( - 'files', nargs='+', metavar='FILE', - help='Two or more CSV files to concatenate OR a directory containing CSV files') - parser.add_argument( - '-v', '--verbose', - action="count", - default=0, - help="increase verbosity") - parser.add_argument( - '-o', '--output-file', - help="Name of the output file, determined from input if not specified", - default='') - parser.add_argument( - '-e', '--error', - action='store_true', - help="Exit at the first sign of trouble", - default=False) - parser.add_argument( - '-E', '--error-dir', - help="Name of the directory to save files with errors, disabled if not specified", - default='') - args = parser.parse_args() - retval, of, bf = csvjoiner(debug=args.verbose, - indir=(args.files[0] if len(args.files) == 1 else args.files), - outfile=args.output_file, - keep_going=not args.error, - errdir=args.error_dir) - sysexit(0 if retval else -1) diff --git a/src/epmt/epmt_convert_csv.py b/src/epmt/epmt_convert_csv.py index 1966a955..5ed42526 100755 --- a/src/epmt/epmt_convert_csv.py +++ b/src/epmt/epmt_convert_csv.py @@ -384,8 +384,3 @@ def extract_jobid_from_collated_csv(collated_csv): ''' return collated_csv.split('papiex')[-1].split('-')[1] - -if __name__ == "__main__": - import sys - epmt_logging_init(intlvl=2) - convert_csv_in_tar(sys.argv[1], sys.argv[2] if len(sys.argv) > 2 else '') diff --git a/src/epmt/epmt_daemon.py b/src/epmt/epmt_daemon.py index 6374185e..995dec35 100644 --- a/src/epmt/epmt_daemon.py +++ b/src/epmt/epmt_daemon.py @@ -1,7 +1,7 @@ """ EPMT daemon module - handles background daemon functionality. """ -# from __future__ import print_function + from getpass import getuser from os import path, kill, unlink, getppid from sys import exit as sysexit diff --git a/src/epmt/epmt_rootcause.py b/src/epmt/epmt_rootcause.py index 5d011788..ff488e03 100644 --- a/src/epmt/epmt_rootcause.py +++ b/src/epmt/epmt_rootcause.py @@ -88,57 +88,57 @@ def rootcause(ref, input, features, methods=[rootcause_zscore]): return False, None, None -if __name__ == "__main__": - # Synthesize 10 feature names - n_features = 6 - features = [f'{x:c}' for x in range(97, 97 + n_features)] - print("Features:\n", features) +#if __name__ == "__main__": +# # Synthesize 10 feature names +# n_features = 6 +# features = [f'{x:c}' for x in range(97, 97 + n_features)] +# print("Features:\n", features) - def multiple(): - ''' - Check with multiple outliers - Narrow range of reference values - ''' - np.random.seed(104) - random_reference_df = pd.DataFrame(np.random.randint(50, 100, size=(100, n_features)), columns=features) - print("Reference:\n", random_reference_df.head()) - # Wider range input values for test set - random_input_df = pd.DataFrame(np.random.randint(25, 125, size=(1, n_features)), columns=features) - print("Input:\n", random_input_df.head()) - retval, df, dct = rootcause(random_reference_df, random_input_df, features) - print("Retval:\n", retval) - print("Result:\n", df) - print("Result:\n", dct) +def ex_multiple(features, n_features): + ''' + Check with multiple outliers + Narrow range of reference values + ''' + np.random.seed(104) + random_reference_df = pd.DataFrame(np.random.randint(50, 100, size=(100, n_features)), columns=features) + print("Reference:\n", random_reference_df.head()) + # Wider range input values for test set + random_input_df = pd.DataFrame(np.random.randint(25, 125, size=(1, n_features)), columns=features) + print("Input:\n", random_input_df.head()) + retval, df, dct = rootcause(random_reference_df, random_input_df, features) + print("Retval:\n", retval) + print("Result:\n", df) + print("Result:\n", dct) - def none(): - ''' - Check with no outliers - Narrow range of reference values - ''' - np.random.seed(103) - random_reference_df = pd.DataFrame(np.random.randint(50, 100, size=(100, n_features)), columns=features) - print("Reference:\n", random_reference_df.head()) - # Wider range input values for test set - random_input_df = pd.DataFrame(np.random.randint(25, 125, size=(1, n_features)), columns=features) - print("Input:\n", random_input_df.head()) - retval, df, dct = rootcause(random_reference_df, random_input_df, features) - print("Retval:\n", retval) - print("Result:\n", df) - print("Result:\n", dct) +def ex_none(features, n_features): + ''' + Check with no outliers + Narrow range of reference values + ''' + np.random.seed(103) + random_reference_df = pd.DataFrame(np.random.randint(50, 100, size=(100, n_features)), columns=features) + print("Reference:\n", random_reference_df.head()) + # Wider range input values for test set + random_input_df = pd.DataFrame(np.random.randint(25, 125, size=(1, n_features)), columns=features) + print("Input:\n", random_input_df.head()) + retval, df, dct = rootcause(random_reference_df, random_input_df, features) + print("Retval:\n", retval) + print("Result:\n", df) + print("Result:\n", dct) + +def ex_one(features, n_features): + ''' + Check with one outlier + Narrow range of reference values + ''' + np.random.seed(102) + random_reference_df = pd.DataFrame(np.random.randint(50, 100, size=(100, n_features)), columns=features) + print("Reference:\n", random_reference_df.head()) + # Wider range input values for test set + random_input_df = pd.DataFrame(np.random.randint(25, 125, size=(1, n_features)), columns=features) + print("Input:\n", random_input_df.head()) + retval, df, dct = rca(random_reference_df, random_input_df, features) + print("Retval:\n", retval) + print("Result:\n", df) + print("Result:\n", dct) - def one(): - ''' - Check with one outlier - Narrow range of reference values - ''' - np.random.seed(102) - random_reference_df = pd.DataFrame(np.random.randint(50, 100, size=(100, n_features)), columns=features) - print("Reference:\n", random_reference_df.head()) - # Wider range input values for test set - random_input_df = pd.DataFrame(np.random.randint(25, 125, size=(1, n_features)), columns=features) - print("Input:\n", random_input_df.head()) - retval, df, dct = rca(random_reference_df, random_input_df, features) - print("Retval:\n", retval) - print("Result:\n", df) - print("Result:\n", dct) - one() diff --git a/src/epmt/epmtlib.py b/src/epmt/epmtlib.py index 4996f459..9e39288e 100644 --- a/src/epmt/epmtlib.py +++ b/src/epmt/epmtlib.py @@ -1224,7 +1224,3 @@ def set_signal_handlers(signals=[], handler=None): logger.debug('Finished restoring signal handlers to defaults') else: logger.debug('Finished setting up signal handlers') - - -if __name__ == "__main__": - print(version_str(True))