Пример #1
0
    def test_run_with_logging():
        logger = logging.getLogger("luigi-interface")
        actual = run_with_logging(["python", "-c", "print(1)"], logger)
        assert actual == 0

        try:
            run_with_logging(["python", "-c", "import sys; sys.exit(1)"], logger)
            assert False
        except subprocess.CalledProcessError:
            assert True
    def run(self):
        cmd_line = self._mk_cmd_line()
        logger.info(" ".join(cmd_line))

        try:
            run_with_logging(cmd_line, logger)
        except subprocess.CalledProcessError as e:
            logging.error(e, exc_info=True)
            # exit luigi with the same exit code as the python dataflow job proccess
            # In this way users can easily exit the job with code 50 to avoid Styx retries
            # https://github.com/spotify/styx/blob/master/doc/design-overview.md#workflow-state-graph
            os._exit(e.returncode)

        self.on_successful_run()
        if self.validate_output():
            self._publish_outputs()
        else:
            raise ValueError("Output is not valid")
Пример #3
0
 def run(self):
     cmd = self._mk_cmd()
     logger.info("Running:\n```\n%s\n```", cmd)
     run_with_logging(cmd, logger)
     logger.info("Training finished.")
 def run(self):
     cmd = self._mk_cmd()
     logger.info("Running:\n```\n%s\n```", cmd)
     run_with_logging(cmd, logger)
     logger.info("Training successful. Marking as done.")
     self._success_hook()