Skip to content

Commit

Permalink
Issue427 oct verification update master (#498)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mwetter authored Dec 12, 2022
1 parent 6bbaf66 commit fbed1a2
Show file tree
Hide file tree
Showing 50 changed files with 1,604 additions and 700 deletions.
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ cache: pip

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

notifications:
Expand Down Expand Up @@ -73,7 +73,6 @@ script:
- make unittest_development_error_dictionary
- make unittest_development_merger
- make unittest_development_refactor
- make unittest_development_regressiontest_jmodelica
- make unittest_development_regressiontest_openmodelica
- make unittest_development_regressiontest_optimica
- make unittest_development_regressiontest
Expand Down
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ unittest_development_merger:
unittest_development_refactor:
python3 buildingspy/tests/test_development_refactor.py

unittest_development_regressiontest_jmodelica:
python3 buildingspy/tests/test_development_regressiontest_jmodelica.py

unittest_development_regressiontest_openmodelica:
python3 buildingspy/tests/test_development_regressiontest_openmodelica.py

Expand All @@ -56,6 +53,9 @@ unittest_development_regressiontest:
unittest_development_Validator:
python3 buildingspy/tests/test_development_Validator.py

unittest_development_Comparator:
python3 buildingspy/tests/test_development_Comparator.py

unittest_examples_dymola:
python3 buildingspy/tests/test_examples_dymola.py

Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ BuildingsPy

BuildingsPy is a Python package that can be used to

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

The package provides functions to extract data series from
Expand Down
19 changes: 19 additions & 0 deletions buildingspy/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
BuildingsPy Changelog
---------------------

Version 4.x.x, xxx -- Release 4.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Added class buildingspy.development.simulationCompare that compares
the simulation performance across tools or git branches.
(https://github.com/lbl-srg/BuildingsPy/issues/492)
- Refactored regression tests for Dymola to allow specifying a time out for each tests, and set the default time out to 300 seconds.
(https://github.com/lbl-srg/BuildingsPy/issues/495)
- Add option to exclude simulation of models from Dymola CI tests.
(https://github.com/lbl-srg/BuildingsPy/pull/486)

Version 4.0.0, May 12, 2022 -- Release 4.0
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Removed JModelica support, and added support for new OPTIMICA compile_fmu API.
(https://github.com/lbl-srg/BuildingsPy/pull/480)
- For simulation and unit tests, updated the API for OPTIMICA to the one used in oct-2022-05-09-master-4b0cd2bf71
(https://github.com/lbl-srg/BuildingsPy/issues/479)
- For simulation, corrected a bug that led to an error message when a model from the Modelica Standard Library is simulated
(https://github.com/lbl-srg/BuildingsPy/issues/472)
- For unit tests, enabled option to run tests with OpenModelica.
This change also allows specifying the test configuration in the more concise
conf.yml rather than conf.json file.
Expand Down
4 changes: 2 additions & 2 deletions buildingspy/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ BuildingsPy

BuildingsPy is a Python package that can be used to

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

The package provides functions to extract data series from
Expand Down
2 changes: 1 addition & 1 deletion buildingspy/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.0.0
4.0.dev1
11 changes: 6 additions & 5 deletions buildingspy/development/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""
This module contains the classes
- *refactor*, a module that assists in refactoring Modelica classes,
- *Tester* that runs the unit tests of the `Buildings` library,
- *Validator* that validates the html code of the info section of the `.mo` files, and
- *IBPSA* that synchronizes Modelica libraries with the `IBPSA` library.
- *ErrorDictionary* that contains information about possible error strings.
- :func:`refactor <buildingspy.development.refactor>`, a module that assists in refactoring Modelica classes,
- :func:`Tester <buildingspy.development.regressiontest.Tester>` that runs the unit tests of the `Buildings` library,
- :func:`Validator <buildingspy.development.validator.Validator>` that validates the html code of the info section of the `.mo` files, and
- :func:`IBPSA <buildingspy.development.merger.IBPSA>` that synchronizes Modelica libraries with the `IBPSA` library.
- :func:`ErrorDictionary <buildingspy.development.error_dictionary.ErrorDictionary>` that contains information about possible error strings.
- :func:`Comparator <buildingspy.development.simulationCompare.Comparator>` that compares the simulation performance across simulation tools or git branches.
"""
83 changes: 83 additions & 0 deletions buildingspy/development/dymola_run.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
def _add_exception(return_dict, e, cmd):
import subprocess

return_dict['success'] = False

# if isinstance(e, subprocess.CalledProcessError):
# # Check if simulation terminated, and if so, get the error
# return_dict['stdout'] = e.output.decode("utf-8")
# output = return_dict['stdout']
# for line in output.split('\n'):
# if 'terminated' in line:
# # Found terminated string. Cut everything after the '|' character that OpenModelica writes.
# idx=line.rfind('|')
# msg=line[idx+1:].strip()
# # The solver terminated. Add this information to a custom exception message.
# return_dict['exception'] = f"'{' '.join(cmd)}' caused '{msg}'."
# pass

if not 'exception' in return_dict:
# Did not find 'terminated' in message, handle exception as usual
return_dict['exception'] = '{}: {}'.format(type(e).__name__, e)


def _run_process(return_dict, cmd, worDir, timeout):
import subprocess

output = subprocess.check_output(
cmd,
cwd = worDir,
timeout=timeout,
stderr=subprocess.STDOUT,
shell=False)

return_dict['success'] = True
if 'stdout' in return_dict:
return_dict['stdout'] += output.decode("utf-8")
else:
return_dict['stdout'] = output.decode("utf-8")
return

def _simulate(model, timeout):
import os
import subprocess

worDir = "{{ working_directory }}"
return_dict = {}

try:
cmd = {{ cmd }}
return_dict['cmd'] = ' '.join(cmd)
output = _run_process(return_dict, cmd, worDir, timeout)

except Exception as e:
_add_exception(return_dict, e, cmd)
return return_dict

def run():
import os
import json
import traceback
import sys

timeout = {{ time_out }}
model = "{{ model }}"
result = {"model": model,
"working_directory": "{{ working_directory }}",
"simulation": {"success": False}}

# Log file
log_file = "{}_buildingspy.json".format(model.replace(".", "_"))
try:
os.remove(log_file)
except OSError:
pass

# Simulate model
result["simulation"] = _simulate(model, timeout)

with open(log_file, "w") as log:
log.write("{}\n".format(json.dumps(result, indent=4, sort_keys=False)) )

if __name__=="__main__":
run()
20 changes: 0 additions & 20 deletions buildingspy/development/error_dictionary_jmodelica.py

This file was deleted.

161 changes: 0 additions & 161 deletions buildingspy/development/jmodelica_run.template

This file was deleted.

Loading

0 comments on commit fbed1a2

Please sign in to comment.