Ecos-platform / fmu4j_template

Starter template for building FMUs using FMU4j
0 stars 1 forks source link

added CI to test build and run fmu #3

Closed HenningScheufler closed 2 years ago

HenningScheufler commented 2 years ago

The CI build and tests the fmu fixes instructions on linux were incorrect There seems to be a bug on Linux that I run into when testing on my machine:

Exception in thread "main" java.lang.ClassNotFoundException: at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) [FATAL][Model] [][FMU status:Fatal] [FMU4j native] Unable to find class ''!

markaren commented 2 years ago

Drop conda and simply go with pip and FMPy?

markaren commented 2 years ago

Uhm, why isn't the action running? I can't see anything for me to start it either.

markaren commented 2 years ago

[FATAL][Model] [][FMU status:Fatal] [FMU4j native] Unable to find class ''!

I'm guessing the string pointer holding the name of the class has gone out of scope on Linux -> Bug in FMU4j.

markaren commented 2 years ago

On my work PC, there seems to an issue with Python (3.9). The FMU runs fine with FMUChecker and other native importers, but fails with fmpy.. (Windows)

markaren commented 2 years ago

Doing something similar with the base FMU4j repo. This works: https://github.com/Vico-platform/FMU4j/blob/test/.github/workflows/build.yml But fmpy is a no-go.

markaren commented 2 years ago

The call

std::ifstream infile(resources_ + "/mainclass.txt");
std::getline(infile, slaveName_);

slaveName_ is ``

fails when not running in an existing JVM on linux..

Otherwise, the CI for FMU4j is up and running for cross-platform: https://github.com/Vico-platform/FMU4j/blob/test/.github/workflows/build.yml

markaren commented 2 years ago

The issue on linux is that the app is not unzipping the file correctly. FMI4j manages it on linux and it works with other apps on Windows...

markaren commented 2 years ago

So, the issue of running external tests on the FMUs has been solved in https://github.com/Vico-platform/FMU4j/pull/2. However, there is a bug in Linux somewhere, which makes it not work on linux. Basically, the fmu is unable to read the mainclass.txt file, but only on linux.

HenningScheufler commented 2 years ago

Doing something similar with the base FMU4j repo. This works: https://github.com/Vico-platform/FMU4j/blob/test/.github/workflows/build.yml But fmpy is a no-go.

I reversed the changes to pyfmi with conda as pip install pyfmi is over 2 years old

HenningScheufler commented 2 years ago

Linux Test still fails with bumped FMU4j version with

[FMU4j native] Created a new JVM. Exception in thread "main" java.lang.ClassNotFoundException: at java.net.URLClassLoader.findClass(URLClassLoader.java:382) at java.lang.ClassLoader.loadClass(ClassLoader.java:418) at java.lang.ClassLoader.loadClass(ClassLoader.java:351) [FATAL][Model] [][FMU status:Fatal] [FMU4j native] Unable to find class ''! Traceback (most recent call last): File "/home/runner/work/fmu4j_template/fmu4j_template/test/test-fmu.py", line 5, in model = load_fmu('../build/fmus/JavaSlave.fmu') File "src/pyfmi/fmi.pyx", line 8725, in pyfmi.fmi.load_fmu File "src/pyfmi/fmi.pyx", line 7021, in pyfmi.fmi.FMUModelCS2.init File "src/pyfmi/fmi.pyx", line 4592, in pyfmi.fmi.FMUModelBase2.instantiate pyfmi.fmi.FMUException: Failed to instantiate the model. See the log for possibly more information.

markaren commented 2 years ago

I saw it and it is weird. pyfmi uses FMI Library, which FMUChecker also uses. v0.1.1 has an updated .so built on Linux by me.

markaren commented 2 years ago

Tested locally with FMPy on Ubuntu 18.04. Works fine with FMU4j master.. Could release 0.1.2 with a clean build to make sure..

HenningScheufler commented 2 years ago

increased version of the fmu-builder to 0.1.1 from 0.1.0 in buildSrc

Now the CI passes