From 0e8f58277757554e938ecda881e452fd4bd70b0f Mon Sep 17 00:00:00 2001 From: Filip Jorissen Date: Tue, 22 May 2018 08:34:21 +0200 Subject: [PATCH 1/3] added a check that verifies whether a model is used multiple times see #202 --- buildingspy/development/regressiontest.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/buildingspy/development/regressiontest.py b/buildingspy/development/regressiontest.py index 90221695..9787caba 100644 --- a/buildingspy/development/regressiontest.py +++ b/buildingspy/development/regressiontest.py @@ -833,19 +833,22 @@ def _get_attribute_value(line, keyword, dat): def _checkDataDictionary(self): """ Check if the data used to run the regression tests do not have duplicate ``*.fmu`` files - and ``*.mat`` names. + and ``*.mat`` names, or model names. Since Dymola writes all ``*.fmu`` and ``*.mat`` files to the current working directory, duplicate file names would cause a translation or simulation to overwrite the files of a previous test. This would make it impossible to check the FMU export and to compare the results to previously obtained results. + Duplicate model names are not allowed since this can cause a conflict when writing + translation log files on multicore systems. - If there are duplicate ``.fmu`` and ``*.mat`` file names used, then this method raises + If there are duplicate ``.fmu`` and ``*.mat`` file names or model names used, then this method raises a ``ValueError`` exception. """ s_fmu = set() s_mat = set() + s_tra = set() errMes = "" for data in self._data: if 'ResultFile' in data: @@ -856,6 +859,18 @@ def _checkDataDictionary(self): " You need to make sure that all scripts use unique result file names.\n" % resFil else: s_mat.add(resFil) + + # Using the same model for multiple unit tests can lead to a conflict when writing the translation log file + # on a multicore test setup. This is therefore not allowed. + # See https://github.com/lbl-srg/BuildingsPy/issues/202 for a discussion. + for data in self._data: + if 'modelName' in data: + modelName = data['modelName'] + if data['mustSimulate']: + if modelName in s_tra: + errMes += "*** Error: Model name %s is used by more than one script.\n" \ + " You need to make sure that all scripts use each model only once.\n" % modelName + for data in self._data: if 'FMUName' in data: fmuFil = data['FMUName'] From 74d2de44bfcaf402208baad3cfbb03e3f8974bdf Mon Sep 17 00:00:00 2001 From: Filip Jorissen Date: Tue, 22 May 2018 08:44:59 +0200 Subject: [PATCH 2/3] typo for #202 --- buildingspy/development/regressiontest.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/buildingspy/development/regressiontest.py b/buildingspy/development/regressiontest.py index 9787caba..0da3a0cc 100644 --- a/buildingspy/development/regressiontest.py +++ b/buildingspy/development/regressiontest.py @@ -870,6 +870,8 @@ def _checkDataDictionary(self): if modelName in s_tra: errMes += "*** Error: Model name %s is used by more than one script.\n" \ " You need to make sure that all scripts use each model only once.\n" % modelName + else: + s_tra.add(modelName) for data in self._data: if 'FMUName' in data: From e4eeb7c735fe7f60a5f83959a43bb37d4fad7422 Mon Sep 17 00:00:00 2001 From: Michael Wetter Date: Wed, 2 Jan 2019 16:26:14 -0800 Subject: [PATCH 3/3] Removed trailing space --- buildingspy/development/regressiontest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/buildingspy/development/regressiontest.py b/buildingspy/development/regressiontest.py index afc14e42..dc39240d 100644 --- a/buildingspy/development/regressiontest.py +++ b/buildingspy/development/regressiontest.py @@ -861,7 +861,7 @@ def _checkDataDictionary(self): s_mat.add(resFil) # Using the same model for multiple unit tests can lead to a conflict when writing the translation log file - # on a multicore test setup. This is therefore not allowed. + # on a multicore test setup. This is therefore not allowed. # See https://github.com/lbl-srg/BuildingsPy/issues/202 for a discussion. for data in self._data: if 'modelName' in data: