-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 init
Interactive profile creation
#3625
Merged
jtcohen6
merged 22 commits into
dbt-labs:main
from
NiallRees:nw/interactive_profile_creation
Oct 20, 2021
Merged
Changes from 13 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3393245
Initial
NiallRees ea238e5
Merge branch 'develop' into nw/interactive_profile_creation
NiallRees e1a8463
Further dev
NiallRees 2a29dbd
Make mypy happy
NiallRees 164e983
Further dev
NiallRees befcbd0
Merge branch 'develop' into nw/interactive_profile_creation
NiallRees 83c0888
Existing tests passing
NiallRees 6184fb3
Functioning integration test
NiallRees 591ad75
Merge branch 'develop' into nw/interactive_profile_creation
NiallRees 182c82d
Passing integration test
NiallRees c105ab7
Integration tests
NiallRees 9bd1bed
Add changelog entry
NiallRees 622840e
Add integration test for init outside of project
NiallRees 5ceb484
Fall back to target_options.yml when invalid profile_template.yml is …
NiallRees 6dcae8c
Use built-in yaml with exception of in init
NiallRees 52f9efb
Remove oyaml and fix tests
NiallRees 32a97a9
Merge branch 'develop' into nw/interactive_profile_creation
NiallRees bd50977
Update dbt_project.yml in test comparison
NiallRees 4e490ce
Create the profiles directory if it doesn't exist
NiallRees 5be5e5e
Merge branch 'main' into nw/interactive_profile_creation
jtcohen6 f9ac912
Use safe_load
NiallRees 4f213ba
Update integration test
NiallRees File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,12 @@ | |
# Name your project! Project names should contain only lowercase characters | ||
# and underscores. A good package name should reflect your organization's | ||
# name or the intended use of these models | ||
name: 'my_new_project' | ||
name: '{project_name}' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎉 |
||
version: '1.0.0' | ||
config-version: 2 | ||
|
||
# This setting configures which "profile" dbt uses for this project. | ||
profile: 'default' | ||
profile: '{profile_name}' | ||
|
||
# These configurations specify where dbt should look for different types of files. | ||
# The `source-paths` config, for example, states that models in this project can be | ||
|
@@ -30,9 +30,9 @@ clean-targets: # directories to be removed by `dbt clean` | |
|
||
# In this example config, we tell dbt to build all models in the example/ directory | ||
# as tables. These settings can be overridden in the individual model files | ||
# using the `{{ config(...) }}` macro. | ||
# using the `{{{{ config(...) }}}}` macro. | ||
models: | ||
my_new_project: | ||
{project_name}: | ||
# Config indicated by + and applies to all files under models/example/ | ||
example: | ||
+materialized: view |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 replaced yaml with oyaml in order to retain ordering when prompting for user input. Rather than keep both I just replaced every reference with oyaml. It may well be preferred that we leave all other imports as-is, let me know.
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.
@kwigley do you have any thoughts 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.
It looks like the switch from
yaml
tooyaml
has broken one highly specific integration test, which checks the sorting behavior of thetoyaml
Jinja context method. Thesort_keys
argument is not being respected byoyaml.safe_dump
. Glad we have a test for it!https://github.com/dbt-labs/dbt/blob/3789acc5a7b3f71b4e333ac6e235c62ee0c957f5/test/integration/013_context_var_tests/tests/to_yaml.sql#L5
https://github.com/dbt-labs/dbt/blob/3789acc5a7b3f71b4e333ac6e235c62ee0c957f5/core/dbt/context/base.py#L416
I think my preference would probably be to avoid switching from
yaml
tooyaml
wherever possible. I'm also wondering if there's another way we can preserve prompt order fortarget_options.yml
, even if it requires an extra attributeThere 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.
It would seem my reasoning for using oyaml was misplaced - I've removed it and apart from some changes to the order of dumped yaml in
profiles.yml
the rest of the behaviour is identical. So the order of the questions to the user is still the order of the keys in thetarget_options.yml
. Hooray!