Skip to content

Commit fbed1a2

Browse files
authored
Issue427 oct verification update master (#498)
Refactored regression tests for Dymola to allow specifying a time out for each tests, and set the default time out to 300 seconds For #495
1 parent 6bbaf66 commit fbed1a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+1604
-700
lines changed

.travis.yml

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ cache: pip
1010

1111
env:
1212
global:
13-
- OMC_VERSION=ubuntu-2004-omc:1.19.0_dev-539-gb76366f-1
14-
- OPTIMICA_VERSION=travis-ubuntu-1804-optimica:r26446
15-
- DYMOLA_VERSION=travis_ubuntu-2004_dymola:2022x-x86_64
13+
- OMC_VERSION=ubuntu-2004-omc:1.20.0_dev-314-g3033f43-1
14+
- OPTIMICA_VERSION=travis-ubuntu-1804-optimica:2022-05-09-master-4b0cd2bf71
15+
- DYMOLA_VERSION=travis_ubuntu-2004_dymola:2022x-x86_64_rev-2
1616
- MPLBACKEND=agg
1717

1818
notifications:
@@ -73,7 +73,6 @@ script:
7373
- make unittest_development_error_dictionary
7474
- make unittest_development_merger
7575
- make unittest_development_refactor
76-
- make unittest_development_regressiontest_jmodelica
7776
- make unittest_development_regressiontest_openmodelica
7877
- make unittest_development_regressiontest_optimica
7978
- make unittest_development_regressiontest

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ unittest_development_merger:
4141
unittest_development_refactor:
4242
python3 buildingspy/tests/test_development_refactor.py
4343

44-
unittest_development_regressiontest_jmodelica:
45-
python3 buildingspy/tests/test_development_regressiontest_jmodelica.py
46-
4744
unittest_development_regressiontest_openmodelica:
4845
python3 buildingspy/tests/test_development_regressiontest_openmodelica.py
4946

@@ -56,6 +53,9 @@ unittest_development_regressiontest:
5653
unittest_development_Validator:
5754
python3 buildingspy/tests/test_development_Validator.py
5855

56+
unittest_development_Comparator:
57+
python3 buildingspy/tests/test_development_Comparator.py
58+
5959
unittest_examples_dymola:
6060
python3 buildingspy/tests/test_examples_dymola.py
6161

README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ BuildingsPy
66

77
BuildingsPy is a Python package that can be used to
88

9-
* run Modelica simulation using Dymola or JModelica
10-
* process ``*.mat`` output files that were generated by Dymola, JModelica or OpenModelica.
9+
* run Modelica simulation using Dymola or OPTIMICA
10+
* process ``*.mat`` output files that were generated by Dymola, OPTIMICA or OpenModelica.
1111
* run unit tests as part of the library development.
1212

1313
The package provides functions to extract data series from

buildingspy/CHANGES.txt

+19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
BuildingsPy Changelog
22
---------------------
3+
4+
Version 4.x.x, xxx -- Release 4.0
5+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6+
- Added class buildingspy.development.simulationCompare that compares
7+
the simulation performance across tools or git branches.
8+
(https://github.com/lbl-srg/BuildingsPy/issues/492)
9+
- Refactored regression tests for Dymola to allow specifying a time out for each tests, and set the default time out to 300 seconds.
10+
(https://github.com/lbl-srg/BuildingsPy/issues/495)
11+
- Add option to exclude simulation of models from Dymola CI tests.
12+
(https://github.com/lbl-srg/BuildingsPy/pull/486)
13+
14+
Version 4.0.0, May 12, 2022 -- Release 4.0
15+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
16+
- Removed JModelica support, and added support for new OPTIMICA compile_fmu API.
17+
(https://github.com/lbl-srg/BuildingsPy/pull/480)
18+
- For simulation and unit tests, updated the API for OPTIMICA to the one used in oct-2022-05-09-master-4b0cd2bf71
19+
(https://github.com/lbl-srg/BuildingsPy/issues/479)
20+
- For simulation, corrected a bug that led to an error message when a model from the Modelica Standard Library is simulated
21+
(https://github.com/lbl-srg/BuildingsPy/issues/472)
322
- For unit tests, enabled option to run tests with OpenModelica.
423
This change also allows specifying the test configuration in the more concise
524
conf.yml rather than conf.json file.

buildingspy/README.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ BuildingsPy
66

77
BuildingsPy is a Python package that can be used to
88

9-
* run Modelica simulation using Dymola or JModelica
10-
* process ``*.mat`` output files that were generated by Dymola, JModelica or OpenModelica.
9+
* run Modelica simulation using Dymola or OPTIMICA
10+
* process ``*.mat`` output files that were generated by Dymola, OPTIMICA or OpenModelica.
1111
* run unit tests as part of the library development.
1212

1313
The package provides functions to extract data series from

buildingspy/VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.0
1+
4.0.dev1

buildingspy/development/__init__.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
"""
22
This module contains the classes
33
4-
- *refactor*, a module that assists in refactoring Modelica classes,
5-
- *Tester* that runs the unit tests of the `Buildings` library,
6-
- *Validator* that validates the html code of the info section of the `.mo` files, and
7-
- *IBPSA* that synchronizes Modelica libraries with the `IBPSA` library.
8-
- *ErrorDictionary* that contains information about possible error strings.
4+
- :func:`refactor <buildingspy.development.refactor>`, a module that assists in refactoring Modelica classes,
5+
- :func:`Tester <buildingspy.development.regressiontest.Tester>` that runs the unit tests of the `Buildings` library,
6+
- :func:`Validator <buildingspy.development.validator.Validator>` that validates the html code of the info section of the `.mo` files, and
7+
- :func:`IBPSA <buildingspy.development.merger.IBPSA>` that synchronizes Modelica libraries with the `IBPSA` library.
8+
- :func:`ErrorDictionary <buildingspy.development.error_dictionary.ErrorDictionary>` that contains information about possible error strings.
9+
- :func:`Comparator <buildingspy.development.simulationCompare.Comparator>` that compares the simulation performance across simulation tools or git branches.
910
1011
"""
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
def _add_exception(return_dict, e, cmd):
2+
import subprocess
3+
4+
return_dict['success'] = False
5+
6+
# if isinstance(e, subprocess.CalledProcessError):
7+
# # Check if simulation terminated, and if so, get the error
8+
# return_dict['stdout'] = e.output.decode("utf-8")
9+
# output = return_dict['stdout']
10+
# for line in output.split('\n'):
11+
# if 'terminated' in line:
12+
# # Found terminated string. Cut everything after the '|' character that OpenModelica writes.
13+
# idx=line.rfind('|')
14+
# msg=line[idx+1:].strip()
15+
# # The solver terminated. Add this information to a custom exception message.
16+
# return_dict['exception'] = f"'{' '.join(cmd)}' caused '{msg}'."
17+
# pass
18+
19+
if not 'exception' in return_dict:
20+
# Did not find 'terminated' in message, handle exception as usual
21+
return_dict['exception'] = '{}: {}'.format(type(e).__name__, e)
22+
23+
24+
def _run_process(return_dict, cmd, worDir, timeout):
25+
import subprocess
26+
27+
output = subprocess.check_output(
28+
cmd,
29+
cwd = worDir,
30+
timeout=timeout,
31+
stderr=subprocess.STDOUT,
32+
shell=False)
33+
34+
return_dict['success'] = True
35+
if 'stdout' in return_dict:
36+
return_dict['stdout'] += output.decode("utf-8")
37+
else:
38+
return_dict['stdout'] = output.decode("utf-8")
39+
return
40+
41+
def _simulate(model, timeout):
42+
import os
43+
import subprocess
44+
45+
worDir = "{{ working_directory }}"
46+
return_dict = {}
47+
48+
try:
49+
cmd = {{ cmd }}
50+
return_dict['cmd'] = ' '.join(cmd)
51+
output = _run_process(return_dict, cmd, worDir, timeout)
52+
53+
except Exception as e:
54+
_add_exception(return_dict, e, cmd)
55+
return return_dict
56+
57+
def run():
58+
import os
59+
import json
60+
import traceback
61+
import sys
62+
63+
timeout = {{ time_out }}
64+
model = "{{ model }}"
65+
result = {"model": model,
66+
"working_directory": "{{ working_directory }}",
67+
"simulation": {"success": False}}
68+
69+
# Log file
70+
log_file = "{}_buildingspy.json".format(model.replace(".", "_"))
71+
try:
72+
os.remove(log_file)
73+
except OSError:
74+
pass
75+
76+
# Simulate model
77+
result["simulation"] = _simulate(model, timeout)
78+
79+
with open(log_file, "w") as log:
80+
log.write("{}\n".format(json.dumps(result, indent=4, sort_keys=False)) )
81+
82+
if __name__=="__main__":
83+
run()

buildingspy/development/error_dictionary_jmodelica.py

-20
This file was deleted.

buildingspy/development/jmodelica_run.template

-161
This file was deleted.

0 commit comments

Comments
 (0)