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

Read filenames using case insensitive extension #2263

Conversation

sumanau7
Copy link
Contributor

@sumanau7 sumanau7 commented Mar 29, 2020

resolves #1681

Description

  1. FileSystemSearcher now finds all files ignoring the case of the extension.
  2. Add warning if core config files are found with .yaml extension in the project.

Checklist

  • I have signed the CLA
  • 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
  • I have updated the CHANGELOG.md and added information about my change to the "dbt next" section.

@cla-bot
Copy link

cla-bot bot commented Mar 29, 2020

Thanks for your pull request, and welcome to our community! We require contributors to sign our Contributor License Agreement and we don't seem to have your signature on file. Check out this article for more information on why we have a CLA.

In order for us to review and merge your code, please submit the Individual Contributor License Agreement form attached above above. If you have questions about the CLA, or if you believe you've received this message in error, don't hesitate to ping @drewbanin.

CLA has not been signed by users: @sumanau7

@beckjake
Copy link
Contributor

@cla-bot check

@cla-bot
Copy link

cla-bot bot commented Mar 30, 2020

The cla-bot has been summoned, and re-checked this pull request!

@cla-bot cla-bot bot added the cla:yes label Mar 30, 2020
@beckjake
Copy link
Contributor

Thanks for your contribution @sumanau7! It looks like flake8 is unhappy with your changes, mostly line length things - once those are fixed, tests should work:

core/dbt/parser/schemas.py:139:80: E501 line too long (80 > 79 characters)
core/dbt/parser/schemas.py:140:80: E501 line too long (89 > 79 characters)
core/dbt/parser/schemas.py:141:80: E501 line too long (90 > 79 characters)
core/dbt/parser/schemas.py:142:80: E501 line too long (99 > 79 characters)

@sumanau7 sumanau7 force-pushed the fix/read_filenames_using_case_insenstive_extension branch from f78d822 to 6b13d45 Compare March 30, 2020 16:05
Comment on lines +131 to +135
# TODO: In order to support this, make FilesystemSearcher accept a list
# of file patterns. eg: ['.yml', '.yaml']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to just return itertools.chain(yaml_files, yml_files). It won't be the most efficient thing in the world, but that's probably fine.

@sumanau7
Copy link
Contributor Author

sumanau7 commented Mar 31, 2020

@beckjake Does the overall PR looks good to be merged, for the new warning added, is the file dbt/unit/test_parser.py right place to add the unit test for it ?

@sumanau7 sumanau7 marked this pull request as ready for review March 31, 2020 16:51
Copy link
Contributor

@beckjake beckjake left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this unit test looks good!

I think for the warning, this should get an integration test. The tests in test/integration/008_schema_tests_test are a sort of reasonable place to start. In particular, check out the TestQuotedSchemaTestColumns test, which makes use of the quote-required-models folder inn there. You'll want to do similar to that test:

  • create a models folder for the test
  • put a model ending with (.sql) in it. It can just be something like select 1 as id.
  • put a schema.yml file with .yaml in there and declare a test on the model (probably just a unique test on id)
  • make sure results = self.run_dbt(["run"], strict=False) passes and that len(results) == 1
  • make sure results = self.run_dbt(["test"], strict=False) passes and that len(results) == 1
  • make sure results = self.run_dbt(["run"]) fails with an error (because strict mode is enabled). You will probably have to use something like this:
with self.assertRaises(dbt.exceptions.Exception) as exc:
    self.run_dbt(["run"])
self.assertIn('yaml', str(exc.exception)

You'll also want to add a second test that does the same but uses a file ending in .SQL, I think. That test might have to get skipped on windows.

core/dbt/parser/schemas.py Outdated Show resolved Hide resolved
self.project, self.project.all_source_paths, '.yaml'
)
if yaml_files:
logger.warning(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instead of logger.warning, we want exceptions.warn_or_error here.

@beckjake
Copy link
Contributor

@sumanau7 This is a great PR so far, thanks for your contribution! This PR definitely merits some tests (I don't want to regress and break this in the future!) and we have some internal conventions on how we handle warnings that I have suggestions on, but this is all very minor.

@cla-bot
Copy link

cla-bot bot commented Apr 5, 2020

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Sumanau Sareen.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@cla-bot cla-bot bot removed the cla:yes label Apr 5, 2020
@sumanau7 sumanau7 force-pushed the fix/read_filenames_using_case_insenstive_extension branch from c7acc8d to 1b8d58b Compare April 5, 2020 17:25
@cla-bot cla-bot bot added the cla:yes label Apr 5, 2020
@sumanau7 sumanau7 force-pushed the fix/read_filenames_using_case_insenstive_extension branch 2 times, most recently from edb3a72 to 647b3ba Compare April 7, 2020 05:01
@sumanau7
Copy link
Contributor Author

sumanau7 commented Apr 7, 2020

@beckjake let me know if integration tests looks good, i will proceed to update changes in changelog

test/unit/test_system_client.py Outdated Show resolved Hide resolved
@sumanau7 sumanau7 force-pushed the fix/read_filenames_using_case_insenstive_extension branch from 647b3ba to 527e6c2 Compare April 7, 2020 16:19
core/dbt/parser/schemas.py Outdated Show resolved Hide resolved
…egration test for checking case-insensitive extensions
@sumanau7 sumanau7 force-pushed the fix/read_filenames_using_case_insenstive_extension branch from 527e6c2 to f9343c4 Compare April 7, 2020 16:38
@beckjake
Copy link
Contributor

beckjake commented Apr 7, 2020

Ok, thanks! I've kicked off tests again and I truly believe this is it, though no promises 😆

I appreciate you sticking with this, I know it's a pain!

@sumanau7
Copy link
Contributor Author

sumanau7 commented Apr 7, 2020

Ok, thanks! I've kicked off tests again and I truly believe this is it, though no promises 😆

I appreciate you sticking with this, I know it's a pain!

Don't worry about it, you guys are the best.

@cla-bot
Copy link

cla-bot bot commented Apr 7, 2020

Thank you for your pull request and welcome to our community. We could not parse the GitHub identity of the following contributors: Sumanau Sareen.
This is most likely caused by a git client misconfiguration; please make sure to:

  1. check if your git client is configured with an email to sign commits git config --list | grep email
  2. If not, set it up using git config --global user.email email@example.com
  3. Make sure that the git commit email is configured in your GitHub account settings, see https://github.com/settings/emails

@cla-bot cla-bot bot removed the cla:yes label Apr 7, 2020
@sumanau7 sumanau7 force-pushed the fix/read_filenames_using_case_insenstive_extension branch from 70628d1 to 6f302e2 Compare April 7, 2020 17:20
@cla-bot cla-bot bot added the cla:yes label Apr 7, 2020
@beckjake beckjake merged commit 380f7c2 into dbt-labs:dev/octavius-catto Apr 8, 2020
@beckjake
Copy link
Contributor

beckjake commented Apr 8, 2020

This will make it into 0.17.0 when that's released. Thanks so much for contributing to dbt!

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

Successfully merging this pull request may close these issues.

Support reading both yml and yaml file extensions for schema configuration files.
3 participants