MoDeNa-EUProject / MoDeNa

Software Framework for MOdelling of morphology DEvelopment of micro- and NAnostructures (MoDeNa)
17 stars 19 forks source link

importing modena gives KeyError: 'DoesNotExist' #47

Closed japaf closed 8 years ago

japaf commented 8 years ago

This issue appeared on my desktop, but I couldn't reproduce it on my laptop, so it could be caused by interference with yet unidentified program/package. I did try to clone Modena to new directory and reinstall it, I checked that environment variables were set, but it did not help.

Trying to import Modena (e.g., running any initModels script) produced:

Error in python catched in 198 of /home/me/opt/Modena/src/src/global.c
KeyError: 'DoesNotExist'

Any idea, what I should try to get it running?

sigveka commented 8 years ago

This looks familiar from the workshop...

What cmake version are you using?

cmake --version
japaf commented 8 years ago

I am using 2.8.12.2.

sigveka commented 8 years ago

@japaf How about instantiating the python interactive interpreter and import modena?

$ python
>>> import modena

(I am expecting this to fail)


@henrus

The C stub causing the error is shown below.

pName = PyString_FromString("DoesNotExist"); // Key we wish to access 
if(!pName){ Modena_PyErr_Print(); } // handle error if string conversion fails

modena_DoesNotExist = PyObject_GetItem(pDict, pName); // returns NULL on failure 
Py_DECREF(pName);
if(!modena_DoesNotExist){ Modena_PyErr_Print(); } // <----- Culprit

Specifically it is the check for "DoesNotExist" in the modules dictionary that returns NULL. This is expected because there is no entry of "DoesNotExist" I believe(?), and therefore the PyObject_GetItem function should return NULL.

Unexpectedly, however, it works on my laptop. I also tried to "printf" lines in initlibmodena to ensure that the stub above is actually executed, and indeed it is.

japaf commented 8 years ago

Going to python and trying to import modena from there gives me the same error.

Indeed that section in global.c gives me trouble. If I comment out those five lines, I can import modena and initialize forward mapping models, but it fails whenever I try to create new model in macroscopic code. Error message:

 Error in python catched in 219 of /home/me/opt/Modena/src/src/model.c
SystemError: NULL result without error in PyObject_Call
return code = 1
An error occurred
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/fireworks/core/rocket.py", line 202, in run
    m_action = t.run_task(my_spec)
  File "/home/me/lib/python2.7/site-packages/modena/Strategy.py", line 816, in run_task
    return self.handleReturnCode(ret.stored_data['returncode'])
  File "/home/me/lib/python2.7/site-packages/modena/Strategy.py", line 770, in handleReturnCode
    sys.exit(returnCode)
SystemExit: 1
2015-12-01 08:47:34,990 INFO Rocket finished
henrus commented 8 years ago

andermatt*1073-> python Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import modena

Works for me with d91a44 from substituteModels2

japaf commented 8 years ago

I can confirm that this is resolved, closing it.