HaroldMills / Vesper

Open source software for acoustic monitoring of nocturnal bird migration.
MIT License
55 stars 6 forks source link

Creating clips fails with UNIQUE constraint #191

Closed RichardLitt closed 2 years ago

RichardLitt commented 2 years ago

I'm not sure why this is happening, or how to stop it:

2022-03-06 09:58:25,567 ERROR                Attempt to create clip Edinburgh / AudioMoth Output / MPG Ranch Thrush Detector 1.1 70 / start 2022-03-05 04:05:56.425000+00:00 / duration 0.600 s failed with message: UNIQUE constraint failed: vesper_clip.recording_channel_id, vesper_clip.start_time, vesper_clip.creating_processor_id. Clip will be ignored.
RichardLitt commented 2 years ago

Also seems to fail with Old Bird Thrush and Tseep detectors. This may be because I ran the BirdVOX 0.6.0 detectors first? Is there a way to run difference detectors on the same file?

HaroldMills commented 2 years ago

Vesper allows only one clip for a given combination of recording channel, start time, and detector. An attempt to insert a clip that violates this constraint usually means that the detector in question has already been run on this recording. Is that not the case here?

RichardLitt commented 2 years ago

That wasn't the case here. I have six detectors enabled: Two birdvox, two MPG Ranch, and the OldBird ones. I had run the Birdvox recorders, but it wasn't letting me run the MPG Ranch and OldBird ones on the same files that I'd previously run the BirdVox on.

This morning, I ran only the Tseep and Thrush recorders detectors. They worked fine on the new file. Also, I found a Eurasian Oystercatcher and Eurasian Moorhen from my recordings, so thank you again for your work! How cool.

HaroldMills commented 2 years ago

Hmm... I'd like to look into this further, then. Would you be willing to send me a copy of your archive database (the .sqlite file in your archive directory) so I can query it to find out what job created the clip mentioned in the error message? (In an upcoming Vesper version, this information will be available on a new kind of page that shows complete information for a particular clip, including the number of the job that created it, so I won't have to ask you to send me your database!)

RichardLitt commented 2 years ago

Sent!

HaroldMills commented 2 years ago

The clip in question was created by job number 22 (see log at http://127.0.0.1:8000/jobs/22), which ran the MPG Ranch thrush detector on March recordings. From the time of the error message you sent, I think it must have come from job number 26 (http://127.0.0.1:8000/jobs/26), which re-ran that detector on the same recordings. I've done some thinking about how Vesper might help people avoid this problem, e.g. by keeping track of which detectors have been run on which recordings and providing more informative error messages when an attempt is made to run a detector a second time. That's more complicated than it might seem at first, but I'll keep thinking about it. For now, looking at a clip calendar for all clips created by a particular detector is the best way I can think of for checking what nights you've run a detector for.

RichardLitt commented 2 years ago

Gah. I'm sorry, I didn't realize I had run that. Thank you for debugging this!

HaroldMills commented 2 years ago

No problem! It happens from time to time, and in the future I hope to improve Vesper to provide a straightforward explanation of the problem.