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

More consistency for global CLI flags #2990

Closed
jtcohen6 opened this issue Jan 2, 2021 · 2 comments · Fixed by #3839
Closed

More consistency for global CLI flags #2990

jtcohen6 opened this issue Jan 2, 2021 · 2 comments · Fixed by #3839
Assignees
Labels
1.0.0 Issues related to the 1.0.0 release of dbt enhancement New feature or request

Comments

@jtcohen6
Copy link
Contributor

jtcohen6 commented Jan 2, 2021

Describe the feature

Every "global" CLI flag should:

  • Precede the dbt subcommand (dbt --global-flag run)
  • Be truly global, i.e. usable with all subcommands
  • Have a corresponding environment variable and profile config
  • Relate to logistical details of development or deployment: log format + coloring, how to handle warnings, whether/where to write artifacts, etc. Anything project-related should be defined within project code; these are things that wouldn't make sense to version control alongside the rest.

If set in multiple ways, the hierarchy should always be: flag > env var > profile config.

Each flag should have a corresponding and addressable Jinja value, perhaps under flags. While e.g. {{env_var(DBT_NO_WRITE_JSON)}} should only return true if the specific environment variable is on, I think that the value of {{flags.NO_WRITE_JSON}} should be true whether set by CLI flag, env var, or profile config.

Current global flags/configs

I'm not talking about standard CLI fare, such as --version and --help.

Proposed

I do think that some flags should be promoted to "global" status:

  • --no-version-check: Right now, it works for some subcommands but not others, and I personally find it pesky to remember which ones are which. It should work for every subcommand and precede the subcommand.
  • -x, --fail-fast: Supported for run and test, why not all the rest?
  • --profiles-dir, DBT_PROFILES_DIR: Already global, it should also be supported when preceding the subcommand.

Documentation

We should then create a handy table of environment variables available to dbt's invocation context. That would include:

  • All global flags
  • Subcommand-specific flags / env vars, such as DBT_DEFER_TO_STATE + DBT_ARTIFACT_STATE_PATH

We might also mention there that:

  • Custom environment variables prefixed with DBT_ENV_CUSTOM_ENV_ will appear in the metadata.env dict of dbt JSON artifacts
  • Custom environment variables prefixed with DBT_ENV_SECRET_ will be scrubbed from logs
  • All environment variables are addressable using {{env_var()}}

Describe alternatives you've considered

  • Leaving these incomplete and inconsistent

Who will this benefit?

  • More complex deployments of dbt
  • Readers of more consistent documentation
@jtcohen6 jtcohen6 added enhancement New feature or request 1.0.0 Issues related to the 1.0.0 release of dbt labels Jan 2, 2021
@jtcohen6
Copy link
Contributor Author

jtcohen6 commented Jan 4, 2021

See also:

@leahwicz
Copy link
Contributor

  • Some global flags can be set as env vars -> this can be a different effort
  • "Reconsider our runtime configuration setup" issue (we can split this out into another v1.0 issue, estimation 8)

gshank added a commit that referenced this issue Sep 1, 2021
gshank added a commit that referenced this issue Sep 22, 2021
iknox-fa pushed a commit that referenced this issue Feb 8, 2022
automatic commit by git-black, original commits:
  779c789
iknox-fa pushed a commit that referenced this issue Feb 8, 2022
automatic commit by git-black, original commits:
  42e8c56
  779c789
iknox-fa pushed a commit that referenced this issue Feb 8, 2022
automatic commit by git-black, original commits:
  779c789
  9991b06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.0.0 Issues related to the 1.0.0 release of dbt enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants