Skip to content
Snippets Groups Projects
Commit af53be9f authored by René Schöne's avatar René Schöne
Browse files

Fix off-by-one error in merge_results

parent b869dca6
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python #!/usr/bin/env python
import argparse import argparse
import csv
import glob import glob
import json import json
import logging import logging
...@@ -51,11 +50,11 @@ def include_file_config(args): ...@@ -51,11 +50,11 @@ def include_file_config(args):
def create_link(fileToLink, linkName, dry_run): def create_link(fileToLink, linkName, dry_run):
(logger.info if args.dry_run else logger.debug)('Linking %s to %s', fileToLink, linkName)
if dry_run: if dry_run:
return return
if os.path.lexists(linkName): if os.path.lexists(linkName):
os.unlink(linkName) os.unlink(linkName)
(logger.info if args.dry_run else logger.debug)('Linking %s to %s', fileToLink, linkName)
os.symlink(fileToLink, linkName) os.symlink(fileToLink, linkName)
...@@ -89,6 +88,10 @@ def copy_replace(fileTocopy, all_runs_dir, tool_name, run, dry_run): ...@@ -89,6 +88,10 @@ def copy_replace(fileTocopy, all_runs_dir, tool_name, run, dry_run):
run_name = new_run_name(run) run_name = new_run_name(run)
targetFile = os.path.join( targetFile = os.path.join(
all_runs_dir, os.path.basename(fileTocopy).replace(tool_name, run_name)) all_runs_dir, os.path.basename(fileTocopy).replace(tool_name, run_name))
if dry_run:
logger.info('Would copy "%s" to "%s"', fileTocopy, targetFile)
return
logger.debug('Copying "%s" to "%s"', fileTocopy, targetFile)
first = True first = True
with open(fileTocopy) as fdr_source, open(targetFile, 'w') as fdr_target: with open(fileTocopy) as fdr_source, open(targetFile, 'w') as fdr_target:
for line in fdr_source: for line in fdr_source:
...@@ -130,15 +133,8 @@ def main(args): ...@@ -130,15 +133,8 @@ def main(args):
for dir_name in (merged_dir, merged_dir_benchmark, merged_dir_individual): for dir_name in (merged_dir, merged_dir_benchmark, merged_dir_individual):
ensure_directory(dir_name, args.dry_run) ensure_directory(dir_name, args.dry_run)
# Gathering tools # Using tools from config
tools = [] logger.debug('result_dir: %s, tools: %s', result_dir, args.tools)
reader = csv.reader(args.tools)
next(reader)
for row in reader:
if not row:
continue
tools.append(row[0])
logger.debug('result_dir: %s, tools: %s', result_dir, tools)
# Clean symlinks if requested or max_size is set # Clean symlinks if requested or max_size is set
if (args.clean or args.max_size) and not args.dry_run: if (args.clean or args.max_size) and not args.dry_run:
...@@ -152,7 +148,7 @@ def main(args): ...@@ -152,7 +148,7 @@ def main(args):
os.remove(linkName) os.remove(linkName)
# Merge results # Merge results
for tool in tools: for tool in args.tools:
if tool.startswith('#'): if tool.startswith('#'):
logger.debug('Ignoring tool "%s"', tool[1:]) logger.debug('Ignoring tool "%s"', tool[1:])
continue continue
...@@ -182,7 +178,7 @@ def main(args): ...@@ -182,7 +178,7 @@ def main(args):
ensure_directory(global_run_dir, args.dry_run) ensure_directory(global_run_dir, args.dry_run)
for csvFile in os.listdir(run_dir): for csvFile in os.listdir(run_dir):
# link file in run directory # link file in run directory
fileToLink = os.path.join(tool_dir, run, csvFile) fileToLink = os.path.join(run_dir, csvFile)
linkName = os.path.join(global_run_dir, csvFile) linkName = os.path.join(global_run_dir, csvFile)
create_link(fileToLink, linkName, args.dry_run) create_link(fileToLink, linkName, args.dry_run)
# skip if max-size is set and size is exceeded # skip if max-size is set and size is exceeded
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment