Skip to content

Commit 68da481

Browse files
authored
Fixing the output directory creation (#487)
1 parent b8de373 commit 68da481

2 files changed

Lines changed: 16 additions & 20 deletions

File tree

python/run_analysis.py

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -385,33 +385,30 @@ def run_stages(args, rdf_module, anapath):
385385
output_filepath = None
386386
output_dir = os.path.join(output_dir, output_stem)
387387

388-
info_msg = f'Adding process "{process_name}" with:'
388+
info_msg = f'Will run over process "{process_name}" with:'
389389
if fraction < 1:
390-
info_msg += f'\n\t- fraction: {fraction}'
391-
info_msg += f'\n\t- number of files: {len(file_list):,}'
390+
info_msg += f'\n - fraction: {fraction}'
391+
info_msg += f'\n - number of input files: {len(file_list):,}'
392392
if output_dir:
393-
info_msg += f'\n\t- output directory: {output_dir}'
393+
info_msg += f'\n - output directory: {output_dir}'
394394
if output_filepath:
395-
info_msg += f'\n\t- output file path: {output_dir}'
395+
info_msg += f'\n - output file path: {output_filepath}'
396396
if len(chunk_list) > 1:
397-
info_msg += f'\n\t- number of chunks: {chunks}'
398-
399-
# Create directory if more than 1 chunk
400-
if len(chunk_list) > 1:
401-
output_directory = os.path.join(output_dir, output_stem)
402-
403-
if not os.path.exists(output_directory):
404-
os.system(f'mkdir -p {output_directory}')
397+
info_msg += f'\n - number of output chunks: {chunks}'
398+
LOGGER.info(info_msg)
405399

406400
# Running locally
407401
LOGGER.info('Running locally...')
408402
if len(chunk_list) == 1:
409403
args.output = output_filepath
410404
run_local(rdf_module, chunk_list[0], args)
411405
else:
406+
# Create directory if more than 1 chunk
407+
if not os.path.exists(output_dir):
408+
os.system(f'mkdir -p {output_dir}')
409+
412410
for index, chunk in enumerate(chunk_list):
413-
args.output = os.path.join(output_directory,
414-
f'chunk{index}.root')
411+
args.output = os.path.join(output_dir, f'chunk{index}.root')
415412
run_local(rdf_module, chunk, args)
416413

417414

python/run_fccanalysis.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -583,17 +583,16 @@ def run_fccanalysis(args, analysis_module):
583583
info_msg += f'\n - output file path: {output_filepath}'
584584
LOGGER.info(info_msg)
585585

586-
# Create directory if more than 1 chunk
587-
if n_chunks > 1:
588-
if not os.path.exists(output_dir):
589-
os.system(f'mkdir -p {output_dir}')
590-
591586
# Running locally
592587
LOGGER.info('Running locally...')
593588
if n_chunks == 1:
594589
args.output = output_filepath
595590
run_local(config, args, analysis, chunk_list[0])
596591
else:
592+
# Create directory if more than 1 chunk
593+
if not os.path.exists(output_dir):
594+
os.system(f'mkdir -p {output_dir}')
595+
597596
for index, chunk in enumerate(chunk_list):
598597
args.output = f'{output_dir}/chunk{index}.root'
599598
run_local(config, args, analysis, chunk)

0 commit comments

Comments
 (0)