Skip to content

Commit

Permalink
Enable creation of new reference results in batch mode (#561)
Browse files Browse the repository at this point in the history
* add options for startup and additional package loading
  • Loading branch information
FWuellhorst authored Jun 21, 2024
1 parent 7670334 commit f7dbcb9
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 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,13 @@ 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 f7dbcb9

Please sign in to comment.