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

Make default project paths, init project consistent #4007

Merged
merged 1 commit into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- Add warning when trying to put a node under the wrong key. ie. A seed under models in a `schema.yml` file. ([#3899](https://github.com/dbt-labs/dbt/issues/3899))
- Plugins for `redshift`, `snowflake`, and `bigquery` have moved to separate repos: [`dbt-redshift`](https://github.com/dbt-labs/dbt-redshift), [`dbt-snowflake`](https://github.com/dbt-labs/dbt-snowflake), [`dbt-bigquery`](https://github.com/dbt-labs/dbt-bigquery)
- Change the default dbt packages installation directory to `dbt_packages` from `dbt_modules`. Also rename `module-path` to `packages-install-path` to allow default overrides of package install directory. Deprecation warning added for projects using the old `dbt_modules` name without specifying a `packages-install-path`. ([#3523](https://github.com/dbt-labs/dbt/issues/3523))
- Update the default project paths to be `analysis-paths = ['analyses']` and `test-paths = ['tests]`. Also have starter project set `analysis-paths: ['analyses']` from now on. ([#2659](https://github.com/dbt-labs/dbt/issues/2659))

Contributors:

Expand Down
4 changes: 2 additions & 2 deletions core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ def create_project(self, rendered: RenderComponents) -> 'Project':
source_paths: List[str] = value_or(cfg.source_paths, ['models'])
macro_paths: List[str] = value_or(cfg.macro_paths, ['macros'])
data_paths: List[str] = value_or(cfg.data_paths, ['data'])
test_paths: List[str] = value_or(cfg.test_paths, ['test'])
analysis_paths: List[str] = value_or(cfg.analysis_paths, [])
test_paths: List[str] = value_or(cfg.test_paths, ['tests'])
analysis_paths: List[str] = value_or(cfg.analysis_paths, ['analyses'])
snapshot_paths: List[str] = value_or(cfg.snapshot_paths, ['snapshots'])

all_source_paths: List[str] = _all_source_paths(
Expand Down
2 changes: 1 addition & 1 deletion core/dbt/include/starter_project/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ profile: 'default'
# The `source-paths` config, for example, states that models in this project can be
# found in the "models/" directory. You probably won't need to change these!
source-paths: ["models"]
analysis-paths: ["analysis"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
Expand Down
2 changes: 1 addition & 1 deletion performance/projects/01_2000_simple_models/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ profile: 'default'
# The `source-paths` config, for example, states that source models can be found
# in the "models/" directory. You probably won't need to change these!
source-paths: ["models"]
analysis-paths: ["analysis"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ config-version: 2
profile: 'default'

source-paths: ["models"]
analysis-paths: ["analysis"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ config-version: 2
profile: 'default'

source-paths: ["models"]
analysis-paths: ["analysis"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
version: 2

analyses:
- name: analysis
- name: my_analysis
description: "This is my analysis"
8 changes: 4 additions & 4 deletions test/integration/019_analysis_tests/test_analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def models(self):
return "models"

def analysis_path(self):
return "analysis"
return "analyses"

@property
def project_config(self):
Expand All @@ -28,16 +28,16 @@ def assert_contents_equal(self, path, expected):

@use_profile('postgres')
def test_postgres_analyses(self):
compiled_analysis_path = os.path.normpath('target/compiled/test/analysis')
path_1 = os.path.join(compiled_analysis_path, 'analysis.sql')
compiled_analysis_path = os.path.normpath('target/compiled/test/analyses')
path_1 = os.path.join(compiled_analysis_path, 'my_analysis.sql')
path_2 = os.path.join(compiled_analysis_path, 'raw_stuff.sql')

self.run_dbt(['clean'])
self.assertFalse(os.path.exists(compiled_analysis_path))
results = self.run_dbt(["compile"])
self.assertEqual(len(results), 3)
manifest = get_manifest()
analysis_id = 'analysis.test.analysis'
analysis_id = 'analysis.test.my_analysis'
self.assertIn(analysis_id, manifest.nodes)
node = manifest.nodes[analysis_id]
self.assertEqual(node.description, 'This is my analysis')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ config-version: 2
profile: 'default'

source-paths: ["models"]
analysis-paths: ["analysis"]
analysis-paths: ["analyses"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ def project_config(self):
'data-paths': ['seed'],
'test-paths': ['tests'],
'macro-paths': ['macros-b'],
'analysis-paths': ['analysis'],
'analysis-paths': ['analyses'],
'seeds': {
'quote_columns': False,
},
Expand All @@ -248,8 +248,8 @@ def tearDown(self):
os.remove(normalize('target/partial_parse.msgpack'))
if os.path.exists(normalize('tests/my_test.sql')):
os.remove(normalize('tests/my_test.sql'))
if os.path.exists(normalize('analysis/my_analysis.sql')):
os.remove(normalize('analysis/my_analysis.sql'))
if os.path.exists(normalize('analyses/my_analysis.sql')):
os.remove(normalize('analyses/my_analysis.sql'))
if os.path.exists(normalize('macros-b/tests.sql')):
os.remove(normalize('macros-b/tests.sql'))

Expand Down Expand Up @@ -345,7 +345,7 @@ def test_postgres_pp_sources(self):
self.assertIn(test_id, manifest.nodes)

# Add an analysis
shutil.copyfile('extra-files/my_analysis.sql', 'analysis/my_analysis.sql')
shutil.copyfile('extra-files/my_analysis.sql', 'analyses/my_analysis.sql')
results = self.run_dbt(["--partial-parse", "run"])
manifest = get_manifest()

Expand All @@ -356,7 +356,7 @@ def test_postgres_pp_sources(self):
self.assertEqual(len(manifest.nodes), 9)

# Remove analysis
os.remove(normalize('analysis/my_analysis.sql'))
os.remove(normalize('analyses/my_analysis.sql'))
results = self.run_dbt(["--partial-parse", "run"])
manifest = get_manifest()
self.assertEqual(len(manifest.nodes), 8)
Expand Down
22 changes: 11 additions & 11 deletions test/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,9 @@ def test_defaults(self):
self.assertEqual(project.source_paths, ['models'])
self.assertEqual(project.macro_paths, ['macros'])
self.assertEqual(project.data_paths, ['data'])
self.assertEqual(project.test_paths, ['test'])
self.assertEqual(project.analysis_paths, [])
self.assertEqual(project.docs_paths, ['models', 'data', 'snapshots', 'macros'])
self.assertEqual(project.test_paths, ['tests'])
self.assertEqual(project.analysis_paths, ['analyses'])
self.assertEqual(project.docs_paths, ['models', 'data', 'snapshots', 'analyses', 'macros'])
self.assertEqual(project.asset_paths, [])
self.assertEqual(project.target_path, 'target')
self.assertEqual(project.clean_targets, ['target'])
Expand Down Expand Up @@ -624,7 +624,7 @@ def test_implicit_overrides(self):
'target-path': 'other-target',
})
project = project_from_config_norender(self.default_project_data)
self.assertEqual(project.docs_paths, ['other-models', 'data', 'snapshots', 'macros'])
self.assertEqual(project.docs_paths, ['other-models', 'data', 'snapshots', 'analyses', 'macros'])
self.assertEqual(project.clean_targets, ['other-target'])

def test_hashed_name(self):
Expand All @@ -636,8 +636,8 @@ def test_all_overrides(self):
'source-paths': ['other-models'],
'macro-paths': ['other-macros'],
'data-paths': ['other-data'],
'test-paths': ['other-test'],
'analysis-paths': ['analysis'],
'test-paths': ['other-tests'],
'analysis-paths': ['other-analyses'],
'docs-paths': ['docs'],
'asset-paths': ['other-assets'],
'target-path': 'other-target',
Expand Down Expand Up @@ -706,8 +706,8 @@ def test_all_overrides(self):
self.assertEqual(project.source_paths, ['other-models'])
self.assertEqual(project.macro_paths, ['other-macros'])
self.assertEqual(project.data_paths, ['other-data'])
self.assertEqual(project.test_paths, ['other-test'])
self.assertEqual(project.analysis_paths, ['analysis'])
self.assertEqual(project.test_paths, ['other-tests'])
self.assertEqual(project.analysis_paths, ['other-analyses'])
self.assertEqual(project.docs_paths, ['docs'])
self.assertEqual(project.asset_paths, ['other-assets'])
self.assertEqual(project.target_path, 'other-target')
Expand Down Expand Up @@ -1201,9 +1201,9 @@ def test_from_args(self):
self.assertEqual(config.source_paths, ['models'])
self.assertEqual(config.macro_paths, ['macros'])
self.assertEqual(config.data_paths, ['data'])
self.assertEqual(config.test_paths, ['test'])
self.assertEqual(config.analysis_paths, [])
self.assertEqual(config.docs_paths, ['models', 'data', 'snapshots', 'macros'])
self.assertEqual(config.test_paths, ['tests'])
self.assertEqual(config.analysis_paths, ['analyses'])
self.assertEqual(config.docs_paths, ['models', 'data', 'snapshots', 'analyses', 'macros'])
self.assertEqual(config.asset_paths, [])
self.assertEqual(config.target_path, 'target')
self.assertEqual(config.clean_targets, ['target'])
Expand Down