Skip to content

Commit

Permalink
Added flag for outputting TMA metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
calebbiggers committed Feb 14, 2025
1 parent 95d380b commit 96ac76e
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions scripts/perf_format_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,20 @@

def main():
# Get file pointers from args
arg_input_file = get_args()
arg_input_file, args_tma = get_args()

# Check that intput/output dirs exists
ensure_directories()

# Check for input file arg
if arg_input_file:
# If input file given, convert just input file
convert_file(arg_input_file)
convert_file(arg_input_file, args_tma)
else:
# If no input file, convert all files in input dir
glob = Path(FILE_PATH, INPUT_DIR_PATH).glob("*.json")
for file in glob:
convert_file(file)
convert_file(file, args_tma)

def ensure_directories():
# Check that intput/output dirs exists
Expand All @@ -63,7 +63,7 @@ def ensure_directories():
except IOError as e:
sys.exit(f"[ERROR] - Error setting up inpur/output dirs {str(e)}. Exiting")

def convert_file(file_path):
def convert_file(file_path, output_tma):
"""
Takes a standard json file and outputs a converted perf file
Expand All @@ -87,7 +87,7 @@ def convert_file(file_path):
format_converter.populate_issue_dict()

# Convert the dictionary to list of Perf format metric objects
perf_metrics = format_converter.convert_to_perf_metrics(platform)
perf_metrics = format_converter.convert_to_perf_metrics(platform, output_tma)
if not perf_metrics:
return

Expand All @@ -110,11 +110,13 @@ def get_args():
# Arguments
parser.add_argument("-i", "--finput", type=Path,
help="Path of input json file", required=False)

parser.add_argument("-t", "--tma", type=bool,
help="Output TMA metrics [true/false]", required=False)

# Get arguments
args = parser.parse_args()

return args.finput
return args.finput, args.tma


def get_output_file(path):
Expand Down Expand Up @@ -284,7 +286,7 @@ def populate_issue_dict(self):
else:
self.issue_dict[issue].append(self.translate_metric_name(metric))

def convert_to_perf_metrics(self, platform):
def convert_to_perf_metrics(self, platform, output_tma):
"""
Converts the json dictionary read into the script to a list of
metric objects in PERF format.
Expand All @@ -296,6 +298,11 @@ def convert_to_perf_metrics(self, platform):

try:
for metric in self.input_data["Metrics"]:
# Check if outputting TMA metrics
if not output_tma:
if "TMA" in metric["Category"]:
continue

# Add new metric object for each metric dictionary
new_metric = Metric(
public_description=self.get_public_description(metric),
Expand Down

0 comments on commit 96ac76e

Please sign in to comment.