Esempio n. 1
0
    async def _compute_result(self) -> Dict[str, Any]:
        # set filter for contextualized logging
        execution_context_filter.bind_context(
            currently_executed_instance_id=self.operator_hierarchical_id,
            currently_executed_component_id=self.component_id,
            currently_executed_component_node_name=self.operator_name,
        )

        logger.info(
            "Starting computation for operator %s of type component with operator id %s",
            self.operator_name,
            self.operator_hierarchical_id,
        )
        self._in_computation = True

        self._check_inputs()

        # Gather data from input sources (detects cycles):
        input_values = await self._gather_data_from_inputs()

        # Actual execution of current node
        function_result = await self._run_comp_func(input_values)

        # cleanup
        self._in_computation = False
        execution_context_filter.clear_context()

        return function_result
Esempio n. 2
0
async def execute_transformation_revision(
    exec_by_id_input: ExecByIdInput, ) -> ExecutionResponseFrontendDto:
    """Execute transformation revision

    raises subtypes of TrafoExecutionError on errors.
    """

    execution_context_filter.bind_context(job_id=exec_by_id_input.job_id)
    execution_input = prepare_execution_input(exec_by_id_input)
    return await run_execution_input(execution_input)
Esempio n. 3
0
    async def result(self) -> Dict[str, Any]:
        self._wire_workflow_inputs()

        execution_context_filter.bind_context(
            currently_executed_instance_id=self.operator_hierarchical_id,
            currently_executed_component_id=None,
            currently_executed_component_node_name=self.
            operator_hierarchical_name,
        )

        logger.info(
            "Starting computation for operator %s of type workflow with operator id %s",
            self.operator_hierarchical_name,
            self.operator_hierarchical_id,
        )

        # gather result from workflow operators
        results = {}
        exe_context_config = execution_context.get()

        for (
                wf_output_name,
            (
                sub_node,
                sub_node_output_name,
            ),
        ) in self.output_mappings.items():
            try:
                results[wf_output_name] = (
                    (await sub_node.result)[sub_node_output_name]
                    if not (sub_node.has_only_plot_outputs
                            and not exe_context_config.run_pure_plot_operators)
                    else {})
            except KeyError as e:
                # possibly an output_name missing in the result dict of one of the providing nodes!
                logger.info(
                    "Execution failed due to missing output of a node",
                    exc_info=True,
                )
                raise MissingOutputException(
                    "Could not obtain output result from another node while preparing to "
                    "run operator").set_context(
                        operator_hierarchical_id=self.operator_hierarchical_id,
                        operator_hierarchical_name="workflow",
                    ) from e

        # cleanup
        execution_context_filter.clear_context()

        return results