Commit 2e2c8c45 authored by Benjamin Schwenker's avatar Benjamin Schwenker
Browse files

making goReporter.py more robust against problems

parent edf7d4b7
......@@ -66,6 +66,7 @@ import sys
import glob
import subprocess
import logging
import traceback
from sklearn.model_selection import train_test_split
from path_explain import PathExplainerTF
import shutil
......@@ -291,17 +292,22 @@ def report_on_channel(
# Output path for plots
save_path = "./{}_plots".format(channel)
# Load the data, for training ONLY!
x, y, index = load_data_from_path(
config,
data_path=data_path,
start_time=train_times[0],
end_time=train_times[1],
downsample_fraction=0.33,
holdout_times=[])
# Load the data, for training ONLY!
try:
x, y, index = load_data_from_path(
config,
data_path=data_path,
start_time=train_times[0],
end_time=train_times[1],
downsample_fraction=0.33,
holdout_times=[]
)
except Exception as e:
logging.error(traceback.format_exc())
return
if x.size == 0:
logging.info('Error: No data for training found. Quit reporting on {}'.format(obs))
logging.error('Error: No data for training found. Quit reporting on {}'.format(obs))
return
# Make train test split
......@@ -464,14 +470,19 @@ def report_on_hitrate(
# Output path for plots
save_path = "./{}_plots".format(channel)
# Load the data, for training ONLY!
x, y, index = load_data_from_path(
config,
data_path=data_path,
start_time=train_times[0],
end_time=train_times[1],
downsample_fraction=0.33,
holdout_times=[])
# Load the data, for training ONLY!
try:
x, y, index = load_data_from_path(
config,
data_path=data_path,
start_time=train_times[0],
end_time=train_times[1],
downsample_fraction=0.33,
holdout_times=[])
except Exception as e:
logging.error(traceback.format_exc())
return
if x[0].size == 0:
logging.info('Error: No data for training found. Quit reporting on {}'.format(obs))
......@@ -1064,11 +1075,18 @@ def main():
attachments = []
for channel in channels:
file_name = get_jobname(shift=args.shift, channel=channel, report_day=start, tag=args.tag) + '.pdf'
attachments.append( os.path.join(args.report_path, file_name) )
file_path = os.path.join(args.report_path, file_name)
if Path(file_path).is_file():
attachments.append( file_path )
# Should guarantee fixed order of attachments in eLog entry
attachments = sorted(attachments)
if args.skbsrv_cred:
logging.info("Uploading reports to skbsrv server")
connectVPN = connect_vpn.ConnectVPN(cmd=args.vpn_cmd, cred_path=args.vpn_cred)
ReportsToWebServer(attachments, start, args.shift, args.skbsrv_cred, connectVPN).copy()
# Upload reports to the elog
if args.elog:
success = bg_net.report_to_elog.elog(
......@@ -1092,10 +1110,5 @@ def main():
else:
logging.info("Created reports: \n" + ", ".join(attachments))
if args.skbsrv_cred:
logging.info("Uploading reports to skbsrv server")
connectVPN = connect_vpn.ConnectVPN(cmd=args.vpn_cmd, cred_path=args.vpn_cred)
ReportsToWebServer(attachments, start, args.shift, args.skbsrv_cred, connectVPN).copy()
if __name__ == '__main__':
main()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment