autopilot
autopilot copied to clipboard
Subject overwriting data in data table
related to https://github.com/wehr-lab/autopilot/issues/157 and https://github.com/wehr-lab/autopilot/issues/133
When the current_trial is not correctly passed to a task, and thus not correctly passed back in the resulting data, the Subject class will overwrite data that has previously been written. This is because it tries to find the row that should correspond with the given current_trial so that it is always writing data from the same trial in the same row, but when the given current_trial is incorrect, it will incorrectly go to that row and overwrite it.
This is really bad!
This behavior was introduced because sometimes the data from the next trial will arrive before the data from the previous trial when they are called in very quick succession.
Things to do here:
- Make sure current_trial is more robustly specified by he Subject class,
- but then also more reliably given to the parent Task class -- if we aren't given one in **kwargs, we should pop up a frame and go looking for it in case someone forgot to pass them up in some plugin task. Then if we find them, we should warn that the task is written incorrectly.
- we should check whether we are overwriting data any time we're doing so in the subject class and never do it!
- something is also going wrong with sessions not incrementing, like they are correctly being counted by the subject class but not saved in the resulting data?
- write tests that ensure we're not overwriting data even when the trial number repeats/returns to zero, etc.