Skip to content

Commit

Permalink
Er/1607 source paths (#4008)
Browse files Browse the repository at this point in the history
* WIP to replace source_path with model_path

* updated some test to point to new testing branches

https://github.com/dbt-labs/dbt-integration-project needs updates to get all tests working

* deprecate souce_paths but not remove fully

* added deprecation test for path deprecation

* replace data-pathswith seed-paths: ['seeds']

ypdated tests to use default directory of 'seeds' instead of 'data'

* added test for exception when paths incorectly defined

source-paths and data-paths have been deprecated in favor of model-paths and seed-paths.  You can still use the deprecated keys but you cannot define both the deprecated and new keys since we wouldn't know how to handle it.

* fixed test naming issue

* fix formatting issues, standardize names

* updated branches for dbt-integration-project

* updated changelog

* synced up rpc deletion messed up when merging

* changelog updates

automatic commit by git-black, original commits:
  0e9a679
  • Loading branch information
emmyoop authored and iknox-fa committed Feb 8, 2022
1 parent c98a16b commit 987ab2d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 24 deletions.
41 changes: 22 additions & 19 deletions core/dbt/config/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,16 +282,19 @@ def check_config_path(self, project_dict, deprecated_path, exp_path):
if deprecated_path in project_dict:
if exp_path in project_dict:
msg = (
'{deprecated_path} and {exp_path} cannot both be defined. The '
'`{deprecated_path}` config has been deprecated in favor of `{exp_path}`. '
'Please update your `dbt_project.yml` configuration to reflect this '
'change.'
"{deprecated_path} and {exp_path} cannot both be defined. The "
"`{deprecated_path}` config has been deprecated in favor of `{exp_path}`. "
"Please update your `dbt_project.yml` configuration to reflect this "
"change."
)
raise DbtProjectError(msg.format(deprecated_path=deprecated_path,
exp_path=exp_path))
raise DbtProjectError(
msg.format(deprecated_path=deprecated_path, exp_path=exp_path)
deprecations.warn(f'project-config-{deprecated_path}',
deprecated_path=deprecated_path,
exp_path=exp_path)
deprecations.warn(
f"project-config-{deprecated_path}",
deprecated_path=deprecated_path,
exp_path=exp_path,
)

def create_project(self, rendered: RenderComponents) -> "Project":
unrendered = RenderComponents(
Expand All @@ -304,8 +307,8 @@ def create_project(self, rendered: RenderComponents) -> "Project":
verify_version=self.verify_version,
)

self.check_config_path(rendered.project_dict, 'source-paths', 'model-paths')
self.check_config_path(rendered.project_dict, 'data-paths', 'seed-paths')
self.check_config_path(rendered.project_dict, "source-paths", "model-paths")
self.check_config_path(rendered.project_dict, "data-paths", "seed-paths")

try:
ProjectContract.validate(rendered.project_dict)
Expand All @@ -329,16 +332,16 @@ def create_project(self, rendered: RenderComponents) -> "Project":

# `source_paths` is deprecated but still allowed. Copy it into
# `model_paths` to simlify logic throughout the rest of the system.
model_paths: List[str] = value_or(cfg.model_paths
if 'model-paths' in rendered.project_dict
else cfg.source_paths, ['models'])
model_paths: List[str] = value_or(
cfg.model_paths if "model-paths" in rendered.project_dict else cfg.source_paths,
["models"],
)
macro_paths: List[str] = value_or(cfg.macro_paths, ["macros"])
# `data_paths` is deprecated but still allowed. Copy it into
# `seed_paths` to simlify logic throughout the rest of the system.
seed_paths: List[str] = value_or(cfg.seed_paths
if 'seed-paths' in rendered.project_dict
else cfg.data_paths, ['seeds'])
seed_paths: List[str] = value_or(
cfg.seed_paths if "seed-paths" in rendered.project_dict else cfg.data_paths, ["seeds"]
)
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"])
Expand Down Expand Up @@ -541,7 +544,7 @@ class Project:
@property
def all_source_paths(self) -> List[str]:
return _all_source_paths(
self.model_paths, self.seed_paths, self.snapshot_paths,
self.model_paths,
self.seed_paths,
self.snapshot_paths,
self.analysis_paths,
Expand Down Expand Up @@ -579,9 +582,9 @@ def to_project_config(self, with_packages=False):
"name": self.project_name,
"version": self.version,
"project-root": self.project_root,
'model-paths': self.model_paths,
"profile": self.profile_name,
"model-paths": self.model_paths,
'seed-paths': self.seed_paths,
"macro-paths": self.macro_paths,
"seed-paths": self.seed_paths,
"test-paths": self.test_paths,
"analysis-paths": self.analysis_paths,
Expand Down
4 changes: 2 additions & 2 deletions core/dbt/deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class PackageInstallPathDeprecation(DBTDeprecation):


class ConfigPathDeprecation(DBTDeprecation):
_description = '''\
_description = """\
The `{deprecated_path}` config has been renamed to `{exp_path}`.
Please update your `dbt_project.yml` configuration to reflect this change.
'''
"""


class ConfigSourcePathDeprecation(ConfigPathDeprecation):
Expand Down
4 changes: 2 additions & 2 deletions core/dbt/parser/read_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def read_files(project, files, parser_files, saved_files):
)

project_files['ModelParser'] = read_files_for_parser(
project, files, project.model_paths, '.sql', ParseFileType.Model, saved_files
project, files, project.model_paths, ".sql", ParseFileType.Model, saved_files
)

project_files['SnapshotParser'] = read_files_for_parser(
Expand All @@ -161,7 +161,7 @@ def read_files(project, files, parser_files, saved_files):
)

project_files['SeedParser'] = read_files_for_parser(
project, files, project.seed_paths, '.csv', ParseFileType.Seed, saved_files
project, files, project.seed_paths, ".csv", ParseFileType.Seed, saved_files
)

project_files['DocumentationParser'] = read_files_for_parser(
Expand Down
2 changes: 1 addition & 1 deletion core/scripts/upgrade_dbt_schema_tests_v1_to_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def handle(parsed):
validate_and_mutate_args(parsed)
with open(os.path.join(parsed.search_directory, 'dbt_project.yml')) as fp:
project = yaml.safe_load(fp)
model_dirs = project.get('model-paths', ['models'])
model_dirs = project.get("model-paths", ["models"])
if parsed.apply:
print('converting the following files to the v2 spec:')
else:
Expand Down

0 comments on commit 987ab2d

Please sign in to comment.