def _result_for_handle(self, solid: Solid, handle: SolidHandle) -> NodeExecutionResult: node_def = solid.definition events_for_handle = _filter_step_events_by_handle( self.event_list, self.handle, handle) outputs_for_handle = (_filter_outputs_by_handle( self._output_capture, self.handle, handle) if self._output_capture else None) handle_with_ancestor = handle.with_ancestor(self.handle) if not handle_with_ancestor: raise DagsterInvariantViolationError( f"No handle provided for solid {solid.name}") if isinstance(node_def, SolidDefinition): return InProcessSolidResult( solid_def=node_def, handle=handle_with_ancestor, all_events=events_for_handle, output_capture=outputs_for_handle, ) else: return InProcessGraphResult( graph_def=node_def, handle=handle_with_ancestor, all_events=events_for_handle, output_capture=outputs_for_handle, )
def _filter_outputs_by_handle( output_dict: Dict[StepOutputHandle, Any], ancestor_handle: SolidHandle, current_handle: SolidHandle, ): handle_with_ancestor = current_handle.with_ancestor(ancestor_handle) outputs = {} for step_output_handle, value in output_dict.items(): handle = _get_solid_handle_from_output(step_output_handle) if handle and handle_with_ancestor and handle.is_or_descends_from( handle_with_ancestor): outputs[step_output_handle] = value return outputs
def _filter_step_events_by_handle( event_list: List[DagsterEvent], ancestor_handle: SolidHandle, current_handle: SolidHandle) -> List[DagsterEvent]: events = [] handle_with_ancestor = cast(SolidHandle, current_handle.with_ancestor(ancestor_handle)) for event in event_list: if event.is_step_event: solid_handle = cast(SolidHandle, event.solid_handle) if solid_handle.is_or_descends_from(handle_with_ancestor): events.append(event) return events