From 768cd68c9fa6ea7f99c61905223f9cf155c7c595 Mon Sep 17 00:00:00 2001 From: Karim Ahmed <karim.ahmed@xfel.eu> Date: Mon, 2 Sep 2019 10:58:39 +0200 Subject: [PATCH] write yaml after req --- reportservice/report_service.py | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/reportservice/report_service.py b/reportservice/report_service.py index 21a787099..e8f13929f 100644 --- a/reportservice/report_service.py +++ b/reportservice/report_service.py @@ -173,12 +173,6 @@ async def server_runner(conf_file): await socket.send_pyobj('Build DC reports through -->') logging.info("response: {}".format(response)) - # Send the conf.yaml file after receiving a zmq-req. - asyncio.ensure_future(copy_files(conf_file, - config['GLOBAL']['git'] - ['figures-local'], - sem=None)) - # Check if response is a list or a dict. # if list, it should either have instrument names or ['all']. # if dict, it should acquires the details of the requested reports @@ -206,17 +200,21 @@ async def server_runner(conf_file): continue logging.info('Requested Configuration: {}'.format(req_cfg)) - + + # Write the requested req-cfg.yaml file after receiving a zmq-req. + fig_local = '{}/figures'.format(req_cfg['GLOBAL']['git']['repo-local'] + ) + + with open('{}/report_config.yaml'.format(fig_local), 'w') as outfile: + yaml.dump(req_cfg, outfile, default_flow_style=False) + async def do_action(cfg): logging.info('Run plot production') jobs_timeout = cfg['GLOBAL']['report-service'].get('job-timeout', 3600) all_new_files = [] - all_new_files.append('{}/{}'.format(config['GLOBAL'] - ['git'] - ['figures-local'], - conf_file.split('/')[-1])) + all_new_files.append('{}/report_config.yaml'.format(fig_local)) for instr_name, instrument in cfg.items(): @@ -271,19 +269,19 @@ async def server_runner(conf_file): out_folder = det_conf['out-folder'].format( instrument=instr_name, detector=det_name) - path = cfg['GLOBAL']['git']['figures-local'] + figures = glob.glob("{}/*png".format(out_folder)) det_new_files = {} for f in figures: const = f.split('/')[-1].split('_')[0] - fpath = '{}/{}/{}/{}'.format(path, instr_name, - det_name, const) + fpath = '{}/{}/{}/{}'.format(fig_local, instr_name, + det_name, const) os.makedirs(fpath, exist_ok=True) det_new_files[f] = fpath - + # Set concurrency limitation. # 50 have been chosen by trial # Note: This is not the max limitation. @@ -295,7 +293,7 @@ async def server_runner(conf_file): for k, v in det_new_files.items()]) logging.info('{} figures of {} are copied into {}'.format( - len(figures), det_name, path)) + len(figures), det_name, fig_local)) asyncio.ensure_future( push_figures(cfg['GLOBAL']['git']['repo-local'], all_new_files)) @@ -304,7 +302,6 @@ async def server_runner(conf_file): # asyncio.ensure_future(del_folder(out_folder)) #except: #logging.error(str(e)) - logging.info('All done') return -- GitLab