Skip to content

Commit eb44eaa

Browse files
committed
Merge branch 'issue558_batchResults' into issue253_coverage
2 parents 34bb8ba + eef7170 commit eb44eaa

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
@@ -513,15 +514,18 @@ def showGUI(self, show=True):
513514
self._showGUI = show
514515
return
515516

516-
def batchMode(self, batchMode):
517+
def batchMode(self, batchMode, createNewReferenceResultsInBatchMode: bool = False):
517518
""" Set the batch mode flag.
518519
519520
:param batchMode: Set to ``True`` to run without interactive prompts
520521
and without plot windows.
522+
:param createNewReferenceResultsInBatchMode: Set to ``True`` to create
523+
new results in batch mode. Default is False.
521524
522525
By default, the regression tests require the user to respond if results differ from previous simulations.
523526
This method can be used to run the script in batch mode, suppressing all prompts that require
524-
the user to enter a response. If run in batch mode, no new results will be stored.
527+
the user to enter a response.
528+
By default, if run in batch mode, no new results will be stored.
525529
To run the regression tests in batch mode, enter
526530
527531
>>> import os
@@ -532,6 +536,7 @@ def batchMode(self, batchMode):
532536
533537
"""
534538
self._batch = batchMode
539+
self._createNewReferenceResultsInBatchMode = createNewReferenceResultsInBatchMode
535540

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

28212826
if self._batch:
2822-
self._reporter.writeError(
2823-
f"Reference file {refFilNam} does not yet exist. You need to generate it by running tests in non-batch mode.")
2827+
if self._createNewReferenceResultsInBatchMode:
2828+
updateReferenceData = True
2829+
else:
2830+
self._reporter.writeError(
2831+
f"Reference file {refFilNam} does not yet exist. "
2832+
f"You need to generate it by running tests in non-batch mode.")
28242833

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

0 commit comments

Comments
 (0)