Skip to content

Commit 4ec182b

Browse files
Copilotbernalde
andcommitted
Fix major issues in generate_model_size_report.py script
Co-authored-by: bernalde <8647329+bernalde@users.noreply.github.com>
1 parent f6a747b commit 4ec182b

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

gdplib/jobshop/model_size_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
| disjunctions | 3 |
88
| disjuncts | 6 |
99
| constraints | 9 |
10-
| nonlinear_constraints | 0 |
10+
| nonlinear_constraints | 0 |

generate_model_size_report.py

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@
4545
all_reports[instance] = report_df
4646

4747
# Generate individual model size report (Markdown)
48-
report_df.columns = ["Number"] # Change column name for individual report
49-
report_df.to_markdown("gdplib/" + instance + "/" + "model_size_report.md")
48+
individual_report_df = report_df.copy()
49+
individual_report_df.columns = ["Number"] # Change column name for individual report
50+
individual_report_df.to_markdown("gdplib/" + instance + "/" + "model_size_report.md")
5051
except Exception as e:
5152
print(f"Error processing {instance}: {str(e)}")
5253
continue
@@ -61,32 +62,31 @@
6162
combined_df = combined_df.sort_index(axis=1)
6263

6364
# Generate the combined report
64-
combined_report = "## Model Size Comparison\n\n"
65-
combined_report += "The following table shows the size metrics for all models in GDPlib:\n\n"
66-
combined_report += combined_df.to_markdown()
67-
combined_report += "\n\nThis table was automatically generated using the `generate_model_size_report.py` script.\n"
65+
combined_report = "## Model Size Comparison\n\n"
66+
combined_report += "The following table shows the size metrics for all models in GDPlib:\n\n"
67+
combined_report += combined_df.to_markdown()
68+
combined_report += "\n\nThis table was automatically generated using the `generate_model_size_report.py` script.\n"
6869

69-
# Read current README content
70-
with open("README.md", "r") as f:
71-
readme_content = f.read()
70+
# Read current README content
71+
with open("README.md", "r") as f:
72+
readme_content = f.read()
7273

73-
# Find the position to insert the table (after "## Model Size Example")
74-
size_example_pos = readme_content.find("## Model Size Example")
75-
if size_example_pos == -1:
76-
raise ValueError("The section '## Model Size Example' was not found in README.md.")
77-
78-
if size_example_pos == -1:
79-
print("Warning: '## Model Size Example' section not found in README.md. Appending report to the end of the file.")
80-
new_readme = readme_content + "\n\n" + combined_report
81-
else:
82-
next_section_pos = readme_content.find("##", size_example_pos + 1)
83-
# Create new README content
84-
new_readme = (
85-
readme_content[:size_example_pos] +
86-
combined_report +
87-
"\n\n" +
88-
readme_content[next_section_pos:]
89-
)
90-
# Write updated README
91-
with open("README.md", "w") as f:
92-
f.write(new_readme)
74+
# Find the position to insert the table (after "## Model Size Example")
75+
size_example_pos = readme_content.find("## Model Size Example")
76+
77+
if size_example_pos == -1:
78+
print("Warning: '## Model Size Example' section not found in README.md. Appending report to the end of the file.")
79+
new_readme = readme_content + "\n\n" + combined_report
80+
else:
81+
next_section_pos = readme_content.find("##", size_example_pos + 1)
82+
# Create new README content
83+
new_readme = (
84+
readme_content[:size_example_pos] +
85+
combined_report +
86+
"\n\n" +
87+
readme_content[next_section_pos:]
88+
)
89+
90+
# Write updated README
91+
with open("README.md", "w") as f:
92+
f.write(new_readme)

0 commit comments

Comments
 (0)