Exemplo n.º 1
0
 def test_submit_stacking_tasks_to_queue_no_delay(self, mock_filter_blocks,
                                                  mock_get_blocks,
                                                  mock_get_instruments,
                                                  mock_stack_calibrations,
                                                  setup):
     mock_get_instruments.return_value = [self.fake_inst]
     mock_get_blocks.return_value = self.fake_blocks_response_json
     mock_filter_blocks.return_value = [
         block for block in self.fake_blocks_response_json['results']
     ]
     schedule_calibration_stacking(self.site, self.context, self.min_date,
                                   self.max_date)
     mock_stack_calibrations.assert_called_with(
         args=(self.min_date,
               self.max_date, self.fake_inst.id, self.frame_type,
               vars(self.context), mock_filter_blocks.return_value),
         countdown=0)
Exemplo n.º 2
0
 def test_submit_stacking_tasks_to_queue_with_delay(
         self, mock_filter_blocks, mock_get_blocks, mock_get_instruments,
         mock_stack_calibrations, setup):
     mock_get_instruments.return_value = [self.fake_inst]
     self.fake_blocks_response_json['results'][0][
         'end'] = datetime.strftime(
             datetime.utcnow() + timedelta(minutes=1),
             date_utils.TIMESTAMP_FORMAT)
     mock_get_blocks.return_value = self.fake_blocks_response_json
     mock_filter_blocks.return_value = [
         block for block in self.fake_blocks_response_json['results']
     ]
     schedule_calibration_stacking(self.site, self.context, self.min_date,
                                   self.max_date)
     mock_stack_calibrations.assert_called_with(
         args=(self.min_date,
               self.max_date, self.fake_inst.id, self.frame_type,
               vars(self.context), mock_filter_blocks.return_value),
         countdown=(60 + CALIBRATION_STACK_DELAYS['BIAS']))
Exemplo n.º 3
0
def stack_calibrations(frame_type):
    logger.info('Stacking calibrations for frame type: {frame_type}'.format(frame_type=frame_type))
    logger.info('Stacking calibrations for frame type: {frame_type}'.format(frame_type=frame_type))
    for day_obs in DAYS_OBS:
        site, camera, dayobs = day_obs.split('/')
        timezone = get_timezone(site, db_address=os.environ['DB_ADDRESS'])
        min_date, max_date = get_min_and_max_dates(timezone, dayobs=dayobs)
        runtime_context = dict(processed_path=DATA_ROOT, log_level='debug', post_to_archive=False,
                               post_to_elasticsearch=False, fpack=True, rlevel=91,
                               db_address=os.environ['DB_ADDRESS'], elasticsearch_qc_index='banzai_qc',
                               elasticsearch_url='http://elasticsearch.lco.gtn:9200', elasticsearch_doc_type='qc',
                               no_bpm=False, ignore_schedulability=True, use_only_older_calibrations=False,
                               preview_mode=False, max_tries=5, broker_url=os.getenv('FITS_BROKER_URL'))
        for setting in dir(settings):
            if '__' != setting[:2] and not isinstance(getattr(settings, setting), ModuleType):
                runtime_context[setting] = getattr(settings, setting)
        schedule_calibration_stacking(site, runtime_context, min_date=min_date, max_date=max_date,
                                      frame_types=[frame_type])
    celery_join()
    logger.info('Finished stacking calibrations for frame type: {frame_type}'.format(frame_type=frame_type))