def result_for_handle(self, handle): '''Get the result of a solid by its solid handle string. This allows indexing into top-level solids to retrieve the results of children of composite solids. Args: handle (str): The string handle for the solid. Returns: :py:class:`SolidExecutionResult`: The result of the given solid. ''' check.str_param(handle, 'handle') solid_def = self.pipeline.get_solid(SolidHandle.from_string(handle)) if not solid_def: raise DagsterInvariantViolationError( 'Can not find solid handle {handle} in pipeline.'.format( handle=handle)) events_by_kind = defaultdict(list) for event in self.event_list: if event.is_step_event: if event.solid_handle.is_or_descends_from(handle): events_by_kind[event.step_kind].append(event) return SolidExecutionResult(solid_def, events_by_kind, self.reconstruct_context)
def output_for_solid(self, handle_str, output_name=DEFAULT_OUTPUT): """Get the output of a solid by its solid handle string and output name. Args: handle_str (str): The string handle for the solid. output_name (str): Optional. The name of the output, default to DEFAULT_OUTPUT. Returns: The output value for the handle and output_name. """ check.str_param(handle_str, "handle_str") check.str_param(output_name, "output_name") return self.result_for_handle(SolidHandle.from_string(handle_str)).output_value(output_name)
def result_for_handle(self, handle): '''Get the result of a solid by its solid handle string. This allows indexing into top-level solids to retrieve the results of children of composite solids. Args: handle (str): The string handle for the solid. Returns: [CompositeSolidExecutionResult, SolidExecutionResult]: The result of the given solid. ''' check.str_param(handle, 'handle') solid = self.solid.definition.get_solid( SolidHandle.from_string(handle)) return self._result_for_handle(solid, '.'.join([self.handle, handle]))
def result_for_handle(self, handle): '''Get a :py:class:`SolidExecutionResult` for a given solid handle string. ''' check.str_param(handle, 'handle') solid_def = self.pipeline.get_solid(SolidHandle.from_string(handle)) if not solid_def: raise DagsterInvariantViolationError( 'Cant not find solid handle {handle} in pipeline.'.format( handle=handle)) events_by_kind = defaultdict(list) for event in self.event_list: if event.is_step_event: if event.solid_handle.is_or_descends_from(handle): events_by_kind[event.step_kind].append(event) return SolidExecutionResult(solid_def, events_by_kind, self.reconstruct_context)
def result_for_handle(self, handle): """Get the result of a solid by its solid handle. This allows indexing into top-level solids to retrieve the results of children of composite solids. Args: handle (Union[str,SolidHandle]): The handle for the solid. Returns: Union[CompositeSolidExecutionResult, SolidExecutionResult]: The result of the given solid. """ if isinstance(handle, six.string_types): handle = SolidHandle.from_string(handle) else: check.inst_param(handle, "handle", SolidHandle) solid = self.container.get_solid(handle) return self._result_for_handle(solid, handle)
def dagster_event_from_dict(event_dict, pipeline_name): check.dict_param(event_dict, "event_dict", key_type=str) check.str_param(pipeline_name, "pipeline_name") # Get event_type event_type = HANDLED_EVENTS.get(event_dict["__typename"]) if not event_type: raise Exception("unhandled event type %s" % event_dict["__typename"]) # Get event_specific_data event_specific_data = None if event_type == DagsterEventType.STEP_OUTPUT: event_specific_data = StepOutputData( step_output_handle=StepOutputHandle(event_dict["stepKey"], event_dict["outputName"]), type_check_data=TypeCheckData( success=event_dict["typeCheck"]["success"], label=event_dict["typeCheck"]["label"], description=event_dict.get("description"), metadata_entries=list( event_metadata_entries(event_dict.get("metadataEntries")) or []), ), ) elif event_type == DagsterEventType.STEP_INPUT: event_specific_data = StepInputData( input_name=event_dict["inputName"], type_check_data=TypeCheckData( success=event_dict["typeCheck"]["success"], label=event_dict["typeCheck"]["label"], description=event_dict.get("description"), metadata_entries=list( event_metadata_entries(event_dict.get("metadataEntries")) or []), ), ) elif event_type == DagsterEventType.STEP_SUCCESS: event_specific_data = StepSuccessData(0.0) elif event_type == DagsterEventType.STEP_UP_FOR_RETRY: event_specific_data = StepRetryData( error=error_from_data(event_dict["retryError"]), seconds_to_wait=event_dict["secondsToWait"], ) elif event_type == DagsterEventType.STEP_MATERIALIZATION: materialization = event_dict["materialization"] event_specific_data = StepMaterializationData( materialization=materialization_from_data(materialization)) elif event_type == DagsterEventType.STEP_EXPECTATION_RESULT: expectation_result = expectation_result_from_data( event_dict["expectationResult"]) event_specific_data = StepExpectationResultData(expectation_result) elif event_type == DagsterEventType.STEP_FAILURE: event_specific_data = StepFailureData( error_from_data(event_dict["error"]), UserFailureData( label=event_dict["failureMetadata"]["label"], description=event_dict["failureMetadata"]["description"], metadata_entries=list( event_metadata_entries(event_dict.get("metadataEntries")) or []), ) if event_dict.get("failureMetadata") else None, ) elif event_type == DagsterEventType.ENGINE_EVENT: event_specific_data = EngineEventData( metadata_entries=list( event_metadata_entries(event_dict.get("metadataEntries"))), marker_start=event_dict.get("markerStart"), marker_end=event_dict.get("markerEnd"), error=error_from_data(event_dict["engineError"]) if event_dict.get("engineError") else None, ) return DagsterEvent( event_type_value=event_type.value, pipeline_name=pipeline_name, step_key=event_dict.get("stepKey"), solid_handle=SolidHandle.from_string(event_dict["solidHandleID"]) if event_dict.get("solidHandleID") else None, # at the time of writing this: # * 'COMPUTE` is the only step kind # * this code should get deleted in the near future as we move away from # dagster-graphql CLI as what we invoke in dask/k8s/etc. step_kind_value="COMPUTE" if event_dict.get("stepKey") else None, logging_tags=None, event_specific_data=event_specific_data, )
def _get_solid_handle_from_output( step_output_handle: StepOutputHandle) -> Optional[SolidHandle]: return SolidHandle.from_string(step_output_handle.step_key)
def dagster_event_from_dict(event_dict, pipeline_name): check.dict_param(event_dict, 'event_dict', key_type=str) check.str_param(pipeline_name, 'pipeline_name') # Get event_type event_type = HANDLED_EVENTS.get(event_dict['__typename']) if not event_type: raise Exception('unhandled event type %s' % event_dict['__typename']) # Get event_specific_data event_specific_data = None if event_type == DagsterEventType.STEP_OUTPUT: event_specific_data = StepOutputData( step_output_handle=StepOutputHandle(event_dict['stepKey'], event_dict['outputName']), type_check_data=TypeCheckData( success=event_dict['typeCheck']['success'], label=event_dict['typeCheck']['label'], description=event_dict.get('description'), metadata_entries=list( event_metadata_entries(event_dict.get('metadataEntries')) or [] ), ), ) elif event_type == DagsterEventType.STEP_INPUT: event_specific_data = StepInputData( input_name=event_dict['inputName'], type_check_data=TypeCheckData( success=event_dict['typeCheck']['success'], label=event_dict['typeCheck']['label'], description=event_dict.get('description'), metadata_entries=list( event_metadata_entries(event_dict.get('metadataEntries')) or [] ), ), ) elif event_type == DagsterEventType.STEP_SUCCESS: event_specific_data = StepSuccessData(0.0) elif event_type == DagsterEventType.STEP_UP_FOR_RETRY: event_specific_data = StepRetryData( error=error_from_data(event_dict['retryError']), seconds_to_wait=event_dict['secondsToWait'], ) elif event_type == DagsterEventType.STEP_MATERIALIZATION: materialization = event_dict['materialization'] event_specific_data = StepMaterializationData( materialization=materialization_from_data(materialization) ) elif event_type == DagsterEventType.STEP_EXPECTATION_RESULT: expectation_result = expectation_result_from_data(event_dict['expectationResult']) event_specific_data = StepExpectationResultData(expectation_result) elif event_type == DagsterEventType.STEP_FAILURE: event_specific_data = StepFailureData( error_from_data(event_dict['error']), UserFailureData( label=event_dict['failureMetadata']['label'], description=event_dict['failureMetadata']['description'], metadata_entries=list( event_metadata_entries(event_dict.get('metadataEntries')) or [] ), ) if event_dict.get('failureMetadata') else None, ) elif event_type == DagsterEventType.ENGINE_EVENT: event_specific_data = EngineEventData( metadata_entries=list(event_metadata_entries(event_dict.get('metadataEntries'))), marker_start=event_dict.get('markerStart'), marker_end=event_dict.get('markerEnd'), error=error_from_data(event_dict['engineError']) if event_dict.get('engineError') else None, ) return DagsterEvent( event_type_value=event_type.value, pipeline_name=pipeline_name, step_key=event_dict.get('stepKey'), solid_handle=SolidHandle.from_string(event_dict['solidHandleID']) if event_dict.get('solidHandleID') else None, # at the time of writing this: # * 'COMPUTE` is the only step kind # * this code should get deleted in the near future as we move away from # dagster-graphql CLI as what we invoke in dask/k8s/etc. step_kind_value='COMPUTE' if event_dict.get('stepKey') else None, logging_tags=None, event_specific_data=event_specific_data, )