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

Move UserConfig to dbt_project.yml and rename to ProjectFlags #9289

Merged
merged 24 commits into from
Jan 4, 2024

Conversation

gshank
Copy link
Contributor

@gshank gshank commented Dec 14, 2023

resolves #9183

Problem

The flags that are in the current UserConfig object attached to the profile should be in dbt_project.yml.

Solution

Rename UserConfig to ProjectFlags, and various variables and attributes from "user_config" to "project_flags". Modify function called in core/dbt/cli/flags.py to retrieve flags to look in both profiles.yml and dbt_project.yml, and issue a deprecation warning if found in profiles.yml and raise an error if found in both places.

Note that we can't use the warn_errors and warn_error_options for this deprecation warning because the deprecation is encountered when loading the project flags which contains warn_errors and warn_error_options.

Remove skipped and unnecessary tests/unit/test_flags.py file.

Checklist

  • I have read the contributing guide and understand what's expected of me
  • I have run this code in development and it appears to resolve the stated issue
  • This PR includes tests, or tests are not required/relevant for this PR
  • This PR has no interface changes (e.g. macros, cli, logs, json artifacts, config files, adapter interface, etc) or this PR has already received feedback and approval from Product or DX
  • This PR includes type annotations for new and modified functions

@gshank gshank requested a review from a team as a code owner December 14, 2023 19:55
@gshank gshank requested a review from aranke December 14, 2023 19:55
@cla-bot cla-bot bot added the cla:yes label Dec 14, 2023
@gshank gshank marked this pull request as draft December 14, 2023 19:55
@gshank gshank removed the request for review from aranke December 14, 2023 19:55
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

Copy link

codecov bot commented Dec 14, 2023

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (48d9a67) 86.61% compared to head (7350dba) 86.59%.

Files Patch % Lines
core/dbt/config/project.py 97.56% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9289      +/-   ##
==========================================
- Coverage   86.61%   86.59%   -0.02%     
==========================================
  Files         221      221              
  Lines       26969    26997      +28     
==========================================
+ Hits        23360    23379      +19     
- Misses       3609     3618       +9     
Flag Coverage Δ
integration 83.48% <91.66%> (-0.02%) ⬇️
unit 65.21% <85.71%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@gshank gshank added the user docs [docs.getdbt.com] Needs better documentation label Dec 20, 2023
@gshank gshank marked this pull request as ready for review December 20, 2023 21:02
@gshank gshank requested a review from a team as a code owner December 20, 2023 21:02
@@ -709,7 +715,6 @@ def to_project_config(self, with_packages=False):
"exposures": self.exposures,
"vars": self.vars.to_dict(),
"require-dbt-version": [v.to_version_string() for v in self.dbt_version],
"config-version": self.config_version,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this just removing some dead code? or are we actively removing support for config-version in dbt_project.yml with this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed support for config-version sometime last year, but a few things were still hanging around. It still exists in the class that validates because we don't want to cause a validation error, but there's no point in passing it along.

// E - DB Adapter

// E001
message AdapterEventDebug {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why move adapter events into common?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't. Don't know why that's showing up as a change. I just merged main into the branch... Git might have gotten confused?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there was a merge error which needed to be resolved but wasn't, and nothing failed because types.proto wasn't rebuilt...

@@ -404,3 +406,38 @@ def test_from_dict_0_value(self):
args_dict = {"log_file_max_bytes": 0}
flags = Flags.from_dict(Command.RUN, args_dict)
assert flags.LOG_FILE_MAX_BYTES == 0


def test_project_flag_defaults():
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice!

@gshank gshank merged commit e42b7ca into main Jan 4, 2024
51 checks passed
@gshank gshank deleted the 9183-user_config_in_dbt_project branch January 4, 2024 15:32
@FishtownBuildBot
Copy link
Collaborator

Opened a new issue in dbt-labs/docs.getdbt.com: dbt-labs/docs.getdbt.com#4709

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes user docs [docs.getdbt.com] Needs better documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-3438] UserConfig in profiles.yml -> flags in dbt_project.yml
4 participants