Skip to content

Update fmt check script, cleanup a few issues#11311

Merged
mitchute merged 3 commits intodevelopfrom
update_fmt_check
Oct 31, 2025
Merged

Update fmt check script, cleanup a few issues#11311
mitchute merged 3 commits intodevelopfrom
update_fmt_check

Conversation

@mitchute
Copy link
Collaborator

@mitchute mitchute commented Oct 31, 2025

Pull request overview

While reviewing #11165, I noticed the code integrity check was failing due to a false positive on a new format string. This PR updates the script to handle that new case and fixes a couple issues found during the process.

Pull Request Author

  • Title of PR should be user-synopsis style (clearly understandable in a standalone changelog context)
  • Label the PR with at least one of: Defect, Refactoring, NewFeature, Performance, and/or DoNoPublish
  • Pull requests that impact EnergyPlus code must also include unit tests to cover enhancement or defect repair
  • Author should provide a "walkthrough" of relevant code changes using a GitHub code review comment process
  • If any diffs are expected, author must demonstrate they are justified using plots and descriptions
  • If changes fix a defect, the fix should be demonstrated in plots and descriptions
  • If any defect files are updated to a more recent version, upload new versions here or on DevSupport
  • If IDD requires transition, transition source, rules, ExpandObjects, and IDFs must be updated, and add IDDChange label
  • If structural output changes, add to output rules file and add OutputChange label
  • If adding/removing any LaTeX docs or figures, update that document's CMakeLists file dependencies
  • If adding/removing any output files (e.g., eplustbl.*)
    • Update ..\scripts\Epl-run.bat
    • Update ..\scripts\RunEPlus.bat
    • Update ..\src\EPLaunch\ MainModule.bas, epl-ui.frm, and epl.vbp (VersionComments)
    • Update ...github\workflows\energyplus.py

Reviewer

  • Perform a Code Review on GitHub
  • If branch is behind develop, merge develop and build locally to check for side effects of the merge
  • If defect, verify by running develop branch and reproducing defect, then running PR and reproducing fix
  • If feature, test running new feature, try creative ways to break it
  • CI status: all green or justified
  • Check that performance is not impacted (CI Linux results include performance check)
  • Run Unit Test(s) locally
  • Check any new function arguments for performance impacts
  • Verify IDF naming conventions and styles, memos and notes and defaults
  • If new idf included, locally check the err file and other outputs

@mitchute mitchute added the Defect Includes code to repair a defect in EnergyPlus label Oct 31, 2025
@mitchute mitchute added this to the EnergyPlus 25.2 milestone Oct 31, 2025
for (int i = 1; i <= nReportPeriods; i++) {
std::string ReportPeriod_Resilience_Summary = fmt::format(
"{} Resilience Summary for Reporting Period {}: {}", kw, i, ReportPeriodInputData(i).title, ReportPeriodInputData(i).totalElectricityUse);
"{} Resilience Summary for Reporting Period {}: {} {}", kw, i, ReportPeriodInputData(i).title, ReportPeriodInputData(i).totalElectricityUse);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Found this issue. We might want to add a bit more here.

Comment on lines -6526 to +6527
format("...Reheat coil outlet node name = {}" + state.dataLoopNodes->NodeID(SupHeatCoilOutletNode)));
ShowContinueError(state, format("...UnitarySystem outlet node name = {}" + state.dataLoopNodes->NodeID(this->AirOutNode)));
format("...Reheat coil outlet node name = {}", state.dataLoopNodes->NodeID(SupHeatCoilOutletNode)));
ShowContinueError(state, format("...UnitarySystem outlet node name = {}", state.dataLoopNodes->NodeID(this->AirOutNode)));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think this concatenates the strings instead of replacing the argument in the placeholder. Updated here.

Comment on lines +391 to +429
class TestCheckFormatStrings(unittest.TestCase):
PASS = 0
FAIL = 1

def test_valid_cases(self):
test_options = [
'format("{}", arg1)',
'format("{}{}=\"{}\"", RoutineName, s_ipsc->cCurrentModuleObject, s_ipsc->cAlphaArgs(1))',
'fmt::format("PLR = {:7." + std::to_string(DecimalPrecision) + "F}", fmt::join(PLRArray, ","))',
'format("...{} is < 2 {{C}}. Freezing could occur.", cNumericFields(17))',
'format(R"({}="{}" invalid {}="{}" not found.)",\n CurrentModuleObject,\n ventSlab.Name,\n cAlphaFields(4),\n state.dataIPShortCut->cAlphaArgs(4))',
'format("{}{}{}{}{}{}", "Occurs for Node=", NodeName, ", ObjectType=", ObjectType, ", ObjectName=", ObjectName)',
'format("{}{}", RoutineName, "Node registered for both Parent and \"not\" Parent")'
'format("{}\n", EnergyPlus::Constant::unitNames[(int)meter->units])'
]

tmp_dir = Path(tempfile.mkdtemp())
tmp_file = tmp_dir / "valid.cc"

with open(tmp_file, 'w') as f:
for line in test_options:
f.write(line)

self.assertEqual(self.PASS, check_format_statements([tmp_file]))

def test_invalid_cases(self):
test_options = [
'format("{}", arg1, arg2)',
'format("{}{}=\"{}\"")',
]

tmp_dir = Path(tempfile.mkdtemp())
tmp_file = tmp_dir / "invalid.cc"

with open(tmp_file, 'w') as f:
for line in test_options:
f.write(line)

self.assertEqual(self.FAIL, check_format_statements([tmp_file]))
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

There's a bunch of parsing voodoo in this script. These tests seem to be enough to capture most of our format uses.

Comment on lines +3386 to +3390
std::string ReportPeriod_Resilience_Summary = fmt::format("{} Resilience Summary for Reporting Period {}: {} {}",
kw,
i,
ReportPeriodInputData(i).title,
ReportPeriodInputData(i).totalElectricityUse);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I ran regressions locally without issue, and CI similarly is not reporting any diffs here, which I assume means these lines are not being hit. Anyone care to comment on whether more should be added here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the resilience reports only run for annual simulations?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe. Just ran regressions forcing annual simulations on the following and there were no diffs.

1ZoneUncontrolled_Win_ResilienceReports_ReportingPeriod_AllTable.idf
1ZoneUncontrolled_Win_ASH55_Thermal_Comfort.idf
1ZoneEvapCooler_ReportPeriodPowerOutage.idf
1ZoneEvapCooler_ReportPeriodPowerOutage_naturalVent.idf
1ZoneUncontrolled_Win_ResilienceReports_ReportingPeriod.idf
1ZoneUncontrolled_Win_ResilienceReports.idf

@mitchute
Copy link
Collaborator Author

Good enough for now on this, but we may need a follow-up issue on the resiliency tables.

@mitchute mitchute merged commit 1d7f4e2 into develop Oct 31, 2025
11 checks passed
@mitchute mitchute deleted the update_fmt_check branch October 31, 2025 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Defect Includes code to repair a defect in EnergyPlus

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants