Pre-release alpha of Cosmos 1.16.0.
Refresh of
a2with 15 additional milestone PRs merged since the second alpha. The head branch was synced withmainagain so this cut actually contains all of them. See the release PR for full provenance, the complete 135-PR changelog, and the test plan: #3073.
Behaviour Changes
RenderConfig.excludeis now resolved against the full project graph instead of against the subsetRenderConfig.selectalready narrowed. Graph operators traverse outwards from the nodes their selector matches, so whenselecthad already dropped those root nodes the traversal had nothing to start from and shared ancestors or descendants were silently kept. For example, given aparenttaggedtestand itschild,select=["+child"], exclude=["+tag:test"]previously rendered bothparentandchild, because+tag:testwas evaluated after+childhad already been applied; it now renders onlychild. This matches dbt, which evaluates both filters against the whole graph and subtracts afterwards. See #2976.ProjectConfignow keeps themodels/seeds/snapshotsrelative paths it was configured with even when it has nodbt_project_pathof its own, andLoadMode.CUSTOMfalls back to them when the project root is supplied throughRenderConfig/ExecutionConfiginstead. Previously those relative paths were discarded in that split configuration andLegacyDbtProjectsilently crawled its defaults, so a project declaring e.g.models_relative_paths="custom/models"rendered no models at all; it now crawlscustom/modelsas configured. Projects that setdbt_project_pathonProjectConfigare unaffected. See #2977.- Under
LoadMode.DBT_MANIFEST,RenderConfig.excludeand a YAML selector'sexcludenow apply to test nodes: tests matched by the exclude (for exampleresource_type:testortag:<x>) are no longer rendered, where previously they were added back next to their model. WithTestBehavior.AFTER_EACH, a model whose tests are all excluded is rendered as a plain task instead of a run and test group, so its task ids change (for examplemodel_a.runbecomesmodel_a_run). The tests of excluded models also leaveDbtGraph.filtered_nodes. Test nodes also keep their own tags in addition to the tags of every parent, soselect tag:<x>matches a test tagged<x>whose parent is not. Anexcludenow also removes every test that depends on an excluded node, as dbt's default indirect selection does, so a multi-parent test goes with any excluded parent while the other parents stay. Selecting by a test's own tag now renders that test where the test behavior allows it: a detached task for a multi-parent test whenshould_detach_multiple_parents_tests=True, or the single test task withTestBehavior.AFTER_ALL; previously nothing was rendered. A source whose tests are all excluded no longer counts as having tests, so withsource_rendering_behavior=WITH_TESTS_OR_FRESHNESSit is rendered only if it has a freshness check. See #2981 and #3080. ExecutionMode.WATCHERconsumers of a node that dbt skipped for an upstream failure now run the node on attempt 1 once the producer has finished, instead of failing and waiting oneretry_delayfor attempt 2. Previously every level of the graph below a failed model added oneretry_delay. Test consumers whose model did not succeed do the same. This applies only when the task hasretriesset, and eitherwatcher_dbt_retry_queueis unset or the consumer already runs on it. Such a node now getsretries + 1real dbt runs instead ofretries. See #3023 and #3047.- On Airflow 3.3 and later, the
ExecutionMode.WATCHERproducer keeps its per-node XCom backup in the Airflow task store instead of an Airflow Variable whenenable_watcher_reliable_retryisTrue, split across keys that roll over at 8 KB so each push rewrites only the open key. Variable writes look the key up in every configured secrets backend first, so with an external backend the producer task ran between about 3 and 6 times faster in our benchmark, depending on how many backends are configured. WithFalsethe Variable flush from the retry callback is unchanged. A producer that finds no backup on a retry logs a warning when the task store was in use. On Airflow 3.4 and later, clearing the producer from the UI or the REST API discards that backup unless "Keep task state" is ticked; see the watcher execution mode guide. See #2771 and #3076. - Under
TestBehavior.BUILD, a rendered dbt source that has tests is now a task group (<source>.sourceand<source>.test) instead of a single<source>_sourcetask, so references to the old task id need updating. The source tests, which this mode never executed before, now run and can fail the DAG. See #1683 and #3037.
Features
- Add
AIConfig(experimental, it may change without a deprecation period), an opt-in diagnosis of failed dbt tasks: on their last attempt, an LLM is asked for the root cause and a fix, which are added after the dbt error. It usesapache-airflow-providers-common-ai(pip install astronomer-cosmos[ai], for Python 3.11+ and Airflow 2.11+), works withExecutionMode.LOCALandExecutionMode.VIRTUALENV, masks secrets, and lets you set what is sent and how much it can spend. See the AI config reference by @corsettigyg in #3018
Enhancements
- Improve
ExecutionMode.WATCHERproducer failure performance by keeping the per-node XCom backup in the Airflow task store on Airflow 3.3 and later by @tatiana in #3076
Bug Fixes
- Stop rendering tests removed by
excludeunderLoadMode.DBT_MANIFESTby @tatiana and @ege-arhan in #3080 - Resolve
excludegraph selectors against the full project graph by @00yhj22-debug in #2976 - Keep
ProjectConfigrelative paths when the project root comes fromRenderConfigby @00yhj22-debug in #2977 - Fix
ExecutionMode.WATCHERconsumers waiting oneretry_delayper level below a failure by @biswasbiplob in #3047 - Surface the macro error on
run-operationfailure with dbt < 1.12 by @barking-code in #2986 - Skip dbt event callbacks for
run-operationon dbt 2 by @pankajastro in #3089 - Fix a circular import when
cosmos.constantsis imported before Airflow by @tatiana in #3087 - Render source tests as a separate task under
TestBehavior.BUILDby @developer-rpai in #3037 - Compare dbt node statuses case-insensitively in
ExecutionMode.WATCHERand enable the watcher tests on dbt-oss, so a capitalisedWarnorErrorfrom dbt 2 is recognised by the source sensor and the default freshness callback by @pankajastro in #3088
Docs
- Document
on_failure_callbackaccess to dbt test failures by @pankajastro in #2846
Others
- Unskip dbt-oss integration tests for dbt ls and profile schema by @pankajastro in #3083
- Run the integration tests against dbt-oss on BigQuery by @pankajastro in #3046
- Run unit tests against dbt-oss in CI by @pankajastro in #3052
Milestone: Cosmos 1.16.0
Full changelog: astronomer-cosmos-v1.16.0a2...astronomer-cosmos-v1.16.0a3