Adam Bloom
10/17/2022, 7:59 PMSensor function returned an empty result
rather than the message passed in the skip reason. Am I missing something? This is what is shown in the examples, but just doesn't seem to work in reality. Note that I've mostly been using multi asset sensors, so perhaps this works with regular asset sensors but not multi asset?claire
10/17/2022, 10:37 PM@multi_asset_sensor(
...
)
def my_multi_asset_sensor(context):
return SkipReason("my message")
should display with the message passed in the skip reasonAdam Bloom
10/17/2022, 10:39 PMdef dbt_test_docs_sensor(context):
asset_events = context.latest_materialization_records_by_key()
if all(asset_events.values()):
context.advance_all_cursors()
yield RunRequest()
else:
return SkipReason("Waiting for new dbt assets")
logs:
2022-10-17 16:39:06 -0600 - dagster.daemon.SensorDaemon - INFO - Checking for new runs for sensor: dbt_test_and_doc_events
2022-10-17 16:39:06 -0600 - dagster.daemon.SensorDaemon - INFO - Sensor dbt_test_and_doc_events skipped: Sensor function returned an empty result
claire
10/17/2022, 10:42 PMAdam Bloom
10/17/2022, 10:43 PMRunRequest
return instead of yield? I can grab a log for that in a moment - in the middle of testing something elseyield RunRequest
to `return RunRequest`:
2022-10-17 16:47:37 -0600 - dagster.daemon.SensorDaemon - ERROR - Sensor daemon caught an error for sensor dbt_test_and_doc_events : dagster._core.errors.DagsterInvalidDefinitionError: Asset materializations have been handled in this sensor, but the cursor was not updated. This means the same materialization events will be handled in the next sensor tick. Use context.advance_cursor or context.advance_all_cursors to update the cursor.
Stack Trace:
File "/Users/adambloom/Library/Caches/pypoetry/virtualenvs/data-pipeline-Z0nElMr1-py3.9/lib/python3.9/site-packages/dagster/_grpc/impl.py", line 320, in get_external_sensor_execution
return sensor_def.evaluate_tick(sensor_context)
File "/Users/adambloom/Library/Caches/pypoetry/virtualenvs/data-pipeline-Z0nElMr1-py3.9/lib/python3.9/site-packages/dagster/_core/definitions/sensor_definition.py", line 1268, in evaluate_tick
result = list(self._evaluation_fn(context))
File "/Users/adambloom/Library/Caches/pypoetry/virtualenvs/data-pipeline-Z0nElMr1-py3.9/lib/python3.9/site-packages/dagster/_core/definitions/sensor_definition.py", line 1421, in _wrapped_fn
for item in result:
File "/Users/adambloom/Library/Caches/pypoetry/virtualenvs/data-pipeline-Z0nElMr1-py3.9/lib/python3.9/site-packages/dagster/_core/definitions/sensor_definition.py", line 1797, in _fn
raise DagsterInvalidDefinitionError(
claire
10/17/2022, 10:56 PMraise StopIteration()
call. So because your sensor contains both a yield and a return statement, the skip reason is ignored as it is passed to the StopIteration
exception.
Instead, you could make the function return all values instead of yielding (for example, by returning a list of run requests). Or, you can change the return SkipReason
to yield SkipReason
Adam Bloom
10/17/2022, 10:58 PMSkipReason
to yieldclaire
10/17/2022, 11:04 PMAsset materializations have been handled in this sensor, but the cursor was not updated.
error is raised erroneously for generator functions. I can fix this for the next releaseAdam Bloom
10/17/2022, 11:06 PMclaire
10/17/2022, 11:08 PMAdam Bloom
10/17/2022, 11:11 PMmulti_asset_sensor
is the generator, right? https://github.com/dagster-io/dagster/blob/master/python_modules/dagster/dagster/_core/definitions/decorators/sensor_decorator.py#L247-L248claire
10/17/2022, 11:14 PMdbt_test_docs_sensor
as the generator function as it contains a yield
statementAdam Bloom
10/17/2022, 11:14 PMreturn
s, I still get that error and that function shouldn't be a generatorreturn
for both the RunRequest
and SkipReason
btw, thanks! This is what I was expecting:
2022-10-17 17:21:23 -0600 - dagster.daemon.SensorDaemon - INFO - Checking for new runs for sensor: dbt_test_and_doc_events
2022-10-17 17:21:23 -0600 - dagster.daemon.SensorDaemon - INFO - Sensor dbt_test_and_doc_events skipped: Waiting for new dbt assets
claire
10/17/2022, 11:25 PM1.0.14
release