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

[CT-1418] [Bug] CLI argument --profile ignored in dbt init #6154

Closed
2 tasks done
scheah92 opened this issue Oct 27, 2022 · 7 comments · Fixed by #7450
Closed
2 tasks done

[CT-1418] [Bug] CLI argument --profile ignored in dbt init #6154

scheah92 opened this issue Oct 27, 2022 · 7 comments · Fixed by #7450
Labels
bug Something isn't working cli good_first_issue Straightforward + self-contained changes, good for new contributors! init Issues related to initializing the dbt starter project

Comments

@scheah92
Copy link

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

According to dbt init --help, the --profile option lets the user load an existing profile to use with a new project. However, that option currently does nothing when you call it with dbt init.

Example:

dbt init --profile default proj1

Result:
proj1 created with proj1/dbt_project.yml showing profile: 'proj1'. ~/.dbt/profiles.yml shows a new profile proj1 created with placeholders. Note: if a profile named proj1 already exists, dbt still creates another profile named proj1 again.

In contrast, calling dbt run --profile default actually does make the project use the profile default, so the --profile argument does work elsewhere at least.

Expected Behavior

proj1 created with proj1/dbt_project.yml showing profile: 'default'. ~/.dbt/profiles.yml should not show any new profile created.

Steps To Reproduce

  1. Create new project directory to store project in
  2. Open ~/.dbt/profiles.yml and create a new profile default.
  3. Run dbt init --profile default proj1
  4. cd into /proj1 and open dbt_project.yml. The profile will be set to proj1 instead of default.
  5. Check ~/.dbt/profiles.yml again and see that dbt has created a new blank proj1 profile to go with the new project, instead of using the existing default profile.

Relevant log output

No response

Environment

- OS: Ubuntu 22.04.1 LTS
- Python: 3.10.6
- dbt: 1.3.0

Which database adapter are you using with dbt?

postgres

Additional Context

No response

@scheah92 scheah92 added bug Something isn't working triage labels Oct 27, 2022
@github-actions github-actions bot changed the title [Bug] CLI argument --profile ignored in dbt init [CT-1418] [Bug] CLI argument --profile ignored in dbt init Oct 27, 2022
@lostmygithubaccount
Copy link
Contributor

hi @scheah92, thanks for reporting, I am able to reproduce this. my first thought was the order of arguments, so perhaps dbt init proj1 --profile default would work, but that behaves the same

we are reworking our CLI commands as part of v1.4 and v1.5 and we can likely pick this up for those releases

@scheah92
Copy link
Author

scheah92 commented Nov 2, 2022

Hi @lostmygithubaccount, if you guys are reworking CLI commands, you might be interested to know that --profile is not the only CLI argument that has issues. In my testing, I've found that --target and --vars also do not appear to have any effect. I suspect these don't work because they rely on --profile in the first place.

@jtcohen6 jtcohen6 added triage and removed triage labels Nov 21, 2022
@iknox-fa iknox-fa added the good_first_issue Straightforward + self-contained changes, good for new contributors! label Apr 3, 2023
@iknox-fa
Copy link
Contributor

iknox-fa commented Apr 3, 2023

Good place to start looking at this:

def run(self):

@ezraerb
Copy link
Contributor

ezraerb commented Apr 11, 2023

The code shows that the profile argument is simply ignored:
with open("dbt_project.yml", "r+") as f: content = f"{f.read()}".format(project_name=project_name, profile_name=project_name) f.seek(0) f.write(content) f.truncate()

@alzaar
Copy link

alzaar commented May 19, 2023

Would it be possible, if I pick this up ?
I made some changes locally and then ran the above instructions. The dbt_project responds to the profile flag. I am unsure of what side effects my changes would have. Specifically, the changes are

profile_name = get_flags().PROFILES
content = f"{f.read()}".format(project_name=project_name, profile_name=profile_name)

I am a first time contributor to the dbt-core repo.

@ezraerb
Copy link
Contributor

ezraerb commented May 19, 2023

I submitted a PR for it: #7450
It has not been reviewed yet. Given the reorg that dbt labs just had, I suspect that will take a while.

@alzaar
Copy link

alzaar commented May 19, 2023

Cool, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli good_first_issue Straightforward + self-contained changes, good for new contributors! init Issues related to initializing the dbt starter project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants