Problem
When using create_config() with large seed values (> 2^31), the pybind11 bindings fail with:
RuntimeError: Unable to cast Python instance of type <class 'int'> to C++ type '?'
This occurs in MalariaConfig.from_params(merged) when Run_Number exceeds the int32 range.
Reproduction
from emodlib.malaria import create_config
# Works (fits in int32)
config = create_config({'Run_Number': 368693116})
# Fails (exceeds int32 max of 2147483647)
config = create_config({'Run_Number': 2191622255})
Current Workaround
In the mops-examples/emodlib-demo, we're truncating seeds to fit int32:
params_dict = {
'Run_Number': int(seed) % (2**31), # Workaround for int32 limit
...
}
This works but loses entropy from the full 64-bit seed space that modelops provides.
Suggested Fix
Update the C++ bindings to accept int64 for Run_Number, or add explicit type conversion/validation in the Python create_config() wrapper with a clear error message.
Context
- Discovered while running
emodlib-demo on modelops k8s cluster (only on larger sweeps that didn't get lucky and always have smaller random seeds)
- The
modelops framework generates random seeds as large integers (up to ~4 billion)
- See commit edwenger/mops-examples@526c3c7 for the workaround
Problem
When using
create_config()with large seed values (> 2^31), thepybind11bindings fail with:RuntimeError: Unable to cast Python instance of type <class 'int'> to C++ type '?'This occurs in
MalariaConfig.from_params(merged)whenRun_Numberexceeds theint32range.Reproduction
Current Workaround
In the
mops-examples/emodlib-demo, we're truncating seeds to fitint32:This works but loses entropy from the full 64-bit seed space that
modelopsprovides.Suggested Fix
Update the C++ bindings to accept
int64forRun_Number, or add explicit type conversion/validation in the Pythoncreate_config()wrapper with a clear error message.Context
emodlib-demoonmodelopsk8s cluster (only on larger sweeps that didn't get lucky and always have smaller random seeds)modelopsframework generates random seeds as large integers (up to ~4 billion)