adaptive-learning / flocs-core

Components for intelligent learning of computer science
1 stars 0 forks source link

Unable to reduce create_student action #52

Closed jcechak closed 7 years ago

jcechak commented 7 years ago

When reducing create_student action the reducer will fail. The last two parts of the stacktrace are the following.

/home/jaroslav/bin/git/flocs-core/flocs/reducers.py in <dictcomp>(.0)
     42     def adapted_reducer(entity_dict, data, context):
     43         data_with_context = ChainMap(data, context)
---> 44         data_kwargs = {key: data_with_context[key] for key in data_keys}
     45         return reducer(entity_dict, **data_kwargs)
     46     return adapted_reducer

/usr/lib/python3.5/collections/__init__.py in __getitem__(self, key)
    873         for mapping in self.maps:
    874             try:
--> 875                 return mapping[key]             # can't use 'key in mapping' with defaultdict
    876             except KeyError:
    877                 pass

TypeError: 'NoneType' object is not subscriptable

It seem like it tries to look up student's last_task_session that is unfortunately not present in the data_with_context.

Minimal reproducer I could find is the following.

import flocs
from flocs.store import Store
from flocs.entities import Student
import flocs.actions
with Store.open({Student: {}}) as store:
    store.stage_action(actions.create_student())
effa commented 7 years ago

Should work now. If not, please report and reopen the issue.