Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Picking columns to export CSV #260

Merged
merged 10 commits into from
Apr 12, 2024
1 change: 1 addition & 0 deletions post-processing/config_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def __init__(self, config: dict):
self.filters = config.get("filters")
self.series = config.get("series")
self.column_types = config.get("column_types")
self.extra_columns = config.get("additional_columns_to_csv")

# parse filter information
self.and_filters = []
Expand Down
9 changes: 7 additions & 2 deletions post-processing/post_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ def __init__(self, log_path: Path, debug=False, verbose=False):
# dataframe filters
self.mask = pd.Series(self.df.index.notnull())

def run_post_processing(self, config: ConfigHandler):
def run_post_processing(self, log_path: Path, config: ConfigHandler):
ilectra marked this conversation as resolved.
Show resolved Hide resolved
"""
Return a dataframe containing the information passed to a plotting script
and produce relevant graphs.

Args:
log_path: str, path to a log file or a directory containing log files.
config: ConfigHandler, class containing configuration information for plotting.
"""

Expand All @@ -50,6 +51,10 @@ def run_post_processing(self, config: ConfigHandler):
# FIXME (#issue #255): have an option to put this into a file (-s / --save flag?)
print("Selected dataframe:")
print(self.df[self.mask][config.plot_columns])
if self.debug:
print("CSV dataframe:")
print(self.df[self.mask][config.plot_columns + config.extra_columns])
ilectra marked this conversation as resolved.
Show resolved Hide resolved
self.df[self.mask][config.plot_columns + config.extra_columns].to_csv(str(log_path)+'/output.csv', index=True) # Set index=False to exclude the DataFrame index from the CSV

# call a plotting script
plot_generic(
Expand Down Expand Up @@ -380,7 +385,7 @@ def main():
try:
post = PostProcessing(args.log_path, args.debug, args.verbose)
config = ConfigHandler.from_path(args.config_path)
post.run_post_processing(config)
post.run_post_processing(args.log_path,config)

except Exception as e:
print(type(e).__name__ + ":", e)
Expand Down
5 changes: 5 additions & 0 deletions post-processing/post_processing_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,8 @@ column_types:
flops_unit: "str"
system: "str"
cpus_per_task: "int"

# Specify which columns to export to csv file
additional_columns_to_csv:
[flops_value,
ilectra marked this conversation as resolved.
Show resolved Hide resolved
cpus_per_task]
Loading