Commit e821008a authored by Joanne Hugé's avatar Joanne Hugé

Update measure-analysis script

Allow user to import metadata from a file instead
parent 85bef512
......@@ -63,7 +63,7 @@ class MeasureSetHandler:
with open(MeasureSetHandler.measure_sets_path, 'w') as measure_sets_file:
json.dump(self.measure_sets, measure_sets_file)
def import_from_json(self, path, flat=False, cyclictest=False, user_input=False):
def import_from_json(self, path, flat=False, cyclictest=False, user_input=False, file_input=None):
measure_sets = []
......@@ -74,11 +74,18 @@ class MeasureSetHandler:
else:
data = json.load(infile)
if file_input != None:
with open(file_input) as metadata_file:
metadata = json.load(metadata_file)
for measure_set_data in data['measure_sets']:
measure_set = MeasureSet()
measure_set.import_from_json_data(measure_set_data, flat=flat, user_input=user_input)
if file_input != None:
measure_set.update_metadata(metadata, []);
measure_sets.append(measure_set)
return measure_sets
......@@ -677,6 +684,7 @@ def parse_args():
parser = argparse.ArgumentParser(description='Measure analysis')
parser.add_argument('-i', nargs=1, required=False, help='import file')
parser.add_argument('-c', action='store_true', required=False, help='parse cyclictest histogram')
parser.add_argument('-I', nargs=1, required=False, help='import metadata file')
parser.add_argument('--remove', nargs=1, required=False, help='remove a measure')
parser.add_argument('--remove-type', nargs=1, required=False, help='remove all measures from a type')
parser.add_argument('--remove-all', action='store_true', help='remove all measure sets')
......@@ -712,10 +720,17 @@ def parse_args():
if args.i is not None:
if args.I is not None:
file_input = args.I[0]
user_input = False
else:
file_input = None
user_input = True
if args.c:
measure_sets = ms_handler.import_from_json(args.i[0], cyclictest=True, user_input=True)
measure_sets = ms_handler.import_from_json(args.i[0], cyclictest=True, user_input=user_input, file_input=file_input)
else:
measure_sets = ms_handler.import_from_json(args.i[0], flat=True, user_input=True)
measure_sets = ms_handler.import_from_json(args.i[0], flat=True, user_input=user_input, file_input=file_input)
for measure_set in measure_sets:
ms_handler.add_measure_set(measure_set)
......
Markdown is supported
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