Trigger failure in Task.map
See original GitHub issueDescription
Triggers don’t seem to call when passed to a .map() Task. Instead the .map() seems to try and process the exception value instead.
Expected Behavior
Expect the trigger to function in the same way as for non-map Task.
Reproduction
from typing import List, Dict
from prefect import Flow
from prefect import Task
from prefect.engine.cache_validators import all_parameters
from prefect.triggers import all_successful
class ExtractDummyTask(Task):
def run(self) -> List[Dict]:
records = [
{"data": "dummy"},
{"data": "dummier"},
{"data": "dummiest"},
]
raise RuntimeError("my test error")
return records
class TransformDummyTask(Task):
def run(self, data: List) -> List:
return data
class LoadDummyTask(Task):
def run(self, data: List) -> None:
print(f"Data: {data}")
extract_dummy = ExtractDummyTask(trigger=all_successful)
transform_dummy = TransformDummyTask(trigger=all_successful)
load_dummy = LoadDummyTask(trigger=all_successful)
# Create dummy flow
with Flow("dummy_flow") as flow:
# Extract
values = extract_dummy(
)
# Transform
# transformed_values = transform_dummy(data=values) # This works as expected
transformed_values = transform_dummy.map(data=values)
# Load
load_dummy(data=transformed_values)
flow.run()
Environment
Tried this locally on mac as well as local dask - same behaviour in both.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Why is my task trigger test failing - Salesforce Stack Exchange
I have a task trigger which updates two custom fields on the Account object : Last_Call_Date and Last_Meeting_Date. I have tried logging a...
Read more >Scheduled Task repeated trigger failure with a managed ...
I have set up a scheduled task on Windows Server 2012 R2 Standard, and it's failing ONLY when I set the trigger to...
Read more >Airflow Trigger Rules: All you need to know! - Marc Lamberti
With this simple trigger rule, your task gets triggered if no upstream tasks are skipped. If they are all in success or failed....
Read more >Mapping | Prefect Docs
If a reducing task has an all_successful task, but one of the mapped children failed, then the reducing task's trigger will fail. This...
Read more >How to inspect mapped tasks' inputs from reduce tasks in Prefect
The handling will largely happen in the persist_episodes . Just pass the list of inputs again and then we can match the inputs...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @cicdw - thanks for the swift reply. Yep, have just re-run against master and it seems the refactor has indeed resolved the issue.
This is definitely a bug, but for anyone reading along at home I’d like to provide some context for why this was originally implemented as intentional behavior: if a user writes a multi-level mapped Flow such as:
Note that the second level of mapped tasks ran, and some even succeeded; this is only possible because each child task was allowed to check its own trigger. If the parent had checked the trigger, it would have decided that the second level of mapped tasks was not ready to proceed (because there was an upstream failure).
The trick will be to figure out a way to fix the bug here + still satisfy this multi-level situation