Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/epmt/epmt_cmd_dbcare.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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()
Expand Down
1 change: 0 additions & 1 deletion src/epmt/epmt_cmd_help.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""
EPMT help command module - provides help functionality.
"""
# from __future__ import print_function
from inspect import signature
from sys import stderr

Expand Down
1 change: 0 additions & 1 deletion src/epmt/epmt_cmd_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/epmt/epmt_cmd_show.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
34 changes: 0 additions & 34 deletions src/epmt/epmt_concat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python3
'''
Data Flow:
Always Check for and Store comments
Expand All @@ -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
Expand Down Expand Up @@ -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)
5 changes: 0 additions & 5 deletions src/epmt/epmt_convert_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '')
2 changes: 1 addition & 1 deletion src/epmt/epmt_daemon.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
102 changes: 51 additions & 51 deletions src/epmt/epmt_rootcause.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 0 additions & 4 deletions src/epmt/epmtlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Loading