-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
dbt project v2 #2312
dbt project v2 #2312
Conversation
e5f656e
to
7087709
Compare
1a58574
to
2618ae9
Compare
- Rename project contract to projectv1 - Add load_dependencies and dependencies attrs to RuntimeConfig - Moved project loading from parser/manifest.py into methods of RuntimeConfig - Move methods that check for unused configs from Project to RuntimeConfig - they require the adapter type to be correct - Rework Var in provider vs base context to handle both styles of Var configuration
Renamed config.config to config.build_config_dict() mypy annotations rename a module to avoid duplicating names
Configs all get defaults, a base class Added SourceConfig Introduced the idea of MergeBehavior and ShowBehavior Implemented updates/merges based on MergeBehavior for configs Implemented typed adapter-specific configs and behavior
…sing for snapshot configs
- Backwards compatiblity shims from v2 to v1 configs - config merging for v2 - compatibility shim for parsing/contexts - defer var lookups as late as possible - fixed ContextConfigType to be a proper Union of the two context config types - Fix adapter configs to be proper dataclasses - fix unused config paths error - make v2 config parsing not alter its source data
7a56f6d
to
005f37c
Compare
I've rebased this again to remove the merge conflict and (I hope) fix the last of those minor test failures in the process. |
005f37c
to
2725a1c
Compare
Docs now get the schema.yml parser vars The SchemaParser now renders the entire schema.yml except tests/descriptions
Split up hooks to expose the hook dict Remove some odd imports
Also add some missing agate methods to stubs fix tests from splitting the config renderer
Bump included projects to v2 fix tests
2725a1c
to
c6b2346
Compare
Things to check:
|
Locally this seems to work ok for me now, but I did mess with that code in this most recent change! |
Ok, I've switched out |
…it on dict values Make the package-duplicates test use a local dependency
51baece
to
669a185
Compare
Ok - I played around with this some more. Can we:
I'm going to start digging into the code in this diff. Will follow up with other thoughts inline while reviewing / testing. Looking good so far though! |
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.
Some comments after taking a look through the diff. I feel good about the code changes here, and I'd like to just do a tiny bit more functional testing before we merge this thing.
👍
|
||
def _flatten_config(dct: Dict[str, Any]): | ||
result = {} | ||
for key, value in dct.items(): |
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.
👍
lists of lists of strings, where each inner list of strings represents | ||
a configured path in the resource. | ||
""" | ||
return { |
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.
Can we add sources in here too?
core/dbt/context/context_config.py
Outdated
validate=validate | ||
) | ||
|
||
# TODO: is fqn[0] always the project name? |
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.
👁️ 👁️
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.
Oh yeah... the answer is "yes, but I don't trust that to always be true"
core/dbt/deprecations.py
Outdated
class DbtProjectYamlDeprecation(DBTDeprecation): | ||
_name = 'dbt-project-yaml-v1' | ||
_description = '''\ | ||
The existing dbt_project.yml format has been deprecated. dbt_project.yml |
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 can add a link + update copy here
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.
Let's go for something like:
dbt v0.17.0 introduces a new config format for the dbt_project.yml file. Support
for the existing version 1 format will be removed in a future release of dbt.
The following packages are currently configured with config version 1:
- debug
- some_package
For upgrading instructions, consult the documentation:
https://docs.getdbt.com/docs/guides/migration-guide/upgrading-to-0-17-0
partition_by: Optional[Dict[str, Any]] = None | ||
kms_key_name: Optional[str] = None | ||
labels: Optional[Dict[str, str]] = None | ||
# TODO: should this accept `str` and `int`, too? |
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.
Is this for partitions
? I think a list of ints would also be valid for some use cases, but users can always pipe a list of ints to | map('string')
or similar if needed
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.
Yeah. That sounds reasonable to me - I think it previously did, but I don't think it necessarily was intended to do so.
Some things I've noticed while testing: Can we specify which packages are configured with v1 It looks like the
My corresponding
Should We should add more error handling around var values. The following
If we can figure out a way to warn for |
I came around (for compatibility reasons) to the idea of |
21eee63
to
8ec266b
Compare
Handle empty vars dict Check sources for unused configs - add a test Warn when dbt finds "vars" in "models", "seeds", etc blocks - add a test Clean up enabled/disabled code to share between sources and nodes - only log downstream tests at debug level when a source is disabled - include the offending project name in the v1 deprecation message - Fix tests that care about error messages, add new ones
8ec266b
to
c18b72b
Compare
Yep, that makes sense. I didn't consider that case when I last looked at this last, but I buy that global and package scoped tiers should be separately addressable. This does get wonky if a var in a package masks a package name, eg:
Here, the |
In your example, a model in I'm not sure if that's what I'd expect, but I don't think I'd be surprised? |
51742fe
to
618adf5
Compare
@@ -331,7 +331,16 @@ def load_all( | |||
macro_hook: Callable[[Manifest], Any], | |||
) -> Manifest: | |||
with PARSING_STATE: | |||
projects = load_all_projects(root_config) | |||
projects = root_config.load_dependencies() | |||
v1_configs = [] |
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'm testing this out locally, and I'm (strangely) only seeing one project or package name in the deprecation warning. My setup:
- has a v1
dbt_project.yml
file in my root project - has a v1
dbt_project.yml
file in a dependency package
Any idea what might be going wrong?
…ion warnings on graph runnable tasks are better
05f214a
to
236a087
Compare
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.
This LGTM with one annoying caveat: can we actually remove the warning that renders if you have a vars
block in a v2 dbt_project.yml
file? I didn't realize this before, but the existing "useless config" warning does a good job of exposing that the vars dict is unused. Apologies for flip-flopping on that one.
Merge it when that very last change is addressed. Nice work here!!
# models have two things to avoid | ||
if first in {'seeds', 'models', 'snapshots'}: | ||
if first in {'seeds', 'models', 'snapshots', 'seeds'}: |
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.
@beckjake it's already in there (and line 98)
The file `searcher.py` was added, as an empty file, four years ago in [#2312](https://github.com/dbt-labs/dbt-core/pull/2312/files#diff-c8e9e62cf63356f44fe1a2b0272b239d7a650c57911477ed4549b15ee3de16fa). Since then it has never been touched or added to. I'm not sure of the initial purpose of the file as it never contained anything and I have not found any documentation in reference to it. It's safe to say, it can go away.
#9878) * Delete empty `test_compiler.py` file Over a year ago in [#7008](https://github.com/dbt-labs/dbt-core/pull/7008/files#diff-c10753a61a1d8f973ec3206206d72b3c5200e41673ab2c6b256f333103eadb8f) the tests in `test_compiler.py` got moved into other testing files. Since then this file has been sitting around empty. It is probably a reasonable time to say goodbye to it. * Delete empty `searcher.py` file The file `searcher.py` was added, as an empty file, four years ago in [#2312](https://github.com/dbt-labs/dbt-core/pull/2312/files#diff-c8e9e62cf63356f44fe1a2b0272b239d7a650c57911477ed4549b15ee3de16fa). Since then it has never been touched or added to. I'm not sure of the initial purpose of the file as it never contained anything and I have not found any documentation in reference to it. It's safe to say, it can go away.
resolves #2300
Description
This PR adds support for a dbt_project.yml v2, as described in #2300
Details:
NodeConfig
and its descendants. The v1 config still uses a special class that implements the legacy behavior, for backwards compatibility reasons.enabled
flagChecklist
CHANGELOG.md
and added information about my change to the "dbt next" section.