-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
bugfix: respect config options in dbt_project.yml #255
Merged
Merged
Changes from 12 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
4811888
bugfix: respect config options in dbt_project.yml
cd531aa
unit test harness
29a31bd
remove now-unused test runner
7912de0
Merge branch 'development' of github.com:analyst-collective/dbt into …
6ae353c
add newline to the end of .gitignore
16418ae
create a working windows test directory
1aad991
fix CHANGELOG.mg pointer
9afcb79
update wording of changelog entry
05ab471
solve KeyError when config is not set
fceb38a
add test for existing file, with no config key (catch KeyError from l…
1a4f607
merge development
50d2726
remove undefined default_profiles_dir
5db3c99
remove None default, add a TODO around argument validation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os.path | ||
import yaml | ||
|
||
import dbt.project as project | ||
|
||
|
||
def read_config(profiles_dir=None): | ||
path = os.path.join(profiles_dir, 'profiles.yml') | ||
|
||
if os.path.isfile(path): | ||
with open(path, 'r') as f: | ||
profile = yaml.safe_load(f) | ||
return profile.get('config', {}) | ||
|
||
return {} | ||
|
||
|
||
def send_anonymous_usage_stats(profiles_dir): | ||
config = read_config(profiles_dir) | ||
|
||
if config is not None and config.get("send_anonymous_usage_stats") == False: | ||
return False | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
. /usr/src/app/test/setup.sh | ||
workon dbt | ||
|
||
cd /usr/src/app | ||
tox -e integration-py27,integration-py35 |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import os | ||
import unittest | ||
import yaml | ||
|
||
import dbt.config | ||
|
||
if os.name == 'nt': | ||
TMPDIR = 'c:/Windows/TEMP' | ||
else: | ||
TMPDIR = '/tmp' | ||
|
||
class ConfigTest(unittest.TestCase): | ||
|
||
def set_up_empty_config(self): | ||
profiles_path = '{}/profiles.yml'.format(TMPDIR) | ||
|
||
with open(profiles_path, 'w') as f: | ||
f.write(yaml.dump({})) | ||
|
||
def set_up_config_options(self, send_anonymous_usage_stats=False): | ||
profiles_path = '{}/profiles.yml'.format(TMPDIR) | ||
|
||
with open(profiles_path, 'w') as f: | ||
f.write(yaml.dump({ | ||
'config': { | ||
'send_anonymous_usage_stats': send_anonymous_usage_stats | ||
} | ||
})) | ||
|
||
def tearDown(self): | ||
profiles_path = '{}/profiles.yml'.format(TMPDIR) | ||
|
||
try: | ||
os.remove(profiles_path) | ||
except: | ||
pass | ||
|
||
def test__implicit_opt_in(self): | ||
self.set_up_empty_config() | ||
self.assertTrue(dbt.config.send_anonymous_usage_stats(TMPDIR)) | ||
|
||
def test__explicit_opt_out(self): | ||
self.set_up_config_options(send_anonymous_usage_stats=False) | ||
self.assertFalse(dbt.config.send_anonymous_usage_stats(TMPDIR)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
|
||
def test__explicit_opt_in(self): | ||
self.set_up_config_options(send_anonymous_usage_stats=True) | ||
self.assertTrue(dbt.config.send_anonymous_usage_stats(TMPDIR)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think passing
None
toos.path.join
causes aTypeError
.Previously, this file was assumed to be located at
~/.dbt/profiles.yml
. We should either remove the default value forprofiles_dir
and insist that the caller passes a value, or we should coalesceNone
to the default filepathThere 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.
this is a good call. since
read_config
is part of the private API of this namespace, and calls have to go throughsend_anonymous_usage_stats
, i just removed the defaultNone
value.