Skip to content

Commit

Permalink
fix(linting): code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
azory-ydata committed May 6, 2024
1 parent 022fd8f commit 0b0dcf8
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 31 deletions.
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 0b0dcf8

Please sign in to comment.