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
Allow model filtering #45
Conversation
Thanks for the PR @followingell -- I'll take a closer look at it later today 🙂 |
@mrshu Not sure where the above comment has gone(?), regardless responding here rather than via email: I think this StackOverflow answer sums it up quite nicely. Essentially, If you'd rather I just use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this together @followingell!
In general, this looks rather nicely -- I've only put a couple of comments here and there to see if I understood the whole concept correctly. Once we get those resolved, we can simply merge it in 🙂
Thanks!
dbt_coverage/__init__.py
Outdated
original_tables_dict = {key: val for key, val in self.tables.items()} | ||
for key, table in original_tables_dict.items(): | ||
for path in model_path_filter: | ||
if path in table.original_file_path: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@followingell how would you feel about changing this to table.original_file_path.startswith(path)
? I am mostly concerned about the unintended consequences of having say the staging/
and pre-staging/
folders in one's project and as it currently is, I am afraid --model-path-filter staging/
would cover both.
Alternatively, having a regex option would certainly work too 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mrshu Again, great thoughts r.e. covering both staging/
and pre-staging/
unintentionally when using --model-path-filter staging/
with my previous implementation.
As per your suggestion I have swapped the code to use startswith
and had this reflected in the README since this provides as much control as before whilst reducing the potential for unintended inclusions as outlined above.
Co-authored-by: Marek Šuppa <mrshu@users.noreply.github.com>
@mrshu FYI for now I have finished with changes. As such, ready for review 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your patience @followingell -- this is very nicely done and I like it quite a bit!
Thanks again @followingell , this was now released in |
Issue
Summary
I added the ability to perform
compute
commands on only a subset of tables by adding a--model-path-filter
option. This means that a subset of models can be selected based upon theiroriginal_file_path
value (taken from themanifest.json
artifact).This functionality means that
dbt-coverage
can now be used in monolithic dbt projects which contain sub-projects owned by different teams. Before adding model selection functionality, usingdbt-coverage
would not have been useful/advisable in such a structure because another, unrelated team may decrease the overall coverage, which can then block PR merging (shoulddbt-coverage
have been integrated as part of a CI/CD pipeline for example).README.md
below:Note: this is a relatively 'rough' solution and there are likely many improvements that could be made to my code / far more elegant implementations that would achieve the same functionality. Please, feel free to suggest changes!
Testing
jaffle_shop
'testing project' and have not encountered issues so far.