Repository navigation
Review - #1
Review#1davidhjp01 wants to merge 20 commits into
Conversation
…oving tests/ out. Ran ruff check --fix and ruff format on project
… ==============================
platform linux -- Python 3.13.12, pytest-9.1.1, pluggy-1.6.0
rootdir: /home/se/DNV/osp/packages/PythonFMU3
configfile: pyproject.toml
plugins: cov-7.1.0
collected 1867 items / 1 skipped
tests/test_builder.py ........... [ 0%]
tests/test_deploy.py ........................ [ 1%]
tests/test_docs.py ... [ 2%]
tests/test_fmi3slave.py ................................................ [ 4%]
[ 4%]
tests/test_integration.py sssssssssssssss [ 5%]
tests/test_multiple_fmus.py s [ 5%]
tests/test_variables.py ................................................ [ 8%]
........................................................................ [ 11%]
........................................................................ [ 15%]
........................................................................ [ 19%]
........................................................................ [ 23%]
........................................................................ [ 27%]
........................................................................ [ 31%]
........................................................................ [ 35%]
........................................................................ [ 38%]
........................................................................ [ 42%]
........................................................................ [ 46%]
........................................................................ [ 50%]
........................................................................ [ 54%]
........................................................................ [ 58%]
........................................................................ [ 62%]
........................................................................ [ 65%]
........................................................................ [ 69%]
........................................................................ [ 73%]
........................................................................ [ 77%]
........................................................................ [ 81%]
........................................................................ [ 85%]
........................................................................ [ 89%]
........................................................................ [ 92%]
........................................................................ [ 96%]
............................................................. [100%]
======================= 1851 passed, 17 skipped in 1.96s ======================= passes all 1851 tests
…therefore docs/usage.md and adapted the documentation build process (adding conf.py, /_static and /_templates)
…ode. Successfull compilation. Added a basic discrete event example.
…s is not only in use for ME, but also for CS in event mode. It is set to True per default as per FMI spec
…tion also to other variable types and added ModelVariables.to_str as formatter for python types to xml strings
…de compiles, but is so far not yet tested.
…that no switch back to step mode was possible. Compilation ok.
…amedTuple needs to be defined and used.
…features. Options are now implemented as dataclass and it is possible to provide options directly to the Slave (not only through cli). Tested features.
…n FMU building and FMU usage with respect to variables with dimensions
…rd. SetupExperiment deprecated, EnterInitializationMode updated, EnterContinuousTimeMode and CompletedIntegratorStep added. Recompiled and basic tests.
…ntiateCosimulation, which where so far not included. Related changes in fmi3slave are also implemented. Compiles and test works. IntermediateUpdate management is still not included.
…ion not yet included.
…enerated FMUs have been added to the git package (.gitignore changed).
davidhjp01
left a comment
There was a problem hiding this comment.
Hi Siegfried, here are my reviews.
I did not mention any typing issues or commented code, which I think can be addressed separately.
| ) | ||
| ) | ||
|
|
||
| def do_step(self, current_time, step_size): |
There was a problem hiding this comment.
Missing positional arg '*' -
There was a problem hiding this comment.
I agree. It would probably be good to define a layer where this additional argument receives a default value value, so that it becomes optional
| terminateSimulation, | ||
| earlyReturn, | ||
| lastSuccessfullTime); | ||
| return fmi3OK; |
There was a problem hiding this comment.
I guess we need to return appropriate return status depending on the result of slave->DoStep?
| me_option_names = list(Fmi3ModelOptionsME().to_dict().keys()) | ||
| if type_node is not None and 'options' in options: | ||
| for option, value in options['options'].items(): | ||
| if option in mx_option_names: |
There was a problem hiding this comment.
Not from the PR, but need to be me_option_names instead?
| if (PyObject_HasAttrString(f, "terminateSimulation")) { | ||
| PyObject* pyTerminateSimulation = PyObject_GetAttrString(f, "terminateSimulation"); | ||
| if (pyTerminateSimulation) { | ||
| *terminateSimulation = static_cast<bool>(PyObject_IsTrue(pyTerminateSimulation)); | ||
| Py_DECREF(pyTerminateSimulation); | ||
| } | ||
| } |
There was a problem hiding this comment.
Also not from PR, but terminateSimulation needs to be assigned if attr is missing
| } else { | ||
| *earlyReturn = false; | ||
| } | ||
| if (PyObject_HasAttrString(f, "lastSuccessfullTime")) { |
| PyObject* value = PyList_GetItem(ref0, i); | ||
| intervals[i] = PyFloat_AsDouble(value); | ||
| } | ||
| Py_DECREF(ref0); |
There was a problem hiding this comment.
These PyList_GetItem and other getters that return pointers do not owned by the caller, so should not be destroyed
There was a problem hiding this comment.
I think we need to Py_INCREF before DECREF
| then indirect the call to the Python executable, and let Python run the CLI script | ||
| as a module. This allows the debugger to follow into the subprocess. | ||
| """ | ||
| CLI_ENTRY_POINT = "sim-explorer" |
There was a problem hiding this comment.
We should not use external app specific test?
There was a problem hiding this comment.
Not quite sure what you mean with that?
| eventHandlingNeeded: bool = False | ||
| terminateSimulation: bool = False | ||
| earlyReturn: bool = False | ||
| lastSuccessfullTime: "Float64" = 0.0 |
| class Fmi3StepResult(NamedTuple): | ||
| eventHandlingNeeded: bool = False | ||
| terminateSimulation: bool = False | ||
| earlyReturn: bool = False | ||
| lastSuccessfullTime: "Float64" = 0.0 |
| import platform | ||
| import tempfile | ||
| import zipfile | ||
| from attrs import asdict |
There was a problem hiding this comment.
this dep should be declared as test depndencies (if only used in test)
…used and early_return_allowed
Just created a PR to leave review comments
@eisDNV