-
Notifications
You must be signed in to change notification settings - Fork 164
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
feat: add __str__ methods to the various part of the profiler options #1115
Open
carlsonp
wants to merge
11
commits into
capitalone:dev
Choose a base branch
from
carlsonp:profile-options-str
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f411110
Replace snappy with cramjam (#1091)
gliptak 1f8ec47
Quick fix for dependency max pins (#1120)
abajpai15 f47ac0f
pre-commit fix (#1122)
taylorfturner 136e7eb
feat: add __str__ methods to the various part of the profiler options
carlsonp 6d2ad99
add docstrings
carlsonp 5765b1f
more docstring adjustments
carlsonp a32a49f
run python black formatter
carlsonp 39ab997
change option to iter_option to clarify and be explicit that this is …
carlsonp 53f7a22
print presets as well as other options
carlsonp 302681c
sort imports using isort
carlsonp cb15c63
add type to variables to fix mypy precommit hook checks
carlsonp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
|
||
import abc | ||
import copy | ||
import json | ||
import re | ||
import warnings | ||
from typing import Any, Generic, TypeVar, cast | ||
|
@@ -193,6 +194,15 @@ def __init__(self, is_enabled: bool = True) -> None: | |
""" | ||
self.is_enabled = is_enabled | ||
|
||
def __str__(self) -> str: | ||
""" | ||
Return a human friendly consumable output in string form. | ||
|
||
:return: str of the option properties | ||
:rtype: str | ||
""" | ||
return str(self.is_enabled) | ||
|
||
def _validate_helper(self, variable_path: str = "BooleanOption") -> list[str]: | ||
""" | ||
Validate the options do not conflict and cause errors. | ||
|
@@ -958,6 +968,25 @@ def __init__( | |
self.cms_relative_error = cms_relative_error | ||
self.cms_max_num_heavy_hitters = cms_max_num_heavy_hitters | ||
|
||
def __str__(self) -> str: | ||
""" | ||
Return a human friendly consumable output in string form. | ||
|
||
:vartype dict_string: dict | ||
:return: str of the option properties | ||
:rtype: str | ||
""" | ||
dict_string: dict = {"CategoricalOptions": []} | ||
for iter_option in [ | ||
a | ||
for a in dir(self) | ||
if not a.startswith("__") and not callable(getattr(self, a)) | ||
]: | ||
dict_string["CategoricalOptions"].append( | ||
{str(iter_option): str(getattr(self, iter_option))} | ||
) | ||
return json.dumps(dict_string, indent=4) | ||
|
||
def _validate_helper(self, variable_path: str = "CategoricalOptions") -> list[str]: | ||
""" | ||
Validate the options do not conflict and cause errors. | ||
|
@@ -1182,6 +1211,25 @@ def __init__( | |
) | ||
self.null_count: BooleanOption = BooleanOption(is_enabled=null_count) | ||
|
||
def __str__(self) -> str: | ||
""" | ||
Return a human friendly consumable output in string form. | ||
|
||
:vartype dict_string: dict | ||
:return: str of the option properties | ||
:rtype: str | ||
""" | ||
dict_string: dict = {"RowStatisticsOptions": []} | ||
for iter_option in [ | ||
a | ||
for a in dir(self) | ||
if not a.startswith("__") and not callable(getattr(self, a)) | ||
]: | ||
dict_string["RowStatisticsOptions"].append( | ||
{str(iter_option): str(getattr(self, iter_option))} | ||
) | ||
return json.dumps(dict_string, indent=4) | ||
|
||
def _validate_helper( | ||
self, variable_path: str = "RowStatisticsOptions" | ||
) -> list[str]: | ||
|
@@ -1228,6 +1276,25 @@ def __init__(self) -> None: | |
self.max_sample_size: int | None = None | ||
self.data_labeler_object: BaseDataLabeler | None = None | ||
|
||
def __str__(self) -> str: | ||
""" | ||
Return a human friendly consumable output in string form. | ||
|
||
:vartype dict_string: dict | ||
:return: str of the option properties | ||
:rtype: str | ||
""" | ||
dict_string: dict = {"DataLabelerOptions": []} | ||
for iter_option in [ | ||
a | ||
for a in dir(self) | ||
if not a.startswith("__") and not callable(getattr(self, a)) | ||
]: | ||
dict_string["DataLabelerOptions"].append( | ||
{str(iter_option): str(getattr(self, iter_option))} | ||
) | ||
return json.dumps(dict_string, indent=4) | ||
|
||
def __deepcopy__(self, memo: dict) -> DataLabelerOptions: | ||
""" | ||
Override deepcopy for data labeler object. | ||
|
@@ -1370,6 +1437,25 @@ def __init__( | |
self.vocab: BooleanOption = BooleanOption(is_enabled=True) | ||
self.words: BooleanOption = BooleanOption(is_enabled=True) | ||
|
||
def __str__(self) -> str: | ||
""" | ||
Return a human friendly consumable output in string form. | ||
|
||
:vartype dict_string: dict | ||
:return: str of the option properties | ||
:rtype: str | ||
""" | ||
dict_string: dict = {"TextProfilerOptions": []} | ||
for iter_option in [ | ||
a | ||
for a in dir(self) | ||
if not a.startswith("__") and not callable(getattr(self, a)) | ||
]: | ||
dict_string["TextProfilerOptions"].append( | ||
{str(iter_option): str(getattr(self, iter_option))} | ||
) | ||
return json.dumps(dict_string, indent=4) | ||
|
||
def _validate_helper(self, variable_path: str = "TextProfilerOptions") -> list[str]: | ||
""" | ||
Validate the options do not conflict and cause errors. | ||
|
@@ -1488,6 +1574,25 @@ def __init__( | |
self.column_null_values = column_null_values | ||
self.sampling_ratio = sampling_ratio | ||
|
||
def __str__(self) -> str: | ||
""" | ||
Return a human friendly consumable output in string form. | ||
|
||
:vartype dict_string: dict | ||
:return: str of the option properties | ||
:rtype: str | ||
""" | ||
dict_string: dict = {"StructuredOptions": []} | ||
for iter_option in [ | ||
a | ||
for a in dir(self) | ||
if not a.startswith("__") and not callable(getattr(self, a)) | ||
]: | ||
dict_string["StructuredOptions"].append( | ||
{str(iter_option): str(getattr(self, iter_option))} | ||
) | ||
return json.dumps(dict_string, indent=4) | ||
|
||
@property | ||
def enabled_profiles(self) -> list[str]: | ||
"""Return a list of the enabled profilers for columns.""" | ||
|
@@ -1638,6 +1743,25 @@ def __init__(self) -> None: | |
self.text = TextProfilerOptions() | ||
self.data_labeler = DataLabelerOptions() | ||
|
||
def __str__(self) -> str: | ||
""" | ||
Return a human friendly consumable output in string form. | ||
|
||
:vartype dict_string: dict | ||
:return: str of the option properties | ||
:rtype: str | ||
""" | ||
dict_string: dict = {"UnstructuredOptions": []} | ||
for iter_option in [ | ||
a | ||
for a in dir(self) | ||
if not a.startswith("__") and not callable(getattr(self, a)) | ||
]: | ||
dict_string["UnstructuredOptions"].append( | ||
{str(iter_option): str(getattr(self, iter_option))} | ||
) | ||
return json.dumps(dict_string, indent=4) | ||
|
||
@property | ||
def enabled_profiles(self) -> list[str]: | ||
"""Return a list of the enabled profilers.""" | ||
|
@@ -1715,6 +1839,17 @@ def __init__(self, presets: str = None) -> None: | |
else: | ||
raise ValueError("The preset entered is not a valid preset.") | ||
|
||
def __str__(self) -> str: | ||
""" | ||
Return a human friendly consumable output in string form. | ||
|
||
:return: str of the option presets and properties | ||
:rtype: str | ||
""" | ||
return f"Presets: {str(self.presets)}\n \ | ||
{str(self.structured_options)}\n \ | ||
{str(self.unstructured_options)}" | ||
|
||
Comment on lines
+1842
to
+1852
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this makes sense here and you would test in |
||
def _complete_presets(self) -> None: | ||
self.set({"*.is_enabled": True}) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
scikit-learn>=0.23.2 | ||
keras>=2.4.3 | ||
keras>=2.4.3,<3.0.0 | ||
rapidfuzz>=2.6.1 | ||
tensorflow>=2.6.4; sys.platform != 'darwin' | ||
tensorflow>=2.6.4; sys_platform == 'darwin' and platform_machine != 'arm64' | ||
tensorflow-macos>=2.6.4; sys_platform == 'darwin' and platform_machine == 'arm64' | ||
tensorflow>=2.6.4,<2.15.0; sys.platform != 'darwin' | ||
tensorflow>=2.6.4,<2.15.0; sys_platform == 'darwin' and platform_machine != 'arm64' | ||
tensorflow-macos>=2.6.4,<2.15.0; sys_platform == 'darwin' and platform_machine == 'arm64' | ||
tqdm>=4.0.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
coverage>=5.0.1 | ||
dask>=2.29.0 | ||
dask>=2.29.0,<2024.2.0 | ||
fsspec>=0.3.3 | ||
pytest>=6.0.1 | ||
pytest-cov>=2.8.1 | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good to find a way to abstract this a bit more so this ends up in
BaseOption
90%+ of this code is repeat just with string changes: so I think there is room to make this DRY-er