Skip to content

[Draft] Enable Auto Table Generation#1475

Draft
rfbgo wants to merge 1 commit intoGoogleCloudPlatform:developfrom
rfbgo:auto_table
Draft

[Draft] Enable Auto Table Generation#1475
rfbgo wants to merge 1 commit intoGoogleCloudPlatform:developfrom
rfbgo:auto_table

Conversation

@rfbgo
Copy link
Copy Markdown
Collaborator

@rfbgo rfbgo commented Mar 30, 2026

Feature PoC

@rfbgo rfbgo marked this pull request as draft March 30, 2026 13:33
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces automatic generation of result tables when no table configuration is provided. It adds a new 'experiment_block_name' variable, updates the table schema to make columns optional, and implements logic to dynamically populate default columns with identity information and figures of merit. Feedback suggests moving the dynamic column generation logic out of the per-row extraction method to improve performance, relocating the 're' import to the top of the file to comply with PEP 8, and using 'any()' for more concise column existence checks.

Comment on lines +229 to +265
if self._default_columns:
# Add identity columns if not present
for var in ["application_name", "workload_name", "experiment_name"]:
if not any(c.name == var for c in self.columns):
col_conf = {"name": var, "expression": f"{{{var}}}"}
self.columns.append(ResultsColumn(col_conf))

# Add variables from experiment template name
unexpanded_exp_template_name = app_inst.variables.get("experiment_template_name")
if unexpanded_exp_template_name:
import re
vars_in_name = re.findall(r"\{([^}]+)\}", unexpanded_exp_template_name)
for var in vars_in_name:
if not any(c.name == var for c in self.columns):
col_conf = {"name": var, "expression": f"{{{var}}}"}
self.columns.append(ResultsColumn(col_conf))

# Add FOM columns
results = app_inst.result
for context in results.contexts:
for fom in context["foms"]:
fom_name = fom["name"]
context_name = context["name"]
# check if we already have it
found = False
for c in self.columns:
if c.figure_of_merit == fom_name and c.figure_of_merit_context == context_name:
found = True
break
if not found:
col_conf = {
"name": fom_name,
"figure_of_merit": fom_name,
"figure_of_merit_context": context_name,
}
self.columns.append(ResultsColumn(col_conf))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

There are a few issues with this block for generating default columns:

  1. Performance: This logic is inside extract_row, which is called for every row. This is inefficient as it repeatedly checks for existing columns. This logic should be moved to a place where it's executed only once per table, for instance, by refactoring ResultsTables.build_tables to first determine all columns and then extract rows.

  2. Import location: The import of 're' is inside a method. According to PEP 8, imports should be at the top of the file.

  3. Readability: The check for existing FOM columns (lines 253-258) can be made more concise using any(). This improves readability without being overly complex.

References
  1. According to PEP 8, imports should be at the top of the file. (link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant