Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup in /tmp/tmp* is not working when an exception it thrown #675

Open
adrpo opened this issue Jun 13, 2024 · 1 comment
Open

Cleanup in /tmp/tmp* is not working when an exception it thrown #675

adrpo opened this issue Jun 13, 2024 · 1 comment

Comments

@adrpo
Copy link

adrpo commented Jun 13, 2024

When used from command line to simulate an FMU on Linux, the created temp directory /tmp/tmpNNNNNNN is not removed on exit if an exception is thrown.
I looked at the code here:
https://github.com/CATIA-Systems/FMPy/blob/main/fmpy/simulation.py#L757
and you should put that in a try/else block otherwise the cleanup will be skipped!

@adrpo adrpo changed the title Cleanup in /tmp/tmp* is not working Cleanup in /tmp/tmp* is not working when an exception it thrown Jun 13, 2024
@adrpo
Copy link
Author

adrpo commented Jun 13, 2024

Example of such failure:

python3 -m fmpy simulate  --output-file Buildings_10_Buildings.Fluid.BaseClasses.FlowModels.Validation.BasicFlowFunction_m_flow_DerivativeCheck_res.csv --start-time -2 --stop-time 2 --timeout 50 --relative-tolerance 1e-08 --interface-type ModelExchange --solver CVode --output-interval 0.0016 Buildings_10_Buildings_Fluid_BaseClasses_FlowModels_Validation_BasicFlowFunction_m_flow_DerivativeCheck.fmu
LOG_ASSERT        | error   | [/home/hudson/saved_omc/libraries/.openmodelica/libraries/Buildings 10.1.1-maint.10.0.x/Fluid/BaseClasses/FlowModels/Validation/BasicFlowFunction_m_flow_DerivativeCheck.mo:25:3-25:54:writable]
|                 | |       | The following assertion has been violated at time -1.998400
|                 | |       | ((abs(err) < 0.001)) --> "Error in implementation."
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.10/dist-packages/fmpy/__main__.py", line 4, in <module>
    main()
  File "/usr/local/lib/python3.10/dist-packages/fmpy/command_line.py", line 167, in main
    result = simulate_fmu(args.fmu_filename,
  File "/usr/local/lib/python3.10/dist-packages/fmpy/simulation.py", line 759, in simulate_fmu
    result = simulateME(model_description, fmu, start_time, stop_time, solver, step_size, relative_tolerance, start_values, apply_default_start_values, input, output, output_interval, record_events, timeout, step_finished, validate, set_stop_time)
  File "/usr/local/lib/python3.10/dist-packages/fmpy/simulation.py", line 1076, in simulateME
    step_event, _ = fmu.completedIntegratorStep()
  File "/usr/local/lib/python3.10/dist-packages/fmpy/fmi2.py", line 491, in completedIntegratorStep
    self.fmi2CompletedIntegratorStep(self.component, noSetFMUStatePriorToCurrentPoint, byref(enterEventMode), byref(terminateSimulation))
  File "/usr/local/lib/python3.10/dist-packages/fmpy/fmi2.py", line 215, in w
    raise FMICallException(function=fname, status=res)
fmpy.fmi1.FMICallException: fmi2CompletedIntegratorStep failed with status 3 (error).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants