[rocprofiler-compute] Refactor to add type annotation and misc (#787)
此提交包含在:
@@ -42,17 +42,15 @@ import yaml
|
||||
|
||||
# Get root directory of the project
|
||||
ROOT_DIR = Path(__file__).parent.parent
|
||||
SOURCE_DIR = ROOT_DIR.joinpath("utils")
|
||||
TARGET_DIR = ROOT_DIR.joinpath("src", "rocprof_compute_soc", "analysis_configs")
|
||||
SETS_TARGET_DIR = ROOT_DIR.joinpath(
|
||||
"src", "rocprof_compute_soc", "profile_configs", "sets"
|
||||
)
|
||||
DOC_TARGET_DIR = ROOT_DIR.joinpath("docs", "data")
|
||||
SOURCE_DIR = ROOT_DIR / "utils"
|
||||
TARGET_DIR = ROOT_DIR / "src" / "rocprof_compute_soc" / "analysis_configs"
|
||||
SETS_TARGET_DIR = ROOT_DIR / "src" / "rocprof_compute_soc" / "profile_configs" / "sets"
|
||||
DOC_TARGET_DIR = ROOT_DIR / "docs" / "data"
|
||||
AUTOGEN_TEXT = (
|
||||
"# AUTOGENERATED FILE. Only edit for testing purposes, not for development. "
|
||||
"Generated from utils/unified_config.yaml. Generated by utils/split_config.py\n"
|
||||
)
|
||||
HASH_FILE = ROOT_DIR.joinpath("utils", "autogen_hash.yaml")
|
||||
HASH_FILE = ROOT_DIR / "utils" / "autogen_hash.yaml"
|
||||
HASH_FILE_MAP = {}
|
||||
GFX_VERSIONS = ["gfx908", "gfx90a", "gfx940", "gfx941", "gfx942", "gfx950"]
|
||||
METRIC_ID_TO_NAME_MAP = {gfx_version: {} for gfx_version in GFX_VERSIONS}
|
||||
@@ -70,7 +68,7 @@ def update_analysis_config():
|
||||
global METRIC_ID_TO_NAME_MAP
|
||||
|
||||
# Read the unified config file
|
||||
with open(SOURCE_DIR.joinpath("unified_config.yaml")) as file:
|
||||
with open(SOURCE_DIR / "unified_config.yaml") as file:
|
||||
unified_config = yaml.safe_load(file)
|
||||
|
||||
# Create per panel config file
|
||||
@@ -94,7 +92,7 @@ def update_analysis_config():
|
||||
|
||||
for gfx_version in GFX_VERSIONS:
|
||||
# Create per gfx architecture folder
|
||||
gfx_dir = TARGET_DIR.joinpath(gfx_version)
|
||||
gfx_dir = TARGET_DIR / gfx_version
|
||||
# Create directory if it doesn't exist
|
||||
if not gfx_dir.exists():
|
||||
gfx_dir.mkdir()
|
||||
@@ -120,9 +118,7 @@ def update_analysis_config():
|
||||
data_source_config
|
||||
)
|
||||
# Write panel config to file
|
||||
filename = Path(
|
||||
TARGET_DIR.joinpath(gfx_version, f"{panel_id}_{panel_title}.yaml")
|
||||
)
|
||||
filename = TARGET_DIR / gfx_version / f"{panel_id}_{panel_title}.yaml"
|
||||
with open(filename, "w") as file:
|
||||
file.write(get_autogen_text())
|
||||
yaml.dump(new_panel_config, file, sort_keys=False)
|
||||
@@ -148,7 +144,7 @@ def update_sets_config():
|
||||
print(f"Created directory: {SETS_TARGET_DIR}")
|
||||
|
||||
# Read the unified config file
|
||||
with open(SOURCE_DIR.joinpath("unified_sets.yaml")) as file:
|
||||
with open(SOURCE_DIR / "unified_sets.yaml") as file:
|
||||
unified_sets = yaml.safe_load(file)
|
||||
|
||||
# Create per gfx version file
|
||||
@@ -172,7 +168,7 @@ def update_sets_config():
|
||||
new_sets["sets"].append(current_set)
|
||||
|
||||
# Write gfx version sets to file
|
||||
filename = Path(SETS_TARGET_DIR.joinpath(f"{gfx_version}_sets.yaml"))
|
||||
filename = SETS_TARGET_DIR / f"{gfx_version}_sets.yaml"
|
||||
with open(filename, "w") as file:
|
||||
file.write(get_autogen_text("utils/unified_sets.yaml"))
|
||||
yaml.dump(new_sets, file, sort_keys=False)
|
||||
@@ -223,7 +219,7 @@ def update_documentation():
|
||||
}
|
||||
|
||||
# Read the unified config file
|
||||
with open(SOURCE_DIR.joinpath("unified_config.yaml")) as file:
|
||||
with open(SOURCE_DIR / "unified_config.yaml") as file:
|
||||
unified_config = yaml.safe_load(file)
|
||||
|
||||
panel_metric_map = {}
|
||||
@@ -258,7 +254,7 @@ def update_documentation():
|
||||
section_metric_map[section] = panel_metric_map[panel_id]
|
||||
|
||||
# Write documentation metrics description file
|
||||
filename = Path(DOC_TARGET_DIR.joinpath("metrics_description.yaml"))
|
||||
filename = DOC_TARGET_DIR / "metrics_description.yaml"
|
||||
with open(filename, "w") as file:
|
||||
file.write(get_autogen_text())
|
||||
yaml.dump(section_metric_map, file, sort_keys=False)
|
||||
|
||||
新增問題並參考
封鎖使用者