Hi, I think I've come across a bug with the javascript functionality (or I really don't understand how it's supposed to work). It seems like the prodigyanswer event which fires after completing a task is passing the info of the upcoming task, not the one that was just completed.
I made a POC recipe to show what I mean:
import prodigy
@prodigy.recipe('Barebones JS Test',
dataset = ('Dataset ID', 'positional', None, str),
)
def barebones_js_test(
dataset
):
stream = [
{
'text': 'text1',
'label': 'label1'
},
{
'text': 'text2',
'label': 'label2'
}, {
'text': 'text3',
'label': 'label3'
}
]
# language=JavaScript
javascript = """
document.addEventListener('prodigyanswer', testAnswer);
function testAnswer(details) {
console.log(details.detail.task)
}
"""
return {
"view_id": "classification",
"dataset": dataset,
"stream": stream,
"config": {
'javascript': javascript,
}
}
Upon load, nothing special:
After accepting text1/label1, I catch the prodigyanswer event and log the passed argument, but it's text2/label2, the upcoming task:
Same on ignore or reject:
Am I misinterpreting the purpose of the event or is an index shifted somewhere?
Austin