Skip to content

Commit

Permalink
Fixes to tests. Addressed some comments.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmccully committed Dec 16, 2024
1 parent 6400d35 commit e585964
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
8 changes: 4 additions & 4 deletions banzai/calibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,11 @@ def apply_master_calibration(self, image, master_calibration_image):
def get_calibration_file_info(self, image):
return dbs.cal_record_to_file_info(
dbs.get_master_cal_record(image, self.calibration_type, self.master_selection_criteria,
self.runtime_context.db_address,
self.runtime_context.db_address,
use_only_older_calibrations=self.runtime_context.use_only_older_calibrations,
prefer_same_block=self.runtime_context.same_block_cals,
prefer_same_proposal=self.runtime_context.prefer_same_proposal,
check_public=self.runtime_context.check_public_cals)
prefer_same_block_cals=self.runtime_context.same_block_cals,
prefer_same_proposal_cals=self.runtime_context.prefer_same_proposal_cals,
check_public_cals=self.runtime_context.check_public_cals)
)


Expand Down
2 changes: 1 addition & 1 deletion banzai/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def process_image(self, file_info: dict, runtime_context: dict):
try:
logger.info('Processing frame', extra_tags={'filename': file_info.get('filename')})
runtime_context = Context(runtime_context)
if realtime_utils.need_to_process_image(file_info, runtime_context):
if realtime_utils.need_to_process_image(file_info, runtime_context, self):
if 'path' in file_info:
filename = os.path.basename(file_info['path'])
else:
Expand Down
12 changes: 6 additions & 6 deletions banzai/dbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,8 @@ def cal_record_to_file_info(record):


def get_master_cal_record(image, calibration_type, master_selection_criteria, db_address,
use_only_older_calibrations=False, prefer_same_block=False, check_public=False,
prefer_same_proposal=False):
use_only_older_calibrations=False, prefer_same_block_cals=False, check_public_cals=False,
prefer_same_proposal_cals=False):
calibration_criteria = CalibrationImage.type == calibration_type.upper()
calibration_criteria &= CalibrationImage.instrument_id == image.instrument.id
calibration_criteria &= CalibrationImage.is_master.is_(True)
Expand All @@ -361,16 +361,16 @@ def get_master_cal_record(image, calibration_type, master_selection_criteria, db

calibration_image = None
with get_session(db_address=db_address) as db_session:
if prefer_same_block:
if prefer_same_block_cals:
block_criteria = CalibrationImage.blockid == image.blockid
image_filter = db_session.query(CalibrationImage).filter(calibration_criteria & block_criteria)
calibration_image = image_filter.order_by(func.abs(CalibrationImage.dateobs - image.dateobs)).first()
if calibration_image is None and prefer_same_proposal:
if calibration_image is None and prefer_same_proposal_cals:
proposal_criteria = CalibrationImage.proposal == image.proposal
image_filter = db_session.query(CalibrationImage).filter(calibration_criteria & proposal_criteria)
calibration_image = image_filter.order_by(func.abs(CalibrationImage.dateobs - image.dateobs)).first()
if check_public:
calibration_criteria &= CalibrationImage.public_date <= datetime.datetime.utcnow()
if check_public_cals:
calibration_criteria &= CalibrationImage.public_date <= datetime.datetime.now(datetime.UTC)
if calibration_image is None:
image_filter = db_session.query(CalibrationImage).filter(calibration_criteria)
calibration_image = image_filter.order_by(func.abs(CalibrationImage.dateobs - image.dateobs)).first()
Expand Down
3 changes: 2 additions & 1 deletion banzai/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@ def parse_args(settings, extra_console_arguments=None, parser_description='Proce
help='Prefer calibrations taken in the same block')
parser.add_argument('--check-public-cals', dest='check_public_cals', default=False, action='store_true',
help='Check to see if calibration frames are public before using them?')
parser.add_argument('--prefer-same-proposal', dest='prefer_same_proposal', default=False, action='store_true',
parser.add_argument('--prefer-same-proposal-cals', dest='prefer_same_proposal_cals',
default=False, action='store_true',
help='Prefer calibrations taken with the same proposal')

if extra_console_arguments is None:
Expand Down

0 comments on commit e585964

Please sign in to comment.