Skip to content

Commit

Permalink
Merge branch 'issue558_batchResults' into issue253_coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mwetter committed Jun 26, 2024
2 parents 34bb8ba + eef7170 commit eb44eaa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
3 changes: 3 additions & 0 deletions buildingspy/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ BuildingsPy Changelog
Version 5.2.0, xxxx
^^^^^^^^^^^^^^^^^^^

- In buildingspy/development/regressiontest.py, add option to create reference
results in batch mode.
(https://github.com/lbl-srg/BuildingsPy/issues/560)
- For Optimica regression tests, added check for Integers that are too large to be represented
- In buildingspy/development/refactor.py, corrected moving images to avoid creating
a directory if the target directory already exists.
Expand Down
17 changes: 13 additions & 4 deletions buildingspy/development/regressiontest.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ def __init__(
self._statistics_log = "statistics.json"
self._nPro = multiprocessing.cpu_count()
self._batch = False
self._createNewReferenceResultsInBatchMode = False
self._pedanticModelica = False

# Number of data points that are used
Expand Down Expand Up @@ -513,15 +514,18 @@ def showGUI(self, show=True):
self._showGUI = show
return

def batchMode(self, batchMode):
def batchMode(self, batchMode, createNewReferenceResultsInBatchMode: bool = False):
""" Set the batch mode flag.
:param batchMode: Set to ``True`` to run without interactive prompts
and without plot windows.
:param createNewReferenceResultsInBatchMode: Set to ``True`` to create
new results in batch mode. Default is False.
By default, the regression tests require the user to respond if results differ from previous simulations.
This method can be used to run the script in batch mode, suppressing all prompts that require
the user to enter a response. If run in batch mode, no new results will be stored.
the user to enter a response.
By default, if run in batch mode, no new results will be stored.
To run the regression tests in batch mode, enter
>>> import os
Expand All @@ -532,6 +536,7 @@ def batchMode(self, batchMode):
"""
self._batch = batchMode
self._createNewReferenceResultsInBatchMode = createNewReferenceResultsInBatchMode

def pedanticModelica(self, pedanticModelica):
""" Set the pedantic Modelica mode flag.
Expand Down Expand Up @@ -2819,8 +2824,12 @@ def _checkReferencePoints(self, ans):
noOldResults = noOldResults + list(pai.keys())

if self._batch:
self._reporter.writeError(
f"Reference file {refFilNam} does not yet exist. You need to generate it by running tests in non-batch mode.")
if self._createNewReferenceResultsInBatchMode:
updateReferenceData = True
else:
self._reporter.writeError(
f"Reference file {refFilNam} does not yet exist. "
f"You need to generate it by running tests in non-batch mode.")

if not (self._batch or ans == "Y" or ans == "N"):
if t_ref is None:
Expand Down

0 comments on commit eb44eaa

Please sign in to comment.