Skip to content
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
29 changes: 27 additions & 2 deletions dataprofiler/profilers/profiler_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import copy
import re
import warnings
from typing import Any

from ..labelers.base_data_labeler import BaseDataLabeler

Expand Down Expand Up @@ -1557,7 +1558,8 @@ def __init__(self, presets: str = None) -> None:
:ivar unstructured_options: option set for unstructured dataset profiling.
:vartype unstructured_options: UnstructuredOptions
:ivar presets: A pre-configured mapping of a string name to group of options:
"complete", "data_types", and "numeric_stats_disabled". Default: None
"complete", "data_types", "numeric_stats_disabled",
and "memory_optimization". Default: None
:vartype presets: Optional[str]
"""
self.structured_options = StructuredOptions()
Expand All @@ -1570,6 +1572,10 @@ def __init__(self, presets: str = None) -> None:
self._data_types_presets()
elif self.presets == "numeric_stats_disabled":
self._numeric_stats_disabled_presets()
elif self.presets == "memory_optimization":
self._memory_optimization_presets()
else:
raise ValueError("The preset entered is not a valid preset.")

def _complete_presets(self) -> None:
self.set({"*.is_enabled": True})
Expand All @@ -1583,6 +1589,25 @@ def _numeric_stats_disabled_presets(self) -> None:
self.set({"*.float.is_numeric_stats_enabled": False})
self.set({"structured_options.text.is_numeric_stats_enabled": False})

def _memory_optimization_presets(self) -> None:
self.set({"structured_options.row_statistics.is_enabled": False})
Copy link
Contributor

Choose a reason for hiding this comment

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

should row_statistics be enabled with HLL @taylorfturner

Copy link
Contributor

Choose a reason for hiding this comment

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

that's more TBD IMO

self.set({"structured_options.multiprocess.is_enabled": False})
self.set({"structured_options.data_labeler.is_enabled": False})
self.set({"structured_options.datetime.is_enabled": False})
self.set({"structured_options.order.is_enabled": False})
Comment on lines +1596 to +1597
Copy link
Contributor

Choose a reason for hiding this comment

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

curious why we are specifically disabling these two. Are they memory intensive?

self.set({"structured_options.chi2_homogeneity.is_enabled": False})
self.set({"structured_options.null_replication_metrics.is_enabled": False})
self.set({"unstructured_options.data_labeler.is_enabled": False})
self.set(
{
(
"structured_options.category."
"max_sample_size_to_check_stop_condition"
): 5000
}
)
self.set({"structured_options.category.stop_condition_unique_value_ratio": 0.5})

def _validate_helper(self, variable_path: str = "ProfilerOptions") -> list[str]:
"""
Validate the options do not conflict and cause errors.
Expand Down Expand Up @@ -1620,7 +1645,7 @@ def _validate_helper(self, variable_path: str = "ProfilerOptions") -> list[str]:

return errors

def set(self, options: dict[str, bool]) -> None:
def set(self, options: dict[str, Any]) -> None:
"""
Overwrite BaseOption.set.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,26 @@ def test_profiler_preset_numeric_stats_disabled(self, *mocks):
self.assertFalse(options.structured_options.null_replication_metrics.is_enabled)
self.assertTrue(options.structured_options.category.is_enabled)
self.assertTrue(options.structured_options.order.is_enabled)

def test_profiler_preset_memory_optimization(self, *mocks):
options = ProfilerOptions(presets="memory_optimization")
self.assertFalse(options.structured_options.row_statistics.is_enabled)
self.assertFalse(options.structured_options.multiprocess.is_enabled)
self.assertFalse(options.structured_options.data_labeler.is_enabled)
self.assertFalse(options.structured_options.datetime.is_enabled)
self.assertFalse(options.structured_options.order.is_enabled)
self.assertFalse(options.structured_options.chi2_homogeneity.is_enabled)
self.assertFalse(options.structured_options.null_replication_metrics.is_enabled)
self.assertFalse(options.unstructured_options.data_labeler.is_enabled)
self.assertEqual(
options.structured_options.category.max_sample_size_to_check_stop_condition,
5000,
)
self.assertEqual(
options.structured_options.category.stop_condition_unique_value_ratio, 0.5
)

def test_profiler_preset_failure(self, *mocks):
expected_error = "The preset entered is not a valid preset."
with self.assertRaisesRegex(ValueError, expected_error):
ProfilerOptions(presets="failing_preset")