Skip to content

Commit

Permalink
More description fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
calebbiggers committed Sep 5, 2024
1 parent 68753ba commit 29a5031
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 12 deletions.
7 changes: 5 additions & 2 deletions scripts/config/replacements_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
"FREERUN_DRAM_ENERGY_STATUS":"power@energy\\-ram@",
"NUM_CPUS":"#num_cpus_online",
"UNC_PKG_ENERGY_STATUS":"power@energy\\-pkg@",
"UNC_DRAM_ENERGY_STATUS":"power@energy\\-ram@"
"UNC_DRAM_ENERGY_STATUS":"power@energy\\-ram@",
"INST_RETIRED.ANY_P:SUP":"INST_RETIRED.ANY_P:k",
"BR_INST_RETIRED.FAR_BRANCH:USER":"BR_INST_RETIRED.FAR_BRANCH:u"
},
"metric_source_events":{
"CHAS_PER_SOCKET":"UNC_CHA([^\\s]*)",
Expand All @@ -62,7 +64,8 @@
"events": ["UNC_CHA_"],
"unit":"cha",
"translations":{
"filter1":"config1"
"filter1":"config1",
"c":"thresh"
},
"scale":100000000
},
Expand Down
33 changes: 23 additions & 10 deletions scripts/perf_format_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ def convert_file(file_path):
return

# Deserialize input DB Json to dictionary
format_converter.deserialize_input()
print(f"Processing file: <{str(file_path.name)}>")
format_converter.deserialize_input()

format_converter.populate_issue_dict()

Expand Down Expand Up @@ -331,13 +331,17 @@ def get_public_description(self, metric):
"""
# Start with base description
description = metric["BriefDescription"].strip()

if not description.endswith("."):
description += ". "
else:
description += " "

# Add "Sample with:" blurb
if "LocateWith" in metric and metric["LocateWith"] != "":
events = metric["LocateWith"].split(";")
events = [event.strip() for event in events if event.strip() != "#NA"]
if len(events) >= 1:
description += f" Sample with: {", ".join(events)}" + "."
description += f"Sample with: {", ".join(events)}" + ". "

# Add "Related metrics:" blurb
related_metrics = []
Expand All @@ -350,13 +354,13 @@ def get_public_description(self, metric):
related_metrics = set([m for m in related_metrics if m != self.translate_metric_name(metric)])

if len(related_metrics) >= 1:
description += f" Related metrics: {", ".join(related_metrics)}" + "."
description += f"Related metrics: {", ".join(related_metrics)}" + ". "

# Make sure description is more than one sentence
if description.count(".") < 1:
elif description.count(". ") == 1 and description.endswith(". "):
return None

return description
return description.strip()

def get_brief_description(self, metric):
"""
Expand All @@ -366,14 +370,23 @@ def get_brief_description(self, metric):
@returns: string containing the shortened description
"""
# Start with base description
description = metric["BriefDescription"]
description = metric["BriefDescription"] + " "

# Sanitize
if "i.e." in description: # Special case if i.e. in description
description = description.replace("i.e.", "ie:")

# Get only first sentence
if "." in description:
return description.split(".")[0] + "."
if description.count(". ") > 1:
description = description.split(". ")[0] + ". "
elif description.count(". ") == 1 and description.strip().endswith("."):
description = description.strip()
elif description.count(". ") == 1 and not description.strip().endswith("."):
description = description.split(". ")[0] + ". "
else:
return description
description = description.strip() + "."

return description.replace("ie:", "i.e.").strip()

def translate_metric_name(self, metric):
"""
Expand Down

0 comments on commit 29a5031

Please sign in to comment.