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

Track deprecation warnings #2710

Merged
merged 2 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

### Under the hood
- Upgraded snowflake-connector-python dependency to 2.2.10 and enabled the SSO token cache ([#2613](https://github.com/fishtown-analytics/dbt/issues/2613), [#2689](https://github.com/fishtown-analytics/dbt/issues/2689), [#2698](https://github.com/fishtown-analytics/dbt/pull/2698))
- Add deprecation warnings to anonymous usage tracking ([#2688](https://github.com/fishtown-analytics/dbt/issues/2688), [#2710](https://github.com/fishtown-analytics/dbt/issues/2710))

### Features
- Add better retry support when using the BigQuery adapter ([#2694](https://github.com/fishtown-analytics/dbt/pull/2694), follow-up to [#1963](https://github.com/fishtown-analytics/dbt/pull/1963))
Expand Down
8 changes: 8 additions & 0 deletions core/dbt/deprecations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import dbt.exceptions
from dbt import ui

import dbt.tracking


class DBTDeprecation:
_name: ClassVar[Optional[str]] = None
Expand All @@ -16,6 +18,11 @@ def name(self) -> str:
'name not implemented for {}'.format(self)
)

def track_deprecation_warn(self) -> None:
dbt.tracking.track_deprecation_warn({
Copy link
Contributor

@beckjake beckjake Aug 17, 2020

Choose a reason for hiding this comment

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

I think mypy is mad here because you don't import dbt.tracking at the top. The code works as-is for stupid python reasons because you imported dbt.exceptions, but I'm surprised flake8 accepted this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Heh. Ok cool I'll fix

"deprecation_name": self.name
})

@property
def description(self) -> str:
if self._description is not None:
Expand All @@ -31,6 +38,7 @@ def show(self, *args, **kwargs) -> None:
desc, prefix='* Deprecation Warning: '
)
dbt.exceptions.warn_or_error(msg)
self.track_deprecation_warn()
active_deprecations.add(self.name)


Expand Down
20 changes: 20 additions & 0 deletions core/dbt/tracking.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
INVOCATION_ENV_SPEC = 'iglu:com.dbt/invocation_env/jsonschema/1-0-0'
PACKAGE_INSTALL_SPEC = 'iglu:com.dbt/package_install/jsonschema/1-0-0'
RPC_REQUEST_SPEC = 'iglu:com.dbt/rpc_request/jsonschema/1-0-1'
DEPRECATION_WARN_SPEC = 'iglu:com.dbt/deprecation_warn/jsonschema/1-0-0'

DBT_INVOCATION_ENV = 'DBT_INVOCATION_ENV'

Expand Down Expand Up @@ -321,6 +322,25 @@ def track_package_install(config, args, options):
)


def track_deprecation_warn(options):

assert active_user is not None, \
'Cannot track deprecation warnings when active user is None'

context = [
SelfDescribingJson(DEPRECATION_WARN_SPEC, options)
]

track(
active_user,
category="dbt",
action='deprecation',
label=active_user.invocation_id,
property_='warn',
context=context
)


def track_invocation_end(
config=None, args=None, result_type=None
):
Expand Down