Esempio n. 1
0
    def find_reason_to_skip_run(reduction_run: ReductionRun, message: Message, instrument) -> Optional[str]:
        """
        Determine whether the processing should be skippped. The run will be
        skipped if the message validation fails or if the instrument is paused.
        """
        if reduction_run.script.text == "":
            return "Script text for current instrument is empty"
        try:
            message.validate("data_ready")
        except RuntimeError as validation_err:
            return f"Validation error from handler: {validation_err}"

        if not instrument.is_active:
            return f"Run {message.run_number} has been skipped because the instrument {instrument.name} is inactive"

        if instrument.is_paused:
            return f"Run {message.run_number} has been skipped because the instrument {instrument.name} is paused"

        return None
 def test_validate_data_ready_valid(self):
     """
     Test: No exception is raised
     When: Calling validate for data_ready with a valid message
     """
     message = Message(instrument='GEM',
                       run_number=111,
                       rb_number=2222222,
                       data='file/path',
                       facility="ISIS",
                       started_by=0)
     try:
         self.assertIsNone(message.validate('/queue/DataReady'))
     except RuntimeError:
         self.fail()