Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feat/telemetry' into feat/telemetry
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/ydata_profiling/utils/common.py
#	src/ydata_profiling/utils/logger.py
  • Loading branch information
Fabiana Clemente authored and Fabiana Clemente committed May 6, 2024
2 parents 022fd8f + ac84eda commit b63ed9c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<div class="row header">
<a class="anchor-pos" id="{{ section.content['anchor_id'] }}"></a>
<h1 class="page-header">{{ section.content['name'] }}</h1>
{% if section.content['name'] == 'Overview' %}
<p class="text-muted text-right">Brought to you by <a href="https://ydata.ai/?utm_source=opensource&utm_medium=ydataprofiling&utm_campaign=report">YData</a></p>
{% endif %}
<!--{% if section.content['name'] == 'Overview' %}
<p class="text-muted text-right">Brought to you by <a href="https://ydata.ai/?utm_source=opensource&utm_medium=ydataprofiling&utm_campaign=report">YData</a></p>
{% endif %}-->
</div>
<div class="section-items">
{{ html }}
Expand Down
31 changes: 17 additions & 14 deletions src/ydata_profiling/utils/common.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
"""Common util functions (e.g. missing in Python)."""
import collections.abc
import os
import subprocess
import platform

import pandas as pd
import requests

import collections.abc
import subprocess
import zipfile
from datetime import datetime, timedelta

Expand All @@ -15,8 +11,12 @@
from pathlib import Path
from typing import Mapping

import pandas as pd
import requests

from ydata_profiling.version import __version__


def update(d: dict, u: Mapping) -> dict:
"""Recursively update a dict.
Expand Down Expand Up @@ -97,8 +97,9 @@ def convert_timestamp_to_datetime(timestamp: int) -> datetime:
else:
return datetime(1970, 1, 1) + timedelta(seconds=int(timestamp))


def analytics_features(dataframe, datatype: bool, report_type: bool):
endpoint= "https://packages.ydata.ai/ydata-profiling?"
endpoint = "https://packages.ydata.ai/ydata-profiling?"

if os.getenv("YDATA_PROFILING_NO_ANALYTICS") != True:
package_version = __version__
Expand All @@ -111,13 +112,15 @@ def analytics_features(dataframe, datatype: bool, report_type: bool):
python_version = ".".join(platform.python_version().split(".")[:2])

try:
request_message = f"{endpoint}version={package_version}" \
f"&python_version={python_version}" \
f"&report_type={report_type}" \
f"&dataframe={dataframe}" \
f"&datatype={datatype}" \
f"&os={platform.system()}" \
f"&gpu={str(gpu_present)}"
request_message = (
f"{endpoint}version={package_version}"
f"&python_version={python_version}"
f"&report_type={report_type}"
f"&dataframe={dataframe}"
f"&datatype={datatype}"
f"&os={platform.system()}"
f"&gpu={str(gpu_present)}"
)

requests.get(request_message)
except Exception:
Expand Down
36 changes: 19 additions & 17 deletions src/ydata_profiling/utils/logger.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,42 @@
"""
Logger function for ydata-profiling reports
"""
from __future__ import absolute_import, division, print_function

import logging

import pandas as pd

from ydata_profiling.utils.common import analytics_features


class ProfilingLogger(logging.Logger):
def __init__(self, name, level=logging.INFO):
super().__init__(name, level)

def info(
self,
msg: object,
) -> None:
super().info(f'[PROFILING] - {msg}.')
self,
msg: object,
) -> None:
super().info(f"[PROFILING] - {msg}.")

def info_def_report(self, dataframe, timeseries: bool):
if dataframe == pd.DataFrame:
dataframe = 'pandas'
report_type = 'regular'
dataframe = "pandas"
report_type = "regular"
elif dataframe == type(None):
dataframe = 'pandas'
report_type='compare'
dataframe = "pandas"
report_type = "compare"
else:
dataframe = 'spark'
report_type = 'regular'
dataframe = "spark"
report_type = "regular"

datatype='timeseries' if timeseries else 'tabular'
datatype = "timeseries" if timeseries else "tabular"

analytics_features(dataframe=dataframe,
datatype=datatype,
report_type=report_type)
analytics_features(
dataframe=dataframe, datatype=datatype, report_type=report_type
)

super().info(f'[PROFILING] Calculating profile with the following characteristics '
f'- {dataframe} | {datatype} | {report_type}.')
super().info(
f"[PROFILING] Calculating profile with the following characteristics "
f"- {dataframe} | {datatype} | {report_type}."
)

0 comments on commit b63ed9c

Please sign in to comment.