It seems that the define-visits command line is not respecting the collections parameter and so every single call to define-visits runs on every single "exposure" for that instrument.
This was noted on a community post and looking at the code the queryDataIds is not constrained by the collection at all. The collection is passed to the DefineVisitsTask but is only used to retrieve the relevant camera (which means it's ignored and the default camera is returned). If registry is not used to work out the WCS the collection is used again to get the WCS for the specific raw.
This implies that there are really two collections of interest.
- The collection constraining the queryDataIds and associated with the butler.get of raw.wcs (if needed).
- The calibration collection used to locate the camera geometry.
As currently implemented DefineVisitsTask is effectively ignoring the collections parameter because loadCamera falls back to the generic one and we use registry to calculate the WCS.
The quick fix here is to add collections to the queryDataIds method in the script layer.
Longer term we will need to consider adding a calibration collection parameter.