Skip to content

Commit

Permalink
Fix a bug that wouldn't allow only grouping by instrument
Browse files Browse the repository at this point in the history
  • Loading branch information
cmccully committed Aug 9, 2023
1 parent 2afcc34 commit 8bb7970
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.11.0 (2023-08-09)
-------------------
- Added the process_by_group keyword to stages to fix a bug that wouldn't allow grouping only by instrument

1.10.1 (2023-05-31)
-------------------
- Updated the logging scheme
Expand Down
4 changes: 4 additions & 0 deletions banzai/calibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ class CalibrationStacker(CalibrationMaker):
def __init__(self, runtime_context):
super(CalibrationStacker, self).__init__(runtime_context)

@property
def process_by_group(self):
return True

def make_master_calibration_frame(self, images):
make_calibration_name = file_utils.make_calibration_filename_function(self.calibration_type,
self.runtime_context)
Expand Down
12 changes: 9 additions & 3 deletions banzai/stages.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ def stage_name(self):
def group_by_attributes(self):
return []

@property
def process_by_group(self):
return False

def get_grouping(self, image):
grouping_criteria = [image.instrument.site, image.instrument.id]
if self.group_by_attributes:
Expand All @@ -31,11 +35,13 @@ def get_grouping(self, image):
def run(self, images):
if not images:
return images
if not self.group_by_attributes:
image_sets = images
else:
if self.group_by_attributes or self.process_by_group:
images.sort(key=self.get_grouping)
image_sets = [list(image_set) for _, image_set in itertools.groupby(images, self.get_grouping)]
else:
# Treat each image individually
image_sets = images

processed_images = []
for image_set in image_sets:
try:
Expand Down

0 comments on commit 8bb7970

Please sign in to comment.