def test_opt_generator(): def _test_gen(): yield 1 assert check.opt_generator(_test_gen()) gen = _test_gen() assert check.opt_generator(gen) assert check.opt_generator(None) is None with pytest.raises(ParameterCheckError): assert check.opt_generator(list(gen)) with pytest.raises(ParameterCheckError): assert check.opt_generator(_test_gen)
def _user_event_sequence_for_step_compute_fn(step_context, evaluated_inputs): check.inst_param(step_context, 'step_context', SystemStepExecutionContext) check.dict_param(evaluated_inputs, 'evaluated_inputs', key_type=str) with user_code_error_boundary( DagsterExecutionStepExecutionError, msg_fn=lambda: '''Error occured during the execution of step: step key: "{key}" solid invocation: "{solid}" solid definition: "{solid_def}" '''.format( key=step_context.step.key, solid_def=step_context.solid_def.name, solid=step_context.solid.name, ), step_key=step_context.step.key, solid_def_name=step_context.solid_def.name, solid_name=step_context.solid.name, ): gen = check.opt_generator( step_context.step.compute_fn(step_context, evaluated_inputs)) if gen is not None: for event in gen: yield event
def _iterate_step_outputs_within_boundary(step_context, evaluated_inputs): check.inst_param(step_context, 'step_context', SystemStepExecutionContext) check.dict_param(evaluated_inputs, 'evaluated_inputs', key_type=str) error_str = '''Error occured during the execution of step: step key: "{key}" solid instance: "{solid}" solid definition: "{solid_def}" '''.format( key=step_context.step.key, solid_def=step_context.solid_def.name, solid=step_context.solid.name, ) with user_code_error_boundary( DagsterExecutionStepExecutionError, error_str, step_key=step_context.step.key, solid_def_name=step_context.solid_def.name, solid_name=step_context.solid.name, ): gen = check.opt_generator( step_context.step.compute_fn(step_context, evaluated_inputs)) if gen is not None: for step_output in gen: yield step_output
def _user_event_sequence_for_step_compute_fn(step_context, evaluated_inputs): check.inst_param(step_context, "step_context", SystemStepExecutionContext) check.dict_param(evaluated_inputs, "evaluated_inputs", key_type=str) with user_code_error_boundary( DagsterExecutionStepExecutionError, control_flow_exceptions=[Failure, RetryRequested], msg_fn=lambda: """Error occurred during the execution of step: step key: "{key}" solid invocation: "{solid}" solid definition: "{solid_def}" """.format( key=step_context.step.key, solid_def=step_context.solid_def.name, solid=step_context.solid.name, ), step_key=step_context.step.key, solid_def_name=step_context.solid_def.name, solid_name=step_context.solid.name, ): gen = check.opt_generator( step_context.step.compute_fn(step_context, evaluated_inputs)) if gen is not None: for event in gen: yield event
def _iterate_step_output_values_within_boundary(step_context, evaluated_inputs): check.inst_param(step_context, 'step_context', StepExecutionContext) check.dict_param(evaluated_inputs, 'evaluated_inputs', key_type=str) error_str = 'Error occured during step {key}'.format( key=step_context.step.key) with _execution_step_error_boundary(step_context, error_str): gen = check.opt_generator( step_context.step.compute_fn(step_context, evaluated_inputs)) if gen is not None: for step_output_value in gen: yield step_output_value