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

Stop mis-identifying unit_test config paths in dbt_project.yaml as unused #10312

Conversation

QMalcolm
Copy link
Contributor

resolves #10311

Problem

unit_tests weren't being included in calls to Manifest.get_resource_fqns, it always appeared to _warn_for_unused_resource_config_paths that there were no unit tests in the manifest. Thus, _warn_for_unused_resource_config_paths always thought that any unit_test config in dbt_project.yaml was unused.

Solution

Include unit_tests in Manifest.get_resource_fqns

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

We're doing this in preperation to a for a unit test which will be testing
these nodes (as well as others) and thus we want them in the manifest.
In the previous commit, 58990aa, we added
the `saved_query` fixture to the `manifest` fixture. This broke the test
`tests/unit/parser/test_manifest.py::TestPartialParse::test_partial_parse_by_version`.
It broke because the `Manifest.deepcopy` manifest basically dictifies things. When we were
dictifying the `QueryParams` of the `saved_query` before, the `where` key was getting
dropped because it was `None`. We'd then run into a runtime error on instantiation of the
`QueryParams` because although `where` is declared as _optional_, we don't set a default
value for it. And thus, kaboom :(

We should probably provide a default value for `where`. However that is out of scope
for this branch of work.
In 58990aa we added a semantic model
to the `manifest` fixture. This broke the test
`tests/unit/graph/test_selector_methods.py::test_select_fqn` because in
the test it selects nodes based on the string `*.*.*_model`. The newly
added semantic model matches this, and thus needed to be added to the
expected results.
Note: At this point the test when run with for a `unit_test` config
taht should be considered used, fails. This is because it is not being
properly identified as used.
Because `unit_tests` weren't being included in calls to `Manifest.get_resource.fqns`,
it always appeared to `_warn_for_unused_resource_config_paths` that there were no
unit tests in the manifest. Because of this `_warn_for_unused_resource_config_paths` thought
that _any_ `unit_test` config in `dbt_project.yaml` was unused.
@QMalcolm QMalcolm requested a review from a team as a code owner June 14, 2024 01:37
@cla-bot cla-bot bot added the cla:yes label Jun 14, 2024
Copy link

codecov bot commented Jun 14, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 88.69%. Comparing base (d4a6482) to head (ffd1272).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10312      +/-   ##
==========================================
- Coverage   88.76%   88.69%   -0.07%     
==========================================
  Files         180      180              
  Lines       22483    22483              
==========================================
- Hits        19957    19942      -15     
- Misses       2526     2541      +15     
Flag Coverage Δ
integration 85.95% <ø> (-0.14%) ⬇️
unit 61.86% <ø> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@QMalcolm QMalcolm merged commit 100352d into main Jun 14, 2024
70 checks passed
@QMalcolm QMalcolm deleted the qmalcolm--10311-stop-mis-identifying-unit-test-config-paths-as-unused branch June 14, 2024 16:27
Copy link
Contributor

The backport to 1.8.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.8.latest 1.8.latest
# Navigate to the new working tree
cd .worktrees/backport-1.8.latest
# Create a new branch
git switch --create backport-10312-to-1.8.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 100352d6b43e6fd1ec6806ced0b474714f484ed8
# Push it to GitHub
git push --set-upstream origin backport-10312-to-1.8.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.8.latest

Then, create a pull request where the base branch is 1.8.latest and the compare/head branch is backport-10312-to-1.8.latest.

2 similar comments
Copy link
Contributor

The backport to 1.8.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.8.latest 1.8.latest
# Navigate to the new working tree
cd .worktrees/backport-1.8.latest
# Create a new branch
git switch --create backport-10312-to-1.8.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 100352d6b43e6fd1ec6806ced0b474714f484ed8
# Push it to GitHub
git push --set-upstream origin backport-10312-to-1.8.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.8.latest

Then, create a pull request where the base branch is 1.8.latest and the compare/head branch is backport-10312-to-1.8.latest.

Copy link
Contributor

The backport to 1.8.latest failed:

The process '/usr/bin/git' failed with exit code 1

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.8.latest 1.8.latest
# Navigate to the new working tree
cd .worktrees/backport-1.8.latest
# Create a new branch
git switch --create backport-10312-to-1.8.latest
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 100352d6b43e6fd1ec6806ced0b474714f484ed8
# Push it to GitHub
git push --set-upstream origin backport-10312-to-1.8.latest
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.8.latest

Then, create a pull request where the base branch is 1.8.latest and the compare/head branch is backport-10312-to-1.8.latest.

@QMalcolm QMalcolm restored the qmalcolm--10311-stop-mis-identifying-unit-test-config-paths-as-unused branch June 14, 2024 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

All unit_test configs in dbt_project.yaml are incorrectly identified as being unused
2 participants