Getting previous answers on_load

I’m working with a custom recipe that has a model update. I’d like to train the model with the on_load function but it seems the docs for this have a mistake.

For the basic example:

def on_load(controller):
    sessions = controller.store.get(dataset)
    for session in sessions:
        for task in session:
            if task['answer'] == 'accept':
                my_custom_model.update(task['text'], task['label'])

There is the following error: AttributeError: 'Controller' object has no attribute 'store'

This is with prodigy 1.5.1

What is the correct way to access the past sessions?

Oh, sorry about that – that example is from the PRODIGY_README.html, right? This is definitely a typo and should be controller.db.

Thanks, that helps. This is the final call that worked for me:
sessions = controller.db.get_dataset(dataset)

1 Like