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

Removes futures from required libs #746

Merged
merged 4 commits into from
Jan 5, 2023
Merged

Conversation

JGSweets
Copy link
Collaborator

@JGSweets JGSweets commented Jan 4, 2023

We are no longer maintaining py2 or <= py3.7. Therefore, this is no longer needed

@JGSweets JGSweets added Medium Priority Significant improvement or bug / feature reducing overall performance Refactor Code that is being modified to improve the library labels Jan 4, 2023
@@ -3,8 +3,6 @@
from io import StringIO
from typing import Dict, List, Optional, Union, cast

from past.builtins import basestring
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no longer needed

and len(data)
and isinstance(data[0], (str, basestring))
):
if isinstance(data, list) and len(data) and isinstance(data[0], str):
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

basestring is for py2

@@ -15,6 +15,8 @@
class AutoSubRegistrationMeta(abc.ABCMeta):
"""For registering subclasses."""

_register_subclass: Callable[[type[AutoSubRegistrationMeta]], None]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

proper mypy

@@ -93,7 +95,9 @@ def _register_subclass(cls) -> None:
@property
def label_mapping(self) -> dict[str, int]:
"""Return mapping of labels to their encoded values."""
return copy.deepcopy(self._label_mapping)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

potential bug fix

@@ -154,7 +158,7 @@ def get_class(cls, class_name: str) -> type[BaseModel] | None:

return cls._BaseModel__subclasses.get(class_name.lower(), None)

def get_parameters(self, param_list: list[str] = None) -> dict:
Copy link
Collaborator Author

@JGSweets JGSweets Jan 4, 2023

Choose a reason for hiding this comment

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

rest in this file are static typing

@@ -189,7 +193,7 @@ def set_params(self, **kwargs: Any) -> None:
for param in kwargs:
self._parameters[param] = kwargs[param]

def add_label(self, label: str, same_as: str = None) -> None:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this file is static typing

@@ -97,7 +97,7 @@ def help(cls) -> None:
"""
raise NotImplementedError()

def get_parameters(self, param_list: list[str] = None) -> dict:
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this file is static typing

@@ -1,8 +1,10 @@
"""Contains functions for the data labeler."""
from __future__ import annotations
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this file is static typing

@@ -10,14 +10,13 @@

import numpy as np
import pandas as pd
from future.utils import with_metaclass
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this is a main change to fix the metaclass

@@ -5,7 +5,6 @@
from collections import OrderedDict
from multiprocessing.pool import Pool

from future.utils import with_metaclass
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

main change to fix the metaclass

@@ -1,22 +1,23 @@
"""Contains helper functions for generating report."""
from __future__ import annotations
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this file is static typing

@@ -9,7 +9,7 @@
from .profiler_options import IntOptions
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

this file is static typing

@@ -32,7 +31,7 @@ def __init__(self, function: Callable) -> None:
__isabstractmethod__ = True


class NumericStatsMixin(with_metaclass(abc.ABCMeta, object)): # type: ignore
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

main change here

Comment on lines -370 to +379
profile: dict = OrderedDict() # type: ignore[no-redef]
report: OrderedDict = OrderedDict()
if "data_label_profile" not in self.profiles:
dict_order.remove("data_label")
for key in dict_order:
try:
profile[key] = unordered_profile[key]
report[key] = unordered_profile[key] # type: ignore
except KeyError:
profile[key] = None
report[key] = None # type: ignore

return profile
return report
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

uses report as static typing issues

@@ -944,20 +944,24 @@ def _remove_data_labelers(

# get all profiles, unstructured is a single profile and hence needs to
# be in a list, whereas structured is already a list
profilers = [self._profile]
Copy link
Collaborator Author

@JGSweets JGSweets Jan 4, 2023

Choose a reason for hiding this comment

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

a lot of this file is static typing fixes

[
col._last_batch_size
for col in self._profile
if col._last_batch_size is not None
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fix to skip if None otherwise min would fail

@@ -1791,6 +1814,15 @@ def _get_and_validate_schema_mapping(

return schema_mapping

@property
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

static typing fix

@@ -7,8 +7,9 @@
from typing import TYPE_CHECKING, List, Union, cast

if TYPE_CHECKING:
from dataprofiler.profilers.float_column_profile import FloatColumn
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

use same relative format

@@ -69,10 +66,11 @@ def plot_histograms(
"column indexes in the profiler"
)

profile_list: list[StructuredColProfiler] = profiler.profile
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

static typing fix

@@ -1,6 +1,5 @@
h5py>=2.10.0
wheel>=0.33.1
future>=0.18.2
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

the removal

@@ -15,6 +15,7 @@ line_length=88
warn_return_any = True
warn_unused_configs = True
ignore_missing_imports = True
disable_error_code = override
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

need to address at a later time, but some mixin / abstraction issues with mypy

Copy link
Contributor

Choose a reason for hiding this comment

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

We should document this if it is needed in the future

@micdavis micdavis merged commit 94a4822 into capitalone:main Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Medium Priority Significant improvement or bug / feature reducing overall performance Refactor Code that is being modified to improve the library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants