Python PatientPool HowTo Issue

I’m trying to set up a patient pool to evaluate how the system scales for multiple patients. When trying to run the “HowTo_PatientPool.py” in the python howtos, I run into a couple of errors.

First, I get an import error for the hemorrhage action:

Traceback (most recent call last):
File “~\pulse\engine\src\python\pulse\howto\HowTo_PatientPool.py”, line 10, in
from pulse.cdm.patient_actions import SEHemorrhage, eHemorrhageType,
ImportError: cannot import name ‘eHemorrhageType’ from ‘pulse.cdm.patient_actions’ (~pulse\engine\src\python\pulse\cdm\patient_actions.py)

That’s overall fine, I just removed the import and the application of a hemorrhage.

The next issue I run into is this:

Traceback (most recent call last):
File “~\pulse\engine\src\python\pulse\howto\HowTo_PatientPool.py”, line 114, in
HowTo_PatientPool()
File “~\pulse\engine\src\python\pulse\howto\HowTo_PatientPool.py”, line 59, in HowTo_PatientPool
if not pool.initialize_engines():
^^^^^^^^^^^^^^^^^^^^^^^^^
File “~\pulse\engine\src\python\pulse\engine\PulseEnginePool.py”, line 64, in initialize_engines
self._is_active = self.__pool.initialize_engines(json, PyPulse.serialization_format.json)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: initialize_engines(): incompatible function arguments. The following argument types are supported:
1. (self: PyPulse.EnginePool) → bool

Invoked with: <PyPulse.EnginePool object at 0x0000026FD2A4C230>, (long EngingeInitialization JSON follows…), <serialization_format.json: 0>

I believe it is calling the function here:

https://gitlab.kitware.com/physiology/engine/-/blob/stable/src/cpp/cdm/PhysiologyEnginePool.cpp#L83

It looks like this function does not take any arguments, and the howto code is sending a json.

If I just remove the arguments from the function call in the howto (line 64 in PulseEnginePool.py),

self._is_active = self.__pool.initialize_engines(json, PyPulse.serialization_format.json)

changed to

self._is_active = self.__pool.initialize_engines()

the function at line 60 of HowTo_PatientPool.py returns false, ending the script with the message:

“Unable to load/stabilize any engine”

I’m fine continuing to try and get it to work. Any suggestions for a fix would be appreciated. I also wanted to make sure to bring it up in case a fix is needed for the howto for anyone to use the PatientPool example in the future.

Hey @robert.bixler

The engine pooling is still a work in progress.
We are about to make a pretty big push on this, so I will let you know as features come online for this.

Currently the best way to run within python is serially, using python threads that call native C++ tends to upset the GIL.

Ok, thanks. I would be interested to hear about those features when they become available.

In the mean time I think I’ve rigged up a solution by initializing patients, serializing their states to a file, and using Python’s multiprocessing function to advance time. Each process serializes the state from a file and advances a given amount of time in parallel with the other processes, then serializes the state back to the file.