From 1450855e410031b20f16d21068f28a4b608938b8 Mon Sep 17 00:00:00 2001 From: Connor McArthur Date: Tue, 7 Feb 2017 16:14:38 -0500 Subject: [PATCH 1/3] update deprecations --- dbt/deprecations.py | 23 ++++------ dbt/project.py | 8 +--- .../test_profile_config.py | 45 ------------------- 3 files changed, 9 insertions(+), 67 deletions(-) diff --git a/dbt/deprecations.py b/dbt/deprecations.py index 676c5dce849..a4e1a222934 100644 --- a/dbt/deprecations.py +++ b/dbt/deprecations.py @@ -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): @@ -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} diff --git a/dbt/project.py b/dbt/project.py index 421adcecf6e..135c0c2956a 100644 --- a/dbt/project.py +++ b/dbt/project.py @@ -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']): diff --git a/test/integration/012_profile_config_tests/test_profile_config.py b/test/integration/012_profile_config_tests/test_profile_config.py index 59d8e9f52e3..bfa6f13b1e3 100644 --- a/test/integration/012_profile_config_tests/test_profile_config.py +++ b/test/integration/012_profile_config_tests/test_profile_config.py @@ -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): From ba0b4597a84bf485cad9ede2ea99d82cd306575a Mon Sep 17 00:00:00 2001 From: Connor McArthur Date: Tue, 7 Feb 2017 16:20:39 -0500 Subject: [PATCH 2/3] add a snowflake profile --- sample.profiles.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sample.profiles.yml b/sample.profiles.yml index c5bcc7e976c..7678feea838 100644 --- a/sample.profiles.yml +++ b/sample.profiles.yml @@ -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: @@ -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 - - From a45735af7b93ed5fb3bca8955f82524fcd0ce33b Mon Sep 17 00:00:00 2001 From: Connor McArthur Date: Tue, 7 Feb 2017 16:42:57 -0500 Subject: [PATCH 3/3] actually validate package name --- dbt/project.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbt/project.py b/dbt/project.py index 135c0c2956a..09bd49f2703 100644 --- a/dbt/project.py +++ b/dbt/project.py @@ -118,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)