ibpsa / project1-boptest

Building Optimization Performance Tests
Other
101 stars 66 forks source link

Install and initialize Git LFS in `testing/Dockerfile` #614

Closed mattrobmattrob closed 5 months ago

mattrobmattrob commented 5 months ago

This addition allows me to compile a Modelica + Spawn of EnergyPlus emulator without issues. Otherwise, there are EnergyPlus related linker errors due to a file that is unlikely to be correct on the filesystem:

/usr/bin/ld:/home/developer/git/modelica-buildings/Buildings/Resources/Library/linux64/[libModelicaBuildingsEnergyPlus.so](http://libmodelicabuildingsenergyplus.so/): file format not recognized; treating as linker script

Fixes https://github.com/ibpsa/project1-boptest/issues/613.

dhblum commented 5 months ago

Thanks @mattrobmattrob. This is good to know. But testing/Docker is setup to use JModelica as test case compiler, which I never thought would be able to compile Spawn models. Or are you testing and finding it can? Or using a different tool with that Dockerfile as a starting environment?

mattrobmattrob commented 5 months ago

Thanks @mattrobmattrob. This is good to know. But testing/Docker is setup to use JModelica as test case compiler, which I never thought would be able to compile Spawn models. Or are you testing and finding it can? Or using a different tool with that Dockerfile as a starting environment?

My test case is moving https://github.com/henze-research-group/MODRLC/tree/actb/testcases/spawnrefsmalloffice into the BOPTEST testcases directory then running cd testing/ && make compile_testcase_model TESTCASE=spawnrefsmalloffice. So, AFAIK (but I'm very new to all this) it should be using the default JModelica compilation pipeline.

I just got compilation working so will ~update this PR slightly and~ push an example branch similar to https://github.com/ibpsa/project1-boptest/pull/569 (or probably just try it on that PR's branch, actually).

mattrobmattrob commented 5 months ago

You can check out https://github.com/ibpsa/project1-boptest/compare/master...mattrobmattrob:mr/add.spawnrefsmalloffice.emulator?expand=1 if you want to see what is working for me with cd testing && make build_jm_image && make compile_testcase_model TESTCASE=spawnrefsmalloffice, @dhblum

dhblum commented 5 months ago

I see. I did a quick test to compile the model with your fork and indeed got the wrapped.fmu. But when I try to deploy the testcase with TESTCASE=spawnrefsmalloffice docker-compose up the log shows a problem:

boptest_1  | 02/05/2024 03:21:14 PM UTC root                ERROR   Failed to initialize test simulation: Traceback (most recent call last):
boptest_1  |   File "/home/user/testcase.py", line 169, in __simulation
boptest_1  |     res = self.fmu.simulate(start_time=start_time,
boptest_1  |   File "src/pyfmi/fmi.pyx", line 7573, in pyfmi.fmi.FMUModelCS2.simulate
boptest_1  |   File "src/pyfmi/fmi.pyx", line 378, in pyfmi.fmi.ModelBase._exec_simulate_algorithm
boptest_1  |   File "src/pyfmi/fmi.pyx", line 372, in pyfmi.fmi.ModelBase._exec_simulate_algorithm
boptest_1  |   File "/home/user/miniconda/envs/pyfmi3/lib/python3.10/site-packages/pyfmi/fmi_algorithm_drivers.py", line 1006, in __init__
boptest_1  |     self.model.initialize()
boptest_1  |   File "src/pyfmi/fmi.pyx", line 4832, in pyfmi.fmi.FMUModelBase2.initialize
boptest_1  |   File "src/pyfmi/fmi.pyx", line 4826, in pyfmi.fmi.FMUModelBase2.initialize
boptest_1  |   File "src/pyfmi/fmi.pyx", line 4774, in pyfmi.fmi.FMUModelBase2.enter_initialization_mode
boptest_1  | pyfmi.fmi.FMUException: Enter Initialize returned with an error. Check the log for information (model.get_log).

When I look at wrapped_log.txt in the container it shows:

FMIL: module = Model, log level = 3: [WARNING][FMU status:Warning]     <ModelicaError category="warning"><value name="msg">"Failed to find spawn executable '%s' in Buildings Library installation, on SPAWNPATH and on PATH."</value></ModelicaError>
FMIL: module = Model, log level = 2: [INFO][FMU status:Error]     Initialization failed.

@mattrobmattrob Are you seeing this error too? I haven't done alot of testing of Spawn compilation and running in BOPTEST myself actually so I'd have to defer to someone who has or look more deeply myself to provide any guidance at this point.

mattrobmattrob commented 5 months ago

@mattrobmattrob Are you seeing this error too? I haven't done alot of testing of Spawn compilation and running in BOPTEST myself actually so I'd have to defer to someone who has or look more deeply myself to provide any guidance at this point.

Thanks for checking that, @dhblum! Yup, this is the beginning of the changes for that particular model. I can get it running with this added to, for example, the boptest-service/worker/Dockerfile:

RUN mkdir -p /SpawnResources/
COPY boptest/testcases/spawnrefsmalloffice/models/SpawnResources/ /SpawnResources/
ENV SPAWNPATH /SpawnResources

But that's just my temporary hack. I plan to fix it up to use the Spawn binary that you mentioned but haven't gotten there yet:

https://github.com/ibpsa/project1-boptest/blob/8c733d583f275072c967e2c85fe938bd7c643117/Dockerfile#L9-L13

Either way, this testing/Dockerfile is checking out repos with Git LFS artifacts that aren't being checked out properly so IMO this change is good on its own as it makes the state of those git checkouts more correct. Regardless of its impact on a Spawn emulation.

dhblum commented 5 months ago

Thanks @mattrobmattrob. I agree making sure Git LFS artifacts are checked out properly for repos is good generally and accepted your suggested edit to the release notes. I'll merge this and close #613, but keep in touch with how you make out compiling and simulating the spawn-based model with the JModelica-based compilation workflow in this repo.