예제 #1
0
파일: impl.py 프로젝트: coderanger/dagster
def get_external_sensor_execution(recon_repo, instance_ref, sensor_name,
                                  last_completion_timestamp, last_run_key):
    check.inst_param(
        recon_repo,
        "recon_repo",
        ReconstructableRepository,
    )

    definition = recon_repo.get_definition()
    sensor_def = definition.get_sensor_def(sensor_name)

    with DagsterInstance.from_ref(instance_ref) as instance:
        sensor_context = SensorExecutionContext(
            instance,
            last_completion_time=last_completion_timestamp,
            last_run_key=last_run_key)

        try:
            with user_code_error_boundary(
                    SensorExecutionError,
                    lambda:
                    "Error occurred during the execution of evaluation_fn for sensor "
                    "{sensor_name}".format(sensor_name=sensor_def.name),
            ):
                return ExternalSensorExecutionData.from_execution_data(
                    sensor_def.get_execution_data(sensor_context))
        except SensorExecutionError:
            return ExternalSensorExecutionErrorData(
                serializable_error_info_from_exc_info(sys.exc_info()))
예제 #2
0
def get_external_sensor_execution(recon_repo, instance_ref, sensor_name,
                                  last_completion_timestamp):
    check.inst_param(
        recon_repo,
        "recon_repo",
        ReconstructableRepository,
    )

    definition = recon_repo.get_definition()
    sensor_def = definition.get_sensor_def(sensor_name)

    with DagsterInstance.from_ref(instance_ref) as instance:
        sensor_context = SensorExecutionContext(
            instance, last_completion_time=last_completion_timestamp)

        try:
            with user_code_error_boundary(
                    SensorExecutionError,
                    lambda:
                    "Error occurred during the execution of evaluation_fn for sensor "
                    "{sensor_name}".format(sensor_name=sensor_def.name),
            ):
                tick_data_list = sensor_def.get_tick_data(sensor_context)
                return ExternalSensorExecutionData(
                    run_requests=[
                        tick for tick in tick_data_list
                        if isinstance(tick, RunRequest)
                    ],
                    skip_message=tick_data_list[0].skip_message
                    if tick_data_list
                    and isinstance(tick_data_list[0], SkipReason) else None,
                )

        except SensorExecutionError:
            return ExternalSensorExecutionErrorData(
                serializable_error_info_from_exc_info(sys.exc_info()))