Creating on_warning_callback arg for better warning management#225
Conversation
# Conflicts: # cosmos/providers/dbt/core/operators.py
jlaneve
left a comment
There was a problem hiding this comment.
Hey @CorsettiS, this is an amazing idea! I think it may be a bit too opinionated in terms of how we're handling the behavior when there's a warning. What do you think about the following:
- instead of baking the
send_slack_alertfunction directly into the package, what if we make a more generalon_warning_callback? Or even anon_completion_callbackwhere we pass in context about the dbt output and let the user decide what they'd like to do with it - add documentation about how to use the callback to send alerts on failure - that's where we can provide the code snippet on how to send a message in slack, for example
I think that'd be helpful to extend this functionality past slack - maybe someone wants to use the same pattern to send an email, etc.
What do you think?
hey @jlaneve I really liked the idea of creating a |
|
Since the image will only be rendered once the PR is merged, I will attach here an image of how the documentation would look like with it. Update (2022-04-08):
@jlaneve I am done on this side. If there is anything you would recommend me to change, I am all ears. Update (2022-04-13):
|
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #225 +/- ##
==========================================
- Coverage 79.76% 77.42% -2.34%
==========================================
Files 28 30 +2
Lines 1003 1094 +91
==========================================
+ Hits 800 847 +47
- Misses 203 247 +44
☔ View full report in Codecov by Sentry. |
…ion on the adapted_subprocesshook.py
# Conflicts: # cosmos/providers/dbt/core/utils/tests/test_warn_parsing.py
jlaneve
left a comment
There was a problem hiding this comment.
just one more small change - then this is good to merge! thank you for iterating on this
[Giovanni Corsetti Silva](https://www.linkedin.com/in/giovanni-corsetti/) (@corsettigyg @CorsettiS @giovannicorsetti) is a Core Data Platform Data Engineer at [Get Your Guide](https://www.getyourguide.com/). He's a Brazilian based in Berlin (Germany) and has been an early adopter of Cosmos, using it regularly throughout his career. Not only has he been using Cosmos since the early stages, but he has consistently improved Cosmos since April 2023: <img width="494" height="249" alt="Screenshot 2025-09-17 at 16 39 49" src="https://github.com/user-attachments/assets/ff9b0055-7df6-47a4-8efa-83a30d5aee99" /> ] m. , <img width="492" height="252" alt="Screenshot 2025-09-17 at 16 40 11" src="https://github.com/user-attachments/assets/8402d883-eff4-46aa-9ae7-afe35bd39a6e" /> <img width="499" height="256" alt="Screenshot 2025-09-17 at 16 39 23" src="https://github.com/user-attachments/assets/c6b84245-aae1-46e6-99e3-552553619dd9" /> His contributions include new features, enhancements, bug fixes and also improvements on the local dev setup, as it can see in some of the many contributions he's done to the project so far: * #1787 * #1761 * #1695 * #1693 * #1663 * #1571 * #1449 * #1099 * #1091 * #419 * #402 * #355 * #354 * #225 Additionally, he has been interacting with users in the #airflow-dbt Slack channel in a very collaborative and supportive way. We want to promote him as a Cosmos committer and maintainer for all these, recognising his constant efforts and achievements towards our community. Thank you very much, @corsettigyg! From this moment, you have write permissions on the repo: <img width="884" height="93" alt="Screenshot 2025-09-18 at 14 34 07" src="https://github.com/user-attachments/assets/abcc8c42-87cf-4b32-a7be-81127190d164" />

In airflow, errors are handled by default with callback functions and/or email alerts, however when we are integrating DBT with airflow, there is an extra case to consider: warnings
When running tests against a dataset, it would be really interesting to also add the possibility to communicate the WARN messages that got triggered in some way, since so far the WARNs can only be found inside the logs, which is no different from a blackbox for companies dealing with many DAGs. We should communicate if a warn is observed in the logs in a more transparent way.
To accomplish that, we can change the DbtTestOperator by adding 1 extra param to it
(Updating after suggestion)