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

Move references for serialize_json_safe() to raiutils #1536

Merged
merged 2 commits into from
Jul 7, 2022
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
2 changes: 1 addition & 1 deletion raiwidgets/raiwidgets/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from html.parser import HTMLParser

from rai_core_flask import FlaskHelper # , environment_detector
from responsibleai.serialization_utilities import serialize_json_safe
from raiutils.data_processing import serialize_json_safe

invalid_feature_flights_error = \
"feature_flights should be of type string. Separate multiple flights " \
Expand Down
3 changes: 1 addition & 2 deletions raiwidgets/raiwidgets/error_analysis_dashboard_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
from erroranalysis._internal.error_analyzer import (ModelAnalyzer,
PredictionsAnalyzer)
from erroranalysis._internal.utils import is_spark
from raiutils.data_processing import convert_to_list
from raiutils.data_processing import convert_to_list, serialize_json_safe
from raiutils.models import is_classifier
from responsibleai._interfaces import ErrorAnalysisData
from responsibleai.serialization_utilities import serialize_json_safe

from .constants import ModelTask
from .error_analysis_constants import (ErrorAnalysisDashboardInterface,
Expand Down
3 changes: 1 addition & 2 deletions raiwidgets/raiwidgets/explanation_dashboard_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import numpy as np
import pandas as pd

from raiutils.data_processing import convert_to_list
from raiutils.data_processing import convert_to_list, serialize_json_safe
from raiutils.models import is_classifier
from responsibleai.serialization_utilities import serialize_json_safe

from .constants import ErrorMessages
from .error_handling import _format_exception
Expand Down
2 changes: 1 addition & 1 deletion raiwidgets/tests/test_responsibleai_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

import pytest

from raiutils.data_processing import serialize_json_safe
from raiwidgets import ResponsibleAIDashboard
from raiwidgets.cohort import Cohort, CohortFilter, CohortFilterMethods
from raiwidgets.dashboard import invalid_feature_flights_error
from responsibleai._interfaces import (CausalData, CounterfactualData, Dataset,
ErrorAnalysisData, ModelExplanationData)
from responsibleai.exceptions import UserConfigValidationException
from responsibleai.serialization_utilities import serialize_json_safe


class TestResponsibleAIDashboard:
Expand Down
2 changes: 1 addition & 1 deletion responsibleai/responsibleai/_tools/shared/base_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

import jsonschema

from raiutils.data_processing import serialize_json_safe
from responsibleai._internal.constants import SerializationAttributes
from responsibleai._tools.shared.attribute_serialization import (
load_attributes, save_attributes)
from responsibleai.serialization_utilities import serialize_json_safe

TResult = TypeVar('TResult') # Type for subclasses of BaseResult

Expand Down
7 changes: 7 additions & 0 deletions responsibleai/responsibleai/serialization_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import datetime
import json
import warnings
from typing import Any

import numpy as np
Expand All @@ -15,6 +16,12 @@ def serialize_json_safe(o: Any):
:param o: Object to make JSON safe.
:return: Serialized object.
"""
warnings.warn(
"FUNCTION-DEPRECATION-WARNING: The function serialize_json_safe "
"will be deprecated in responsibleai. "
"Please import this function from raiutils.data_processing instead.",
DeprecationWarning)

if type(o) in {bool, int, float, str, type(None)}:
if isinstance(o, float):
if np.isinf(o) or np.isnan(o):
Expand Down