Skip to content

Commit

Permalink
Fix HuggingFaceFeature / CustomEvals hash error. (#1248)
Browse files Browse the repository at this point in the history
* Fix HuggingFaceFeature hash error.
* Fix CustomEvals hash error.
  • Loading branch information
Liraim authored Aug 12, 2024
1 parent 6d68435 commit 0c4ddff
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/evidently/features/hf_feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ def generate_data(self, data: pd.DataFrame, data_definition: DataDefinition) ->
result = func(data[self.column_name], **{param: self.params.get(param, None) for param in available_params})
return result

def __hash__(self):
return DataFeature.__hash__(self)


class HuggingFaceToxicityFeature(DataFeature):
__feature_type__: ClassVar = ColumnType.Numerical
Expand Down
3 changes: 3 additions & 0 deletions src/evidently/pydantic_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from functools import lru_cache
from typing import TYPE_CHECKING
from typing import Any
from typing import Callable
from typing import ClassVar
from typing import Dict
from typing import FrozenSet
Expand Down Expand Up @@ -223,6 +224,8 @@ def get_value_fingerprint(value: Any) -> FingerprintPart:
return tuple(get_value_fingerprint(v) for v in value)
if isinstance(value, (set, frozenset)):
return tuple(get_value_fingerprint(v) for v in sorted(value, key=str))
if isinstance(value, Callable): # type: ignore
return hash(value)
raise NotImplementedError(
f"Not implemented for value of type {value.__class__.__module__}.{value.__class__.__name__}"
)
Expand Down

0 comments on commit 0c4ddff

Please sign in to comment.