From 68617bf515aa768851269d599c7d0e2b8dbc4a53 Mon Sep 17 00:00:00 2001 From: Saurabhsingh Rajput Date: Mon, 11 Dec 2023 06:37:18 -0400 Subject: [PATCH] Update codegreen version and add export_summary_to_csv function --- README.md | 5 +++++ codegreen/__init__.py | 2 +- codegreen/fecom/experiment/analysis.py | 17 +++++++++++++++++ pyproject.toml | 2 +- 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 59ef71d..9039079 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,11 @@ Codegreen requires the following hardware: The Intel processor is needed for accessing the RAPL power sensors. An NVIDIA GPU is required for profiling GPU usage via `nvidia-smi`. +Make sure to add your respective local paths to the following files after installation: + +- `codegreen/fecom/patching/patching_config.py` +- `codegreen/fecom/measurement/measurement_config.py` + ## Installation ``` diff --git a/codegreen/__init__.py b/codegreen/__init__.py index 7333f3b..f62c360 100644 --- a/codegreen/__init__.py +++ b/codegreen/__init__.py @@ -1,3 +1,3 @@ """Codegreen package!""" -__version__ = "0.1.30" \ No newline at end of file +__version__ = "0.1.31" \ No newline at end of file diff --git a/codegreen/fecom/experiment/analysis.py b/codegreen/fecom/experiment/analysis.py index 471d916..f9831b8 100644 --- a/codegreen/fecom/experiment/analysis.py +++ b/codegreen/fecom/experiment/analysis.py @@ -254,6 +254,23 @@ def export_summary_to_latex(output_dir: Path, summary_dfs: Dict[str, pd.DataFram for name, df in summary_dfs.items(): df.style.format(precision=2).to_latex(buf = output_dir/f"{name}.tex") +def export_summary_to_csv(output_dir: Path, summary_dfs: Dict[str, pd.DataFrame]): + """ + Write a given set of summary dfs returned by create_summary() to csv files. + """ + + for name, df in summary_dfs.items(): + csv_path = output_dir / f"{name}.csv" + + with open(csv_path, 'w') as csv_file: + writer = csv.writer(csv_file) + + # Write column headers + writer.writerow(df.columns) + + # Write each row to the csv + for index, row in df.iterrows(): + writer.writerow(row) def create_summary(project_energy_data: ProjectEnergyData) -> Dict[str, pd.DataFrame]: cpu_summary_mean = build_summary_df_mean(project_energy_data.cpu_data) diff --git a/pyproject.toml b/pyproject.toml index b1a9d13..28a115b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi" name = "codegreen" authors = [{name = "Saurabhsingh Rajput", email = "saurabh@dal.ca"}] license = {file = "LICENSE"} -classifiers = ["License :: OSI Approved :: Apache 2.0"] +classifiers = ["License :: OSI Approved :: Apache Software License"] dynamic = ["version", "description"] dependencies = [ "typer>=0.9",