def execute(self, request: Any, _context: Any):
        settings.init()
        dag_id = request.dag_id
        context = Context(dag_id)

        inputs = []
        try:
            inputs = self._convert_to_input_data(request)
            outputs = self.execution_task(context).execute(inputs)
            task_response = self._convert_to_task_response(dag_id, outputs)
        except Exception as e:
            print(traceback.format_exc())
            outputs = self._add_error_to_outputs(inputs, e)
            task_response = self._convert_to_task_response(dag_id, outputs)

        return task_response
    def execute(self, request: Any, _context: Any):
        settings.init()
        dag_id = request.dag_id
        context = Context(dag_id)

        try:
            inputs, job_id, task_name = self._parse_request_and_load_arg_file(
                request)
            outputs = self.execution_task(context).execute(inputs)
            task_response = self._generate_arg_file_and_convert_to_task_response(
                dag_id, job_id, task_name, outputs)

        except Exception:
            self.logger.error(traceback.format_exc())
            return self._make_error_task_response(dag_id)

        return task_response
Example #3
0
 def test_outputs_contain_resources(self):
     context = Context(self.DAG_ID)
     task = Task(context)
     outputs = task.execute(self.INPUTS)
     assert isinstance(outputs[0]["job_data"]["resources"], list)
Example #4
0
 def test_outputs_contain_params(self):
     context = Context(self.DAG_ID)
     task = Task(context)
     outputs = task.execute(self.INPUTS)
     assert outputs[0]["job_data"]["params"]
Example #5
0
 def test_outputs_contain_job_data(self):
     context = Context(self.DAG_ID)
     task = Task(context)
     outputs = task.execute(self.INPUTS)
     assert outputs[0]["job_data"]
     assert isinstance(outputs[0]["job_data"], dict)
Example #6
0
 def test_outputs_contain_job_id(self):
     context = Context(self.DAG_ID)
     task = Task(context)
     outputs = task.execute(self.INPUTS)
     assert outputs[0]["job_id"] == self.JOB_ID
Example #7
0
 def test_outputs_outputs_length_over_one(self):
     context = Context(self.DAG_ID)
     task = Task(context)
     outputs = task.execute(self.INPUTS)
     assert isinstance(outputs, list)
     assert len(outputs) >= 1
Example #8
0
 def test_if_execute_method_exist(self):
     context = Context(self.DAG_ID)
     task = Task(context)
     task.execute([])