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

remove telemetry #1034

Merged
merged 2 commits into from
Sep 18, 2024
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 0.10.14dev

* [Feature] Removes telemetry

## 0.10.13 (2024-09-12)

* [Feature] `ploomber-extension` is no longer a dependency
Expand Down
2 changes: 1 addition & 1 deletion doc/community/developer-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ print("all: ", results.fetchall())
Functions that expect a `conn` (sometimes named `con`) input variable should assume the input argument is a connection objects (either `SQLAlchemyConnection` or `DBAPIConnection`):

```python
def histogram(payload, table, column, bins, with_=None, conn=None):
def histogram(table, column, bins, with_=None, conn=None):
pass
```

Expand Down
4 changes: 0 additions & 4 deletions doc/community/support.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Support

For support, feature requests, and product updates: [join our community](https://ploomber.io/community) or follow us on [Twitter](https://twitter.com/ploomber)/[LinkedIn](https://www.linkedin.com/company/ploomber/).

# Telemetry

We collect (optional) anonymous statistics to understand and improve usage. For more details of what we collect and how to opt-out the telemetry collection, [see here](https://docs.ploomber.io/en/latest/community/user-stats.html).
16 changes: 2 additions & 14 deletions src/sql/connection/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@


from sql.store import store
from sql.telemetry import telemetry
from sql import exceptions, display
from sql.error_handler import handle_exception
from sql.parse import (
Expand Down Expand Up @@ -990,13 +989,7 @@ class DBAPIConnection(AbstractConnection):

is_dbapi_connection = True

@telemetry.log_call("DBAPIConnection", payload=True)
def __init__(self, payload, connection, alias=None, config=None):
try:
payload["engine"] = type(connection)
except Exception as e:
payload["engine_parsing_error"] = str(e)

def __init__(self, connection, alias=None, config=None):
# detect if the engine is a native duckdb connection
_is_duckdb_native = _check_if_duckdb_dbapi_connection(connection)

Expand Down Expand Up @@ -1084,12 +1077,7 @@ def to_table(self, table_name, data_frame, if_exists, index, schema=None):
class SparkConnectConnection(AbstractConnection):
is_dbapi_connection = False

@telemetry.log_call("SparkConnectConnection", payload=True)
def __init__(self, payload, connection, alias=None, config=None):
try:
payload["engine"] = type(connection)
except Exception as e:
payload["engine_parsing_error"] = str(e)
def __init__(self, connection, alias=None, config=None):
self._driver = None

# TODO: implement the dialect blacklist and add unit tests
Expand Down
4 changes: 0 additions & 4 deletions src/sql/ggplot/aes.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from sql.telemetry import telemetry


class aes:
"""
Aesthetic mappings
Expand All @@ -17,7 +14,6 @@ class aes:
The edge color of a shape
"""

@telemetry.log_call("aes-init")
def __init__(self, x=None, fill=None, color=None):
self.x = x
self.fill = fill
Expand Down
2 changes: 0 additions & 2 deletions src/sql/ggplot/facet_wrap.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from jinja2 import Template
import math
import sql.connection
from sql.telemetry import telemetry
from sql.util import enclose_table_with_double_quotations


Expand Down Expand Up @@ -42,7 +41,6 @@ class facet_wrap(facet):
Column to groupby and plot on different panels.
"""

@telemetry.log_call("facet-wrap-init")
def __init__(self, facet: str, legend=True):
self.facet = facet
self.legend = legend
Expand Down
2 changes: 0 additions & 2 deletions src/sql/ggplot/geom/geom_boxplot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from sql import plot
from sql.ggplot.geom.geom import geom
from sql.telemetry import telemetry


class geom_boxplot(geom):
Expand All @@ -11,7 +10,6 @@ class geom_boxplot(geom):
def __init__(self):
pass

@telemetry.log_call("ggplot-boxplot")
def draw(self, gg, ax=None):
plot.boxplot(
table=gg.table,
Expand Down
2 changes: 0 additions & 2 deletions src/sql/ggplot/geom/geom_histogram.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from sql import plot
from sql.ggplot.geom.geom import geom
from sql.telemetry import telemetry


class geom_histogram(geom):
Expand Down Expand Up @@ -36,7 +35,6 @@ def __init__(
self.binwidth = binwidth
super().__init__(**kwargs)

@telemetry.log_call("ggplot-histogram")
def draw(self, gg, ax=None, facet=None):
plot.histogram(
table=gg.table,
Expand Down
2 changes: 0 additions & 2 deletions src/sql/ggplot/ggplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import matplotlib as mpl
import matplotlib.pyplot as plt
from ploomber_core.dependencies import requires
from sql.telemetry import telemetry


def _expand_to_multipanel_ax(figure, ax_to_clear=None):
Expand All @@ -28,7 +27,6 @@ class ggplot:
figure: mpl.figure.Figure
axs: list

@telemetry.log_call("ggplot-init")
def __init__(self, table, mapping: aes = None, conn=None, with_=None) -> None:
self.table = table
self.with_ = [with_] if with_ else None
Expand Down
4 changes: 0 additions & 4 deletions src/sql/inspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from prettytable import PrettyTable
from ploomber_core.exceptions import modify_exceptions
from sql.connection import ConnectionManager
from sql.telemetry import telemetry
from sql import exceptions
import math
from sql import util
Expand Down Expand Up @@ -477,19 +476,16 @@ def __init__(self, table_name, schema=None) -> None:
self._table_txt = self._table.get_string()


@telemetry.log_call()
def get_table_names(schema=None):
"""Get table names for a given connection"""
return Tables(schema)


@telemetry.log_call()
def get_columns(name, schema=None):
"""Get column names for a given connection"""
return Columns(name, schema)


@telemetry.log_call()
def get_table_statistics(name, schema=None):
"""Get table statistics for a given connection.

Expand Down
10 changes: 3 additions & 7 deletions src/sql/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@
DataFrame = None
Series = None

from sql.telemetry import telemetry


SUPPORT_INTERACTIVE_WIDGETS = ["Checkbox", "Text", "IntSlider", ""]
IF_NOT_SELECT_MESSAGE = "The query is not a SELECT type query and as \
Expand All @@ -81,7 +79,6 @@ class RenderMagic(Magics):
action="append",
dest="with_",
)
@telemetry.log_call("sqlrender")
def sqlrender(self, line):
args = parse_argstring(self.sqlrender, line)
warnings.warn(
Expand Down Expand Up @@ -187,7 +184,6 @@ class SqlMagic(Magics, Configurable):
),
)

@telemetry.log_call("init")
def __init__(self, shell):
self._store = store

Expand Down Expand Up @@ -370,14 +366,15 @@ def execute(self, line="", cell="", local_ns=None):
line=line, cell=cell, local_ns=local_ns, is_interactive_mode=False
)

@telemetry.log_call("execute", payload=True)
@modify_exceptions
def _execute(self, payload, line, cell, local_ns, is_interactive_mode=False):
def _execute(self, line, cell, local_ns, is_interactive_mode=False):
"""
This function implements the cell logic; we create this private
method so we can control how the function is called. Otherwise,
decorating ``SqlMagic.execute`` will break when adding the ``@log_call``
decorator with ``payload=True``

NOTE: telemetry has been removed, we can remove this function
"""

def interactive_execute_wrapper(**kwargs):
Expand Down Expand Up @@ -518,7 +515,6 @@ def interactive_execute_wrapper(**kwargs):
alias=args.section if args.section else args.alias,
config=self,
)
payload["connection_info"] = conn._get_database_information()

if args.persist_replace and args.append:
raise exceptions.UsageError(
Expand Down
18 changes: 2 additions & 16 deletions src/sql/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
np = None

import sql.connection
from sql.telemetry import telemetry
import warnings


Expand Down Expand Up @@ -178,10 +177,7 @@ def _compute_conf_interval(N, med, iqr):

# https://github.com/matplotlib/matplotlib/blob/ddc260ce5a53958839c244c0ef0565160aeec174/lib/matplotlib/axes/_axes.py#L3915
@requires(["matplotlib"])
@telemetry.log_call("boxplot", payload=True)
def boxplot(
payload, table, column, *, orient="v", with_=None, conn=None, ax=None, schema=None
):
def boxplot(table, column, *, orient="v", with_=None, conn=None, ax=None, schema=None):
"""Plot boxplot

Parameters
Expand Down Expand Up @@ -231,8 +227,6 @@ def boxplot(
if not conn:
conn = sql.connection.ConnectionManager.current

payload["connection_info"] = conn._get_database_information()

_table = enclose_table_with_double_quotations(table, conn)
if schema:
_table = f'"{schema}"."{_table}"'
Expand Down Expand Up @@ -316,9 +310,7 @@ def _get_bar_width(ax, bins, bin_size, binwidth):


@requires(["matplotlib"])
@telemetry.log_call("histogram", payload=True)
def histogram(
payload,
table,
column,
bins,
Expand Down Expand Up @@ -409,7 +401,7 @@ def histogram(
_table = f'"{schema}"."{_table}"'

ax = ax or plt.gca()
payload["connection_info"] = conn._get_database_information()

if category:
if isinstance(column, list):
if len(column) > 1:
Expand Down Expand Up @@ -874,9 +866,7 @@ def _bar(table, column, with_=None, conn=None):


@requires(["matplotlib"])
@telemetry.log_call("bar", payload=True)
def bar(
payload,
table,
column,
show_num=False,
Expand Down Expand Up @@ -928,7 +918,6 @@ def bar(
_table = f'"{schema}"."{_table}"'

ax = ax or plt.gca()
payload["connection_info"] = conn._get_database_information()

if column is None:
raise exceptions.UsageError("Column name has not been specified")
Expand Down Expand Up @@ -1059,9 +1048,7 @@ def _pie(table, column, with_=None, conn=None):


@requires(["matplotlib"])
@telemetry.log_call("bar", payload=True)
def pie(
payload,
table,
column,
show_num=False,
Expand Down Expand Up @@ -1107,7 +1094,6 @@ def pie(
_table = f'"{schema}"."{_table}"'

ax = ax or plt.gca()
payload["connection_info"] = conn._get_database_information()

if column is None:
raise exceptions.UsageError("Column name has not been specified")
Expand Down
10 changes: 1 addition & 9 deletions src/sql/run/resultset.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

from sql.column_guesser import ColumnGuesserMixin
from sql.run.csv import CSVWriter, CSVResultDescriptor
from sql.telemetry import telemetry
from sql.run.table import CustomPrettyTable
from sql._current import _config_feedback_all

Expand Down Expand Up @@ -246,23 +245,19 @@ def dicts(self):
for row in self:
yield dict(zip(self.keys, row))

@telemetry.log_call("data-frame", payload=True)
def DataFrame(self, payload):
def DataFrame(self):
"""Returns a Pandas DataFrame instance built from the result set."""
payload["connection_info"] = self._conn._get_database_information()
import pandas as pd

return _convert_to_data_frame(self, "df", pd.DataFrame)

@telemetry.log_call("polars-data-frame")
def PolarsDataFrame(self, **polars_dataframe_kwargs):
"""Returns a Polars DataFrame instance built from the result set."""
import polars as pl

polars_dataframe_kwargs["schema"] = self.keys
return _convert_to_data_frame(self, "pl", pl.DataFrame, polars_dataframe_kwargs)

@telemetry.log_call("pie")
def pie(self, key_word_sep=" ", title=None, **kwargs):
"""Generates a pylab pie chart from the result set.

Expand Down Expand Up @@ -302,7 +297,6 @@ def pie(self, key_word_sep=" ", title=None, **kwargs):
ax.set_title(title or self.ys[0].name)
return ax

@telemetry.log_call("plot")
def plot(self, title=None, **kwargs):
"""Generates a pylab plot from the result set.

Expand Down Expand Up @@ -349,7 +343,6 @@ def plot(self, title=None, **kwargs):

return ax

@telemetry.log_call("bar")
def bar(self, key_word_sep=" ", title=None, **kwargs):
"""Generates a pylab bar plot from the result set.

Expand Down Expand Up @@ -393,7 +386,6 @@ def bar(self, key_word_sep=" ", title=None, **kwargs):
ax.set_ylabel(self.ys[0].name)
return ax

@telemetry.log_call("generate-csv")
def csv(self, filename=None, **format_params):
"""Generate results in comma-separated form. Write to ``filename`` if given.
Any other parameters will be passed on to csv.writer."""
Expand Down
13 changes: 0 additions & 13 deletions src/sql/telemetry.py

This file was deleted.

2 changes: 0 additions & 2 deletions src/sql/widgets/table_widget/table_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from sql.util import parse_sql_results_to_json
from sql.inspect import fetch_sql_with_pagination, is_table_exists
from sql.widgets import utils
from sql.telemetry import telemetry

import os
from ploomber_core.dependencies import check_installed
Expand All @@ -15,7 +14,6 @@


class TableWidget:
@telemetry.log_call("TableWidget-init")
def __init__(self, table, schema=None):
"""
Creates an HTML table element and populates it with SQL table
Expand Down
Loading
Loading