Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -510,15 +511,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 @@ -529,6 +533,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 @@ -2814,8 +2819,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