Skip to content

Review - #1

Open
davidhjp01 wants to merge 20 commits into
masterfrom
eis
Open

davidhjp01 wants to merge 20 commits into
masterfrom
eis

Conversation

@davidhjp01

@davidhjp01 davidhjp01 commented Oct 22, 2026 •

Copy link
Copy Markdown

Just created a PR to leave review comments
@eisDNV

eisDNV and others added 18 commits August 4, 2026 10:21
…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
…that no switch back to step mode was possible. Compilation ok.
…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.
…enerated FMUs have been added to the git package (.gitignore changed).

@davidhjp01 davidhjp01 left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Hi Siegfried, here are my reviews.
I did not mention any typing issues or commented code, which I think can be addressed separately.

Comment thread tests/slaves/pythonslave.py Outdated
)
)

def do_step(self, current_time, step_size):

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Missing positional arg '*' -

auto f = PyObject_CallMethod(pInstance_, "do_step", "(ddi)", currentTime, stepSize, noSetFmuStatePriorToCurrentPoint);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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;

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I guess we need to return appropriate return status depending on the result of slave->DoStep?

Comment thread src/pythonfmu3/builder.py Outdated
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:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not from the PR, but need to be me_option_names instead?

Comment on lines 273 to 279
if (PyObject_HasAttrString(f, "terminateSimulation")) {
PyObject* pyTerminateSimulation = PyObject_GetAttrString(f, "terminateSimulation");
if (pyTerminateSimulation) {
*terminateSimulation = static_cast<bool>(PyObject_IsTrue(pyTerminateSimulation));
Py_DECREF(pyTerminateSimulation);
}
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Also not from PR, but terminateSimulation needs to be assigned if attr is missing

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

*assign a default value

} else {
*earlyReturn = false;
}
if (PyObject_HasAttrString(f, "lastSuccessfullTime")) {

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Same here

PyObject* value = PyList_GetItem(ref0, i);
intervals[i] = PyFloat_AsDouble(value);
}
Py_DECREF(ref0);

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

These PyList_GetItem and other getters that return pointers do not owned by the caller, so should not be destroyed

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think we need to Py_INCREF before DECREF

Comment thread tests/test_cli.py Outdated
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"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

We should not use external app specific test?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not quite sure what you mean with that?

eventHandlingNeeded: bool = False
terminateSimulation: bool = False
earlyReturn: bool = False
lastSuccessfullTime: "Float64" = 0.0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

typo

Comment on lines +23 to +27
class Fmi3StepResult(NamedTuple):
eventHandlingNeeded: bool = False
terminateSimulation: bool = False
earlyReturn: bool = False
lastSuccessfullTime: "Float64" = 0.0

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Duplicated definition

Comment thread tests/test_builder.py
import platform
import tempfile
import zipfile
from attrs import asdict

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

this dep should be declared as test depndencies (if only used in test)

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