From 1104371651b2c6005df7ad691806832f2b98a835 Mon Sep 17 00:00:00 2001 From: "fei.zheng" Date: Wed, 3 May 2023 17:45:29 -0600 Subject: [PATCH 1/3] add option to save dfs Signed-off-by: fei.zheng --- src/omniperf_analyze/omniperf_analyze.py | 1 + src/omniperf_analyze/utils/tty.py | 29 ++++++++++++++++-------- src/parser.py | 6 +++++ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/omniperf_analyze/omniperf_analyze.py b/src/omniperf_analyze/omniperf_analyze.py index 7cb6b3bf62..1f5041bc72 100644 --- a/src/omniperf_analyze/omniperf_analyze.py +++ b/src/omniperf_analyze/omniperf_analyze.py @@ -209,6 +209,7 @@ def run_cli(args, runs): runs, archConfigs["gfx90a"], output, + args.df_file_dir, args.decimal, args.time_unit, args.cols, diff --git a/src/omniperf_analyze/utils/tty.py b/src/omniperf_analyze/utils/tty.py index c7a0636671..cc38e68c0a 100644 --- a/src/omniperf_analyze/utils/tty.py +++ b/src/omniperf_analyze/utils/tty.py @@ -23,6 +23,7 @@ ##############################################################################el import pandas as pd +from pathlib import Path from tabulate import tabulate from omniperf_analyze.utils import schema, parser @@ -47,7 +48,8 @@ def string_multiple_lines(source, width, max_rows): return "\n".join(lines) -def show_all(runs, archConfigs, output, decimal, time_unit, selected_cols, verbose): +def show_all(runs, archConfigs, output, df_file_dir, decimal, time_unit, + selected_cols, verbose): """ Show all panels with their data in plain text mode. """ @@ -152,15 +154,24 @@ def show_all(runs, archConfigs, output, decimal, time_unit, selected_cols, verbo if not df.empty: # subtitle for each table in a panel if existing + table_id_str = str(table_config["id"] // 100) + "." + str( + table_config["id"] % 100) + if "title" in table_config and table_config["title"]: - ss += ( - str(table_config["id"] // 100) - + "." - + str(table_config["id"] % 100) - + " " - + table_config["title"] - + "\n" - ) + ss += (table_id_str + " " + table_config["title"] + + "\n") + + if df_file_dir: + p = Path(df_file_dir) + if not p.exists(): + p.mkdir() + if p.is_dir(): + if "title" in table_config and table_config[ + "title"]: + table_id_str += ("_" + table_config["title"]) + df.to_csv(p.joinpath( + table_id_str.replace(" ", "_") + ".csv"), + index=False) # NB: # "columnwise: True" is a special attr of a table/df diff --git a/src/parser.py b/src/parser.py index a18ad5d22b..f749c041de 100644 --- a/src/parser.py +++ b/src/parser.py @@ -468,6 +468,12 @@ def parse(my_parser): default=2, help="\t\tSpecify the decimal to display. (DEFAULT: 2)", ) + analyze_group.add_argument( + "--save-dfs", + dest="df_file_dir", + metavar="", + help="\t\tSpecify the dirctory to save analysis dataframe csv files.", + ) analyze_group.add_argument( "--cols", type=int, From 7d73f4abc66c017db5f4881325dc249b9c26f71c Mon Sep 17 00:00:00 2001 From: "fei.zheng" Date: Wed, 3 May 2023 17:50:39 -0600 Subject: [PATCH 2/3] remove saved df files from verbose Signed-off-by: fei.zheng --- src/omniperf_analyze/utils/parser.py | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/omniperf_analyze/utils/parser.py b/src/omniperf_analyze/utils/parser.py index 20ea5bb608..5449804c25 100644 --- a/src/omniperf_analyze/utils/parser.py +++ b/src/omniperf_analyze/utils/parser.py @@ -718,22 +718,6 @@ def load_table_data(workload, dir, is_gui, debug, verbose): debug, ) - # Save workload - name = "saved_analysis" - out_path = os.path.join(dir, name) - try: - os.mkdir(out_path) - if verbose >= 1: - print("Created a Saved Analysis folder") - except OSError as error: - if verbose >= 1: - print("Saved Analysis folder exists") - for id, df in workload.dfs.items(): - if "coll_level" in list(df.columns): - df = df.drop(["coll_level", "Tips"], axis=1) - df.to_csv(os.path.join(out_path, str(id) + ".csv"), index=False) - - def build_comparable_columns(time_unit): """ Build comparable columns/headers for display From 2e0a603930a1e9f44e5b5b9f5911d2df51360b6f Mon Sep 17 00:00:00 2001 From: "fei.zheng" Date: Thu, 4 May 2023 11:46:34 -0600 Subject: [PATCH 3/3] format code Signed-off-by: fei.zheng --- src/omniperf_analyze/utils/parser.py | 1 + src/omniperf_analyze/utils/tty.py | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/omniperf_analyze/utils/parser.py b/src/omniperf_analyze/utils/parser.py index 5449804c25..fa3dec1591 100644 --- a/src/omniperf_analyze/utils/parser.py +++ b/src/omniperf_analyze/utils/parser.py @@ -718,6 +718,7 @@ def load_table_data(workload, dir, is_gui, debug, verbose): debug, ) + def build_comparable_columns(time_unit): """ Build comparable columns/headers for display diff --git a/src/omniperf_analyze/utils/tty.py b/src/omniperf_analyze/utils/tty.py index cc38e68c0a..b8d32c274e 100644 --- a/src/omniperf_analyze/utils/tty.py +++ b/src/omniperf_analyze/utils/tty.py @@ -48,8 +48,9 @@ def string_multiple_lines(source, width, max_rows): return "\n".join(lines) -def show_all(runs, archConfigs, output, df_file_dir, decimal, time_unit, - selected_cols, verbose): +def show_all( + runs, archConfigs, output, df_file_dir, decimal, time_unit, selected_cols, verbose +): """ Show all panels with their data in plain text mode. """ @@ -154,24 +155,26 @@ def show_all(runs, archConfigs, output, df_file_dir, decimal, time_unit, if not df.empty: # subtitle for each table in a panel if existing - table_id_str = str(table_config["id"] // 100) + "." + str( - table_config["id"] % 100) + table_id_str = ( + str(table_config["id"] // 100) + + "." + + str(table_config["id"] % 100) + ) if "title" in table_config and table_config["title"]: - ss += (table_id_str + " " + table_config["title"] + - "\n") + ss += table_id_str + " " + table_config["title"] + "\n" if df_file_dir: p = Path(df_file_dir) if not p.exists(): p.mkdir() if p.is_dir(): - if "title" in table_config and table_config[ - "title"]: - table_id_str += ("_" + table_config["title"]) - df.to_csv(p.joinpath( - table_id_str.replace(" ", "_") + ".csv"), - index=False) + if "title" in table_config and table_config["title"]: + table_id_str += "_" + table_config["title"] + df.to_csv( + p.joinpath(table_id_str.replace(" ", "_") + ".csv"), + index=False, + ) # NB: # "columnwise: True" is a special attr of a table/df