mirror of
https://github.com/dbt-labs/dbt-core
synced 2025-12-21 23:41:27 +00:00
Compare commits
1 Commits
enable-pos
...
jerco/rena
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
da9ae7f4bb |
@@ -109,7 +109,10 @@ class Flags:
|
|||||||
assign_params(invoked_subcommand_ctx, params_assigned_from_default)
|
assign_params(invoked_subcommand_ctx, params_assigned_from_default)
|
||||||
|
|
||||||
if not user_config:
|
if not user_config:
|
||||||
profiles_dir = getattr(self, "PROFILES_DIR", None)
|
# In tests, we don't set this env var / write profiles.yml early enough
|
||||||
|
# See 'profiles_yml' fixture in tests/fixtures/project.py
|
||||||
|
# This is obviously bad
|
||||||
|
profiles_dir = os.getenv("DBT_PROFILES_DIR") or getattr(self, "PROFILES_DIR", None)
|
||||||
user_config = read_user_config(profiles_dir) if profiles_dir else None
|
user_config = read_user_config(profiles_dir) if profiles_dir else None
|
||||||
|
|
||||||
# Overwrite default assignments with user config if available
|
# Overwrite default assignments with user config if available
|
||||||
@@ -153,7 +156,7 @@ class Flags:
|
|||||||
# Support console DO NOT TRACK initiave
|
# Support console DO NOT TRACK initiave
|
||||||
object.__setattr__(
|
object.__setattr__(
|
||||||
self,
|
self,
|
||||||
"ANONYMOUS_USAGE_STATS",
|
"SEND_ANONYMOUS_USAGE_STATS",
|
||||||
False
|
False
|
||||||
if os.getenv("DO_NOT_TRACK", "").lower() in ("1", "t", "true", "y", "yes")
|
if os.getenv("DO_NOT_TRACK", "").lower() in ("1", "t", "true", "y", "yes")
|
||||||
else True,
|
else True,
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ class dbtRunner:
|
|||||||
epilog="Specify one of these sub-commands and you can find more help from there.",
|
epilog="Specify one of these sub-commands and you can find more help from there.",
|
||||||
)
|
)
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@p.anonymous_usage_stats
|
|
||||||
@p.cache_selected_only
|
@p.cache_selected_only
|
||||||
@p.debug
|
@p.debug
|
||||||
@p.enable_legacy_logger
|
@p.enable_legacy_logger
|
||||||
@@ -80,6 +79,7 @@ class dbtRunner:
|
|||||||
@p.printer_width
|
@p.printer_width
|
||||||
@p.quiet
|
@p.quiet
|
||||||
@p.record_timing_info
|
@p.record_timing_info
|
||||||
|
@p.send_anonymous_usage_stats
|
||||||
@p.single_threaded
|
@p.single_threaded
|
||||||
@p.static_parser
|
@p.static_parser
|
||||||
@p.use_colors
|
@p.use_colors
|
||||||
|
|||||||
@@ -6,17 +6,6 @@ from dbt.cli.option_types import YAML, ChoiceTuple, WarnErrorOptionsType
|
|||||||
from dbt.cli.resolvers import default_project_dir, default_profiles_dir
|
from dbt.cli.resolvers import default_project_dir, default_profiles_dir
|
||||||
from dbt.version import get_version_information
|
from dbt.version import get_version_information
|
||||||
|
|
||||||
# TODO: The name (reflected in flags) is a correction!
|
|
||||||
# The original name was `SEND_ANONYMOUS_USAGE_STATS` and used an env var called "DBT_SEND_ANONYMOUS_USAGE_STATS"
|
|
||||||
# Both of which break existing naming conventions (doesn't match param flag).
|
|
||||||
# This will need to be fixed before use in the main codebase and communicated as a change to the community!
|
|
||||||
anonymous_usage_stats = click.option(
|
|
||||||
"--anonymous-usage-stats/--no-anonymous-usage-stats",
|
|
||||||
envvar="DBT_ANONYMOUS_USAGE_STATS",
|
|
||||||
help="Send anonymous usage stats to dbt Labs.",
|
|
||||||
default=True,
|
|
||||||
)
|
|
||||||
|
|
||||||
args = click.option(
|
args = click.option(
|
||||||
"--args",
|
"--args",
|
||||||
envvar=None,
|
envvar=None,
|
||||||
@@ -210,6 +199,7 @@ profile = click.option(
|
|||||||
help="Which profile to load. Overrides setting in dbt_project.yml.",
|
help="Which profile to load. Overrides setting in dbt_project.yml.",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# For tests, the 'DBT_PROFILES_DIR' env var is not set early enough to correctly resolve this
|
||||||
profiles_dir = click.option(
|
profiles_dir = click.option(
|
||||||
"--profiles-dir",
|
"--profiles-dir",
|
||||||
envvar="DBT_PROFILES_DIR",
|
envvar="DBT_PROFILES_DIR",
|
||||||
@@ -285,6 +275,15 @@ selector = click.option(
|
|||||||
"--selector", envvar=None, help="The selector name to use, as defined in selectors.yml"
|
"--selector", envvar=None, help="The selector name to use, as defined in selectors.yml"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# This is a breaking change for the CLI flag only: --no-anonymous-usage-stats is now --no-send-anonymous-usage-stats
|
||||||
|
# Preserve the existing name of the env var and UserConfig
|
||||||
|
send_anonymous_usage_stats = click.option(
|
||||||
|
"--send-anonymous-usage-stats/--no-send-anonymous-usage-stats",
|
||||||
|
envvar="DBT_SEND_ANONYMOUS_USAGE_STATS",
|
||||||
|
help="Share anonymous usage stats with dbt Labs to help us improve dbt-core!",
|
||||||
|
default=True,
|
||||||
|
)
|
||||||
|
|
||||||
show = click.option(
|
show = click.option(
|
||||||
"--show", envvar=None, help="Show a sample of the loaded data in the terminal", is_flag=True
|
"--show", envvar=None, help="Show a sample of the loaded data in the terminal", is_flag=True
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -25,7 +25,20 @@ def preflight(func):
|
|||||||
set_flags(flags)
|
set_flags(flags)
|
||||||
|
|
||||||
# Tracking
|
# Tracking
|
||||||
initialize_from_flags(flags.ANONYMOUS_USAGE_STATS, flags.PROFILES_DIR)
|
# TODO: This is not working correctly!
|
||||||
|
# It seems like an issue with parent-level vs. subcommand-level flags
|
||||||
|
# Drop a breakpoint here
|
||||||
|
# import ipdb; ipdb.set_trace()
|
||||||
|
# Then try:
|
||||||
|
# $ python3 -m dbt.cli.main --no-send-anonymous-usage-stats run
|
||||||
|
# $ SEND_ANONYMOUS_USAGE_STATS=False python3 -m dbt.cli.main run
|
||||||
|
# ipdb> flags.SEND_ANONYMOUS_USAGE_STATS
|
||||||
|
# True
|
||||||
|
# I was also experimenting with version_check, which is supported at both child + parent levels, and is True by default.
|
||||||
|
# $ python3 -m dbt.cli.main --no-version-check run --> flags.version_check returns True (ignored)
|
||||||
|
# $ python3 -m dbt.cli.main run --no-version-check --> flags.version_check returns False (not ignored)
|
||||||
|
# $ python3 -m dbt.cli.main --no-version-check run --version-check --> flags.version_check returns False!! parent is not ignored & wins
|
||||||
|
initialize_from_flags(flags.SEND_ANONYMOUS_USAGE_STATS, flags.PROFILES_DIR)
|
||||||
ctx.with_resource(track_run(run_command=flags.WHICH))
|
ctx.with_resource(track_run(run_command=flags.WHICH))
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
|
|||||||
@@ -303,7 +303,8 @@ class ManifestMetadata(BaseArtifactMetadata):
|
|||||||
self.user_id = tracking.active_user.id
|
self.user_id = tracking.active_user.id
|
||||||
|
|
||||||
if self.send_anonymous_usage_stats is None:
|
if self.send_anonymous_usage_stats is None:
|
||||||
self.send_anonymous_usage_stats = get_flags().ANONYMOUS_USAGE_STATS
|
# TODO: this is called before Flags is actually resolved!!
|
||||||
|
self.send_anonymous_usage_stats = get_flags().SEND_ANONYMOUS_USAGE_STATS
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def default(cls):
|
def default(cls):
|
||||||
|
|||||||
@@ -501,6 +501,10 @@ class TestVerifyArtifacts(BaseVerifyProject):
|
|||||||
# Test generic "docs generate" command
|
# Test generic "docs generate" command
|
||||||
def test_run_and_generate(self, project, manifest_schema_path, run_results_schema_path):
|
def test_run_and_generate(self, project, manifest_schema_path, run_results_schema_path):
|
||||||
start_time = datetime.utcnow()
|
start_time = datetime.utcnow()
|
||||||
|
# Two issues here with send_anonymous_usage_stats:
|
||||||
|
# 1. Our test fixtures don't set an env var / write profiles.yml early enough
|
||||||
|
# 2. Even if I pass in the flag explicitly, it doesn't seem to be working!
|
||||||
|
# results = run_dbt(["--no-send-anonymous-usage-stats", "compile"])
|
||||||
results = run_dbt(["compile"])
|
results = run_dbt(["compile"])
|
||||||
assert len(results) == 7
|
assert len(results) == 7
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user