Skip to content

Fix HTML format fallback to generate both XLSX and CSV as documented#386

Merged
gphuang merged 3 commits intofeat/12-tracelens-integrationfrom
copilot/sub-pr-377-375adac1-1aab-4737-b318-041a55c4aa3d
Dec 17, 2025
Merged

Fix HTML format fallback to generate both XLSX and CSV as documented#386
gphuang merged 3 commits intofeat/12-tracelens-integrationfrom
copilot/sub-pr-377-375adac1-1aab-4737-b318-041a55c4aa3d

Conversation

Copy link

Copilot AI commented Dec 17, 2025

The HTML format handler displayed a warning saying "using xlsx+csv" but only generated XLSX files, creating an inconsistency between the warning message and actual behavior.

Changes:

  • Updated HTML format handler to generate both XLSX and CSV files when HTML is requested, matching the warning message
  • Clarified documentation across all functions to explicitly state HTML format is not yet supported and falls back to xlsx+csv
  • Improved warning message from "using xlsx+csv" to "generating xlsx+csv instead" for clarity

The implementation now generates the expected output:

# When output_format="html" is specified:
# Before: Only generated .xlsx file
# After: Generates both .xlsx file and multiple .csv files in subdirectory

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits December 17, 2025 10:25
Co-authored-by: gphuang <13152353+gphuang@users.noreply.github.com>
Co-authored-by: gphuang <13152353+gphuang@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP Address feedback from PR #377 on tracelens integration Fix HTML format fallback to generate both XLSX and CSV as documented Dec 17, 2025
Copilot AI requested a review from gphuang December 17, 2025 10:29
@gphuang gphuang marked this pull request as ready for review December 17, 2025 11:13
Copilot AI review requested due to automatic review settings December 17, 2025 11:13
@gphuang gphuang merged commit ee94bf7 into feat/12-tracelens-integration Dec 17, 2025
1 check failed
@gphuang gphuang deleted the copilot/sub-pr-377-375adac1-1aab-4737-b318-041a55c4aa3d branch December 17, 2025 11:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an inconsistency in the HTML format handler where it warned about generating "xlsx+csv" files but only actually generated XLSX files. The implementation has been updated to match the documented behavior by generating both XLSX and CSV files when HTML format is requested.

Key changes:

  • HTML format handler now generates both XLSX and CSV files as documented
  • Warning message improved from "using xlsx+csv" to "generating xlsx+csv instead" for clarity
  • Documentation updated across all functions to explicitly mention HTML format fallback behavior
Comments suppressed due to low confidence (1)

primus/backends/megatron/training/mlflow_artifacts.py:370

  • Variable dfs is not used.
            dfs = generate_perf_report_pytorch(trace_file, output_csvs_dir=csv_subdir)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# CSV: Multiple files in a subdirectory
csv_subdir = os.path.join(output_dir, report_name)
os.makedirs(csv_subdir, exist_ok=True)
generate_perf_report_pytorch(trace_file, output_csvs_dir=csv_subdir)
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

Inconsistent variable naming: The return value from generate_perf_report_pytorch is stored in 'xlsx_dfs' for consistency (line 383), but the CSV generation call on line 393 ignores the return value. For consistency with line 370 (the "all"/"csv" branch), this should be stored in a variable like 'csv_dfs' even if not immediately used, to maintain code consistency.

Suggested change
generate_perf_report_pytorch(trace_file, output_csvs_dir=csv_subdir)
csv_dfs = generate_perf_report_pytorch(trace_file, output_csvs_dir=csv_subdir)

Copilot uses AI. Check for mistakes.
Comment on lines 378 to +399
if output_format == "html":
warning_rank_0("[TraceLens] HTML format not yet supported, using xlsx+csv")
# Fall through to xlsx
warning_rank_0("[TraceLens] HTML format not yet supported, generating xlsx+csv instead")
# Generate both XLSX and CSV formats as fallback
# XLSX: Single file with multiple tabs
xlsx_path = os.path.join(output_dir, f"{report_name}_analysis.xlsx")
dfs = generate_perf_report_pytorch(trace_file, output_xlsx_path=xlsx_path)
xlsx_dfs = generate_perf_report_pytorch(trace_file, output_xlsx_path=xlsx_path)
if os.path.exists(xlsx_path):
log_rank_0(
f"[TraceLens] Generated XLSX report with {len(xlsx_dfs)} tabs: {os.path.basename(xlsx_path)}"
)
generated_files.append(xlsx_path)

# CSV: Multiple files in a subdirectory
csv_subdir = os.path.join(output_dir, report_name)
os.makedirs(csv_subdir, exist_ok=True)
generate_perf_report_pytorch(trace_file, output_csvs_dir=csv_subdir)

# Collect all generated CSV files
csv_files = glob.glob(os.path.join(csv_subdir, "*.csv"))
if csv_files:
log_rank_0(f"[TraceLens] Generated {len(csv_files)} CSV files for {report_name}")
generated_files.extend(csv_files)
Copy link

Copilot AI Dec 17, 2025

Choose a reason for hiding this comment

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

Code duplication: The HTML format handler duplicates the logic from the "all" branch (lines 356-376). Consider refactoring to avoid duplication - for example, treating output_format == "html" the same as "all" by changing the condition on line 356 to 'if output_format in ("all", "xlsx", "html")' and line 366 to 'if output_format in ("all", "csv", "html")', then only keeping the warning message unique to the HTML case.

Copilot uses AI. Check for mistakes.
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.

3 participants