CATIA-Systems / FMPy

Simulate Functional Mockup Units (FMUs) in Python
Other
412 stars 117 forks source link

Allow other plot libraries than Kaleido for use in Docker containers #649

Closed dietmarw closed 5 months ago

dietmarw commented 5 months ago

When running the plot_result function inside a Docker container one experiences the issue that there is not enough shared memory for chromium (which kaleido uses). There are some hacks to try to make it work but, really it would be much nicer if there was a configuration option for plot_result that allows to use matplotlib instead.

I did see https://github.com/CATIA-Systems/FMPy/blob/main/fmpy/__init__.py#L12 But that does not help since this would mean using an own custom version of FMPy instead of the officially released one.

t-sommer commented 5 months ago

Do you just want to (optionally) skip the tests or get rid of kaleido altogether?

dietmarw commented 5 months ago

Fancy plot capabilities are not the primary function of FMPy (I'd think). This could be achieved outside it. So removing the Kaleido dependency (and therefore possibly the chromium parts) might then reduce also a FMPy install/image considerably.

t-sommer commented 5 months ago

The plot function is an integral part of the library. However, you can choose which dependencies to install if you don't need it (see https://github.com/CATIA-Systems/FMPy/blob/main/setup.py#L201).

dietmarw commented 5 months ago

The issue is still not resolved since plot_result depends on kaleido. So if you do not install it then you can not use plot_result which is part of the core util and not just a part of some extra examples. So plot_result could be improved to fall back on matplotlib (after all that is the dependency as mentioned for plot and not kaleido). https://github.com/CATIA-Systems/FMPy/blob/main/setup.py#L203 Would that be possible?

t-sommer commented 5 months ago

We plan to use (only) Plotly for all plots in the future (see also #614).

dietmarw commented 5 months ago

But this means that FMPy would be not suitable to run in a Docker container. Which would be a real shame since there are a lot of applications areas for that. So having a fallback to matplotlib would be real improvement.

dietmarw commented 5 months ago

(or any other more lightweight plot solution, does not need to be matplotlib)

t-sommer commented 5 months ago

But this means that FMPy would be not suitable to run in a Docker container.

Why not? Just don't use the plot functions.

dietmarw commented 5 months ago

well the plot functions are part of the core utils of FMPy. So it is strange that it will not work. Mind it is only the write to file where kaleido is currently needed. So if that can be done differently you have a more robust FMPy also suitable for containers.