Skip to content

Conversation

@syntron
Copy link
Contributor

@syntron syntron commented Dec 15, 2025

see #108

[OMCSession] improve log messages for model simulation using OM executable

  • use check=False => no CalledProcessError exception; possibility to handle the return code / error code
  • error code needs to be checked (compare == 0) by the caller!
  • improve log messages; print returncode if it is != 0 with stdout

[ModelicaSystem] improve handling of model simulation

  • ensure a message if logged if returncode != 0

cwd=cmd_run_data.cmd_cwd_local,
timeout=cmd_run_data.cmd_timeout,
check=True,
check=False,
Copy link

@bilderbuchi bilderbuchi Dec 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting an exception on non-zero exit code was good. Exceptions for handling control flow in Python are totally fine, and obvious to the user, and hard to miss, I would keep that. (I did not realize that that's what's happening because I did not dig deep enough in the call hierarchy)

The additional logging is good, so I'd keep that too. 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception on non-zero exit code has to be handled with care. There are possibilities that a result file is created (and usefull) even if the exit code is != 0. An exception here would prevent any processing of such data.

If I remeber correctly, an example is if the model is terminated via Modelica code.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remeber correctly, an example is if the model is terminated via Modelica code.

You mean via terminate()? If yes a nonzero exit code would be strange, because this "successfully terminates the analysis which was carried out".

…table

* use check=False => no CalledProcessError exception; possibility to
  handle the error code
* error code needs to be checked (compare == 0) by the caller!
* improve log messages; print returncode if it is != 0 with stdout
* ensure a message if logged if returncode != 0
* self.session().run_model_executable() will raise OMCSessionException!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants