Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] [1.3.2] tests on sources do not render #875

Closed
Tracked by #1103
push2prod opened this issue Mar 3, 2024 · 2 comments · Fixed by #1107
Closed
Tracked by #1103

[bug] [1.3.2] tests on sources do not render #875

push2prod opened this issue Mar 3, 2024 · 2 comments · Fixed by #1107
Assignees
Labels
area:testing Related to testing, like unit tests, integration tests, etc dbt:test Primarily related to dbt test command or functionality execution:local Related to Local execution environment parsing:dbt_manifest Issues, questions, or features related to dbt_manifest parsing
Milestone

Comments

@push2prod
Copy link

because sources are not natively rendered as models(only by using the experimental feature) i think tests on sources do not render as well.
I tried rendering the sources as dummy operators and trying the AFTER_ALL test behavior but nothing seemed to work.
it would be very convenient to test sources right before running to avoid any problems with dbt pipelines and would greatly appreciate a patch.

we're using local mode with manifest file without any selectors with airflow 2.5.2(if it matters).

Copy link

dosubot bot commented Mar 3, 2024

Hey @push2prod, great to see you around again! Hope you're doing well.

Thank you for bringing this to our attention. It seems like you're encountering an issue with tests on sources not rendering when using Cosmos with the DBT Manifest File method.

From the context provided, Cosmos uses multiple methods to render tests on sources, and one of them is loading from a DBT Manifest File. This method directly loads the DBT graph from the manifest file. However, it seems like this method might not be working as expected in your case.

The process Cosmos follows to render tests on sources when using the DBT Manifest File method involves several steps, including loading the manifest file, parsing it to extract nodes, sources, and exposures, filtering nodes based on the selection and exclusion criteria, and updating nodes with test information.

If the tests on sources are not rendering, it could be due to a variety of reasons. Here are a few things you could check:

  1. Manifest Availability: Ensure that the manifest file is available and the path is correctly specified in the project configuration. If the manifest file is not available, Cosmos will raise a CosmosLoadDbtException.

  2. Execution Path: Make sure that the execution configuration's project path is set. If not, Cosmos will raise a CosmosLoadDbtException.

  3. Selector Support: Cosmos does not support selectors when loading dbt projects using the DBT Manifest File method. If a selector is provided in the RenderConfig, Cosmos will raise a CosmosLoadDbtException.

  4. Node Filtering: Check the selection and exclusion criteria specified in the RenderConfig. Cosmos filters nodes based on these criteria. If the tests on sources are not included in the selection or are excluded, they will not be rendered.

  5. Test Information: Cosmos updates nodes with test information by marking nodes as having tests if they are dependencies of test nodes. Ensure that the tests on sources are correctly defined as dependencies of the relevant nodes.

If you've checked all of these and the issue persists, it would be helpful if you could provide more information about your setup and the exact steps you're following. This will help us better understand the issue and find a suitable solution.

For reference, you can find more details about the DBT Manifest File method and the process Cosmos follows to render tests on sources in the cosmos/dbt/graph.py file and the tests/dbt/test_graph.py file.

Sources

About Dosu

This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@dosubot dosubot bot added area:testing Related to testing, like unit tests, integration tests, etc dbt:test Primarily related to dbt test command or functionality execution:local Related to Local execution environment parsing:dbt_manifest Issues, questions, or features related to dbt_manifest parsing labels Mar 3, 2024
@tatiana tatiana added bug Something isn't working and removed bug Something isn't working labels May 17, 2024
@tatiana
Copy link
Collaborator

tatiana commented May 17, 2024

@push2prod Please, could you share a reproducible example of DAG of what you tried to do, what you saw, and confirm if you'd like to see the tests bundled in task groups, together with the sources, or rendered by the end of the TaskGroup/DAG?

@tatiana tatiana added this to the 1.6.0 milestone May 17, 2024
@tatiana tatiana mentioned this issue Jul 31, 2024
18 tasks
tatiana pushed a commit that referenced this issue Aug 14, 2024
Re-Opening of PR #661

This PR features a new way of rendering source nodes:
- Check freshness for sources with freshness checks
- Source tests
- Empty operators for nodes without tests or freshness.

One of the main limitations I found while using the `custom_callback`
functions on source nodes to check freshness is that nodes were being
created on 100% of sources but not all of them required freshness
checks, this made workers waste compute time.

I'm adding a new variable into the DbtNode class called has_freshness
which would be True for sources with freshness checks and False for any
other resource type.

If this feature is enabled with the option `ALL`:
All sources with the has_freshness == False will be rendered as Empty
Operators, to keep the dbt's behavior of showing sources as suggested in
issue #630
<!-- Add a brief but complete description of the change. -->

A new rendered template field is included too: `freshness` which is the
sources.json generated by dbt when running `dbt source freshness`

This adds a new node type (source), which changes some tests behavior.
This PR also updates the dev dbt project jaffle_shop to include source
nodes when enabled.

![image](https://github.com/user-attachments/assets/e972ac58-8741-4c13-9905-e78775f9cc80)

As seen in the image, source nodes with freshness checks are rendered
with a blue color, while the ones rendered as EmptyOperator show a
white/light green color

Closes: #630
Closes: #572
Closes: #875
<!-- If this PR closes an issue, you can use a keyword to auto-close.
-->
<!-- i.e. "closes #0000" -->

This won't be a breaking change since the default behavior will still be
ignoring this new feature. That can be changed with the new RenderConfig
variable called `source_rendering_behavior`.

Co-authored-by: Pankaj <[email protected]>
Co-authored-by: Pankaj Singh <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:testing Related to testing, like unit tests, integration tests, etc dbt:test Primarily related to dbt test command or functionality execution:local Related to Local execution environment parsing:dbt_manifest Issues, questions, or features related to dbt_manifest parsing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants