diff --git a/.CI/installLibraries.mos b/.CI/installLibraries.mos index 0028b32..96ed2ed 100644 --- a/.CI/installLibraries.mos +++ b/.CI/installLibraries.mos @@ -77,6 +77,7 @@ for l in { {"Modelica_Synchronous", "master"}, {"ModelicaByExample", "master"}, {"ModelicaTestOverdetermined", "master"}, + {"NeuralNetwork", "main"}, {"ObjectStab", "master"}, {"OpenHydraulics", "main"}, {"OpenIMDML", "main"}, diff --git a/README.md b/README.md index b44d461..9e2bd67 100644 --- a/README.md +++ b/README.md @@ -187,10 +187,10 @@ defining `MSLREFERENCE` and `REFERENCEFILES`. Some result file locations: -- Modelica Association: [https://github.com/modelica/MAP-LIB_ReferenceResults](modelica/MAP-LIB_ReferenceResults) -- PNLib: [https://github.com/AMIT-HSBI/PNlib](AMIT-HSBI/PNlib) -- DLR-SR: [https://github.com/DLR-SR/ThermoFluidStream-Regression](DLR-SR/ThermoFluidStream-Regression) - and [https://github.com/DLR-SR/PlanarMechanics_ReferenceResults](DLR-SR/PlanarMechanics_ReferenceResults) +- Modelica Association: [modelica/MAP-LIB_ReferenceResults](https://github.com/modelica/MAP-LIB_ReferenceResults) +- PNLib: [AMIT-HSBI/PNlib](https://github.com/AMIT-HSBI/PNlib) +- DLR-SR: [DLR-SR/ThermoFluidStream-Regression](https://github.com/DLR-SR/ThermoFluidStream-Regression) + and [DLR-SR/PlanarMechanics_ReferenceResults](https://github.com/DLR-SR/PlanarMechanics_ReferenceResults) To download the MSL reference files create a file installReferenceResults.sh with diff --git a/conversionscript.py b/conversionscript.py index 59f00b8..c2b0fc4 100755 --- a/conversionscript.py +++ b/conversionscript.py @@ -13,7 +13,6 @@ from multiprocessing import Pool import time - parser = argparse.ArgumentParser(description='OpenModelica library testing tool') parser.add_argument('libdir', nargs=1) parser.add_argument('--diff', action="store_true") @@ -33,17 +32,6 @@ os.mkdir("converted-libraries/.openmodelica") os.mkdir("converted-libraries/.openmodelica/libraries") -def omcAssert(omc: OMCSessionZMQ, cmd: str, extra: str = ""): - res = omc.sendExpression(cmd) - if not res: - raise Exception(cmd + "\n" + extra + "\n" + (omc.sendExpression("getErrorString()") or "")) - -def omcSendExpression(omc: OMCSessionZMQ, cmd: str, extra: str = ""): - try: - return omc.sendExpression(cmd) - except pyparsing.ParseException as e: - raise Exception(str(e) + "\n" + cmd + "\n" + extra + "\n" + (omc.sendExpression("getErrorString()") or "")) - mslPath = "%s/Modelica 4.0.0+maint.om/" % libdir with open("%s/openmodelica.metadata.json" % mslPath) as f: mslData = json.load(f) @@ -84,7 +72,7 @@ def convertPackage(p): print("Start working on %s" % libnameOnFile) omc = OMCSessionZMQ() libnameOnFileFullPath = "converted-libraries/.openmodelica/libraries/%s/package.mo" % libnameOnFile - omcAssert(omc, 'loadFile("%s", uses=false)' % libnameOnFileFullPath) + omc.sendExpression('loadFile("%s", uses=false)' % libnameOnFileFullPath) errString = omc.sendExpression("getErrorString()") if errString: print(errString) @@ -93,12 +81,12 @@ def convertPackage(p): raise Exception("Expected to have loaded %s but got %s" % (libnameOnFileFullPath, loadedFilePath)) gcProfStatsBeforeConversion = omc.sendExpression("GC_get_prof_stats()") timeBeforeConvert = time.time() - omcAssert(omc, 'runConversionScript(%s, "%s")' % (libname, conversionScript)) + omc.sendExpression('runConversionScript(%s, "%s")' % (libname, conversionScript)) print("runConversionScript(%s, %s) OK" % (libnameOnFile, conversionScript)) uses = data["uses"] for (n,v) in data["uses"].items(): if n in ["Modelica", "ModelicaServices", "Complex"]: - omcAssert(omc, 'addClassAnnotation(%s, annotate=$annotation(uses(%s(version="4.0.0"))))' % (libname, n)) + omc.sendExpression('addClassAnnotation(%s, annotate=$annotation(uses(%s(version="4.0.0"))))' % (libname, n)) data["uses"][n] = "4.0.0" names = omc.sendExpression('getClassNames(%s, sort=true, recursive=true)' % libname) names = list(names) @@ -150,7 +138,7 @@ def convertPackage(p): print(errStr) raise Exception('--allowErrorsInDiff is not active:\necho(false);before:=readFile("%s");\nafter:=readFile("%s");echo(true);\ndiffModelicaFileListings(before, after, OpenModelica.Scripting.DiffFormat.plain, failOnSemanticsChange=true);\ngetErrorString();' % (oldFile, newFile)) else: - omcAssert(omc, 'writeFile("%s", res)' % (newFile)) + omc.sendExpression('writeFile("%s", res)' % (newFile)) isDiff = before != res if before != res: nDiff += 1 diff --git a/test.py b/test.py index efea60b..66c235a 100755 --- a/test.py +++ b/test.py @@ -665,11 +665,10 @@ def hashReferenceFiles(s): try: omc.sendExpression('loadModel(%s,%s%s)' % (lib,versions,exactMatch)) - except OMCSessionException: - try: - print("Failed to load library %s %s: %s" % (library,versions,omc.sendExpression('OpenModelica.Scripting.getErrorString()'))) - except: - print("Failed to load library %s %s. OpenModelica.Scripting.getErrorString() failed..." % (library,conf["libraryVersion"])) + except OMCSessionException as e: + print("Failed to load library %s %s" % (library,versions)) + print(e) + # adrpo: do not sort the top level names as sometimes that loads a bad MSL version # conf["loadFiles"] = sorted(omc.sendExpression("{getSourceFile(cl) for cl in getClassNames()}")) conf["loadFiles"] = omc.sendExpression("{getSourceFile(cl) for cl in getClassNames()}") @@ -728,7 +727,13 @@ def hashReferenceFiles(s): if conf.get("fmi") and fmisimulatorversion: conf["libraryVersionRevision"] = conf["libraryVersionRevision"] + " " + fmisimulatorversion.decode("ascii") conf["libraryLastChange"] = conf["libraryLastChange"] + " " + fmisimulatorversion.decode("ascii") - res=omc.sendExpression('{c for c guard isExperiment(c) and not regexBool(typeNameString(x), "^Modelica_Synchronous\\.WorkInProgress") in getClassNames(%s, recursive=true)}' % library) + res = [] + try: + res = omc.sendExpression('{c for c guard isExperiment(c) and not regexBool(typeNameString(x), "^Modelica_Synchronous\\\\.WorkInProgress") in getClassNames(%s, recursive=true)}' % library) + except OMCSessionException as e: + print("Failed to get class names of library %s", library) + print(e) + if conf.get("ignoreModelPrefix"): if isinstance(conf["ignoreModelPrefix"], list): prefixes = conf["ignoreModelPrefix"]