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

[Fix] Limit check-source-has-tests-by-group hook to yaml files #100

Merged
merged 2 commits into from
Feb 24, 2023
Merged

[Fix] Limit check-source-has-tests-by-group hook to yaml files #100

merged 2 commits into from
Feb 24, 2023

Conversation

katieclaiborne
Copy link
Contributor

@katieclaiborne katieclaiborne commented Feb 23, 2023

In #91, it was my commit that inadvertently added sql to the types_or list for the check-source-has-tests-by-group.

I was naively pattern-matching based on the check-model-has-tests-by-group hook, and didn't think through the implications of the addition.

As we've started to use the new hook, we've run into an AttributeError that occurs when the hook is run over .sql files.

Check the source tests by test group.....................................Failed
- hook id: check-source-has-tests-by-group
- exit code: 1

Traceback (most recent call last):
  File "/home/runner/.cache/pre-commit/repov8wo5h41/py_env-python3/bin/check-source-has-tests-by-group", line 8, in <module>
    sys.exit(main())
  File "/home/runner/.cache/pre-commit/repov8wo5h41/py_env-python3/lib/python3.10/site-packages/pre_commit_dbt/check_source_has_tests_by_group.py", line 85, in main
    return check_test_cnt(
  File "/home/runner/.cache/pre-commit/repov8wo5h41/py_env-python3/lib/python3.10/site-packages/pre_commit_dbt/check_source_has_tests_by_group.py", line 30, in check_test_cnt
    for schema in schemas:
  File "/home/runner/.cache/pre-commit/repov8wo5h41/py_env-python3/lib/python3.10/site-packages/pre_commit_dbt/utils.py", line 2[35](https://github.com/cityblock/data-platform/actions/runs/4255882670/jobs/7404092720#step:10:36), in get_source_schemas
    for source in schema.get("sources", []):
AttributeError: 'str' object has no attribute 'get'

By restoring the types_or to the appropriate value, the hook correctly skips SQL files that are passed in.

image

@katieclaiborne katieclaiborne changed the title Katie/attribute error [Fix] Limit check-source-has-tests-by-group hook to yaml files Feb 23, 2023
@katieclaiborne katieclaiborne marked this pull request as ready for review February 23, 2023 21:09
@katieclaiborne
Copy link
Contributor Author

@ssassi, would you be able to take a look at this fix?

Thanks to my teammate @eve-johns for identifying the issue!

@BAntonellini
Copy link
Collaborator

@ssassi, would you be able to take a look at this fix?

Thanks to my teammate @eve-johns for identifying the issue!

@katieclaiborne I agree with this fix, there is no point in checking if tests exist in SQL files, for the main reason that sources in dbt, alongside it's tests, are defined in YMLs.

@BAntonellini BAntonellini merged commit c0a97eb into dbt-checkpoint:main Feb 24, 2023
@katieclaiborne katieclaiborne deleted the katie/attribute-error branch February 24, 2023 14:53
@katieclaiborne
Copy link
Contributor Author

katieclaiborne commented Feb 24, 2023

I agree with this fix, there is no point in checking if tests exist in SQL files, for the main reason that sources in dbt, alongside it's tests, are defined in YMLs.

Thank you, Bruno!

@katieclaiborne
Copy link
Contributor Author

Any news on an upcoming release?

@BAntonellini
Copy link
Collaborator

@

Any news on an upcoming release?

We've already drafted the content of the future 1.1 release, but will wait for a new service that is in merge process to complete and publish it.

@katieclaiborne
Copy link
Contributor Author

We've already drafted the content of the future 1.1 release, but will wait for a new service that is in merge process to complete and publish it.

Amazing! Thanks for all your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants