Skip to content

Commit f27c392

Browse files
mwetterFWuellhorst
andauthored
Enable creation of new reference results in batch mode (#561) (#562)
* Enable creation of new reference results in batch mode (#561) * add options for startup and additional package loading * Run pep8 * Updated change log --------- Co-authored-by: FWuellhorst <[email protected]>
1 parent 7670334 commit f27c392

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

buildingspy/CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ BuildingsPy Changelog
44
Version 5.2.0, xxxx
55
^^^^^^^^^^^^^^^^^^^
66

7+
- In buildingspy/development/regressiontest.py, add option to create reference
8+
results in batch mode.
9+
(https://github.com/lbl-srg/BuildingsPy/issues/560)
710
- For Optimica regression tests, added check for Integers that are too large to be represented
811
- In buildingspy/development/refactor.py, corrected moving images to avoid creating
912
a directory if the target directory already exists.

buildingspy/development/regressiontest.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ def __init__(
287287
self._statistics_log = "statistics.json"
288288
self._nPro = multiprocessing.cpu_count()
289289
self._batch = False
290+
self._createNewReferenceResultsInBatchMode = False
290291
self._pedanticModelica = False
291292

292293
# Number of data points that are used
@@ -510,15 +511,18 @@ def showGUI(self, show=True):
510511
self._showGUI = show
511512
return
512513

513-
def batchMode(self, batchMode):
514+
def batchMode(self, batchMode, createNewReferenceResultsInBatchMode: bool = False):
514515
""" Set the batch mode flag.
515516
516517
:param batchMode: Set to ``True`` to run without interactive prompts
517518
and without plot windows.
519+
:param createNewReferenceResultsInBatchMode: Set to ``True`` to create
520+
new results in batch mode. Default is False.
518521
519522
By default, the regression tests require the user to respond if results differ from previous simulations.
520523
This method can be used to run the script in batch mode, suppressing all prompts that require
521-
the user to enter a response. If run in batch mode, no new results will be stored.
524+
the user to enter a response.
525+
By default, if run in batch mode, no new results will be stored.
522526
To run the regression tests in batch mode, enter
523527
524528
>>> import os
@@ -529,6 +533,7 @@ def batchMode(self, batchMode):
529533
530534
"""
531535
self._batch = batchMode
536+
self._createNewReferenceResultsInBatchMode = createNewReferenceResultsInBatchMode
532537

533538
def pedanticModelica(self, pedanticModelica):
534539
""" Set the pedantic Modelica mode flag.
@@ -2814,8 +2819,12 @@ def _checkReferencePoints(self, ans):
28142819
noOldResults = noOldResults + list(pai.keys())
28152820

28162821
if self._batch:
2817-
self._reporter.writeError(
2818-
f"Reference file {refFilNam} does not yet exist. You need to generate it by running tests in non-batch mode.")
2822+
if self._createNewReferenceResultsInBatchMode:
2823+
updateReferenceData = True
2824+
else:
2825+
self._reporter.writeError(
2826+
f"Reference file {refFilNam} does not yet exist. "
2827+
f"You need to generate it by running tests in non-batch mode.")
28192828

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

0 commit comments

Comments
 (0)