mosaik 3.4 released – mosaik

mosaik 3.4 released

The mosaik team is over the moon to announce the release of mosaik 3.4. This release brings some important bug fixes to the tiered-time system introduced in mosaik 3.3, and some new features that will hopefully help you in running your mosaik simulations more reliably.

First of all, we have made the internal async datastructures of mosaik available to you. This feature is intended for users who want or have to run mosaik in an existing asyncio event loop (for example, if you are running mosaik in a Jupyter notebook).

To profit from this, you can import AsyncWorld instead of World from the mosaik package. It is used similarly to World, except that many methods are now async and thus need to be called with await. This also means that you can run them asynchronously, for example, to start two simulators with long start-up times in parallel.

In addition to this, AsyncWorld is geared towards users who want to use mosaik as part of a larger project, and will not automatically print its greeting or logging. You can configure this by giving the skip_greetings and configure_logging keyword arguments when creating your AsyncWorld. These keyword arguments also exist for World, but the default values are different.

Second, both World and AsyncWorld are context managers now and can be used with a with or async with block, respectively. The advantage of this is that mosaik will keep the connection to the simulators open until the end of the block, instead of closing them in the run method. This way, you can still call extra methods on the simulators after the simulation, for example, to extract final results from the simulators.

Third, mosaik will automatically terminate processes that it started. This can be controlled by extending your SIM_CONFIG with the "auto_terminate" key, like so:

SIM_CONFIG: mosaik.SimConfig = {
MySim” : {

cmd”: “%(python)s mysim.py %(addr)s”,

auto_terminate”: False,

},

}

Last, there are some bug fixes related to the new tiered-time system. If you ran into “cannot progress backwards” errors or into errors that some times are “incomparable”, these should be fixed now. Please let us know if you still run into issues like these.