Skip to content

Commit

Permalink
prep 0.7.0 (#280)
Browse files Browse the repository at this point in the history
- update deprecations
- include snowflake sample profile
  • Loading branch information
cmcarthur authored Feb 8, 2017
2 parents aeedb53 + a45735a commit bc8a188
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 69 deletions.
23 changes: 8 additions & 15 deletions dbt/deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,14 @@ def show(self, *args, **kwargs):
logger.info("* Deprecation Warning: {}\n".format(desc))
active_deprecations.add(self.name)


class DBTRunTargetDeprecation(DBTDeprecation):
name = 'run-target'
description = """profiles.yml configuration option 'run-target' is
deprecated. Please use 'target' instead. The 'run-target' option will be
removed (in favor of 'target') in DBT version 0.7.0"""


class DBTInvalidPackageName(DBTDeprecation):
name = 'invalid-package-name'
description = """The package name '{package_name}' is not valid. Package
names must only contain letters and underscores. Packages with invalid
names will fail to compile in DBT version 0.7.0"""
# Leaving this as an example. Make sure to add new ones to deprecations_list
# - Connor
#
# class DBTRunTargetDeprecation(DBTDeprecation):
# name = 'run-target'
# description = """profiles.yml configuration option 'run-target' is
# deprecated. Please use 'target' instead. The 'run-target' option will be
# removed (in favor of 'target') in DBT version 0.7.0"""


def warn(name, *args, **kwargs):
Expand All @@ -42,8 +37,6 @@ def warn(name, *args, **kwargs):
active_deprecations = set()

deprecations_list = [
DBTRunTargetDeprecation(),
DBTInvalidPackageName()
]

deprecations = {d.name: d for d in deprecations_list}
Expand Down
13 changes: 6 additions & 7 deletions dbt/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,7 @@ def get(self, key, default=None):
return self.cfg.get(key, default)

def handle_deprecations(self):
if 'run-target' in self.cfg:
dbt.deprecations.warn('run-target')
self.cfg['target'] = self.cfg['run-target']

if not self.is_valid_package_name():
dbt.deprecations.warn(
'invalid-package-name', package_name=self['name'])
pass

def is_valid_package_name(self):
if re.match(r"^[^\d\W]\w*\Z", self['name']):
Expand Down Expand Up @@ -124,6 +118,11 @@ def validate(self):
raise DbtProjectError(
"Project name and version is not provided", self)

if not self.is_valid_package_name():
raise DbtProjectError(
('Package name can only contain letters, numbers, and '
'underscores, and must start with a letter.'), self)

validator = dbt.contracts.connection.credentials_mapping.get(
target_cfg.get('type'), None)

Expand Down
12 changes: 10 additions & 2 deletions sample.profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ evil-corp:
pass: pa55word
dbname: warehouse
schema: analytics # use the prod schema instead
snowflake: # specify the snowflake connection
type: snowflake
threads: 1
account: evilcorp # the url prefix for your snowflake connection,
# i.e. evilcorp.snowflakecomputing.com
user: elliot
password: pa55word
database: warehouse
schema: analytics # use the prod schema instead

target: dev # default target is dev unless changed at run time

mr-robot:
Expand Down Expand Up @@ -86,5 +96,3 @@ mr-robot:
# $ dbt run --profile mr-robot
# $ dbt run --profile mr-robot --target dev
# $ dbt run --profile mr-robot --target prod


45 changes: 0 additions & 45 deletions test/integration/012_profile_config_tests/test_profile_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,51 +2,6 @@
from test.integration.base import DBTIntegrationTest
import dbt.deprecations

class TestRunTargetDeprecation(DBTIntegrationTest):

def setUp(self):
DBTIntegrationTest.setUp(self)

dbt.deprecations.reset_deprecations()
self.run_sql_file("test/integration/012_profile_config_tests/seed.sql")

@property
def schema(self):
return "profile_config_012"

@property
def models(self):
return "test/integration/012_profile_config_tests/models"

@property
def profile_config(self):
return {
'test': {
'outputs': {
'my-target': {
'type': 'postgres',
'threads': 1,
'host': 'database',
'port': 5432,
'user': 'root',
'pass': 'password',
'dbname': 'dbt',
'schema': self.schema
}
},
'run-target': 'my-target'
}
}

@attr(type='postgres')
def test_deprecated_run_target_config(self):
self.run_dbt()

self.assertTablesEqual("seed","view")

self.assertTrue('run-target' in dbt.deprecations.active_deprecations)


class TestNoRunTargetDeprecation(DBTIntegrationTest):

def setUp(self):
Expand Down

0 comments on commit bc8a188

Please sign in to comment.