You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2024/05/15 22:59:53 UTC
(superset) branch elizabeth/tune-logging updated (eb36e279c6 -> 87b625eec8)
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a change to branch elizabeth/tune-logging
in repository https://gitbox.apache.org/repos/asf/superset.git
discard eb36e279c6 warning emits an error
new 87b625eec8 warning emits an error
This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version. This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:
* -- * -- B -- O -- O -- O (eb36e279c6)
\
N -- N -- N refs/heads/elizabeth/tune-logging (87b625eec8)
You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.
Any revisions marked "omit" are not gone; other references still
refer to them. Any revisions marked "discard" are gone forever.
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
superset/errors.py | 1 +
superset/exceptions.py | 12 ++++++++++++
superset/utils/pandas_postprocessing/compare.py | 4 ++--
.../unit_tests/pandas_postprocessing/test_compare.py | 20 +++++++++++++++++++-
4 files changed, 34 insertions(+), 3 deletions(-)
(superset) 01/01: warning emits an error
Posted by el...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
elizabeth pushed a commit to branch elizabeth/tune-logging
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 87b625eec8370b5d034c18c3ec39405d1bd6c1a1
Author: Elizabeth Thompson <es...@gmail.com>
AuthorDate: Wed May 15 14:49:06 2024 -0700
warning emits an error
---
superset/errors.py | 1 +
superset/exceptions.py | 12 ++++++++++++
superset/utils/pandas_postprocessing/compare.py | 12 ++++++++++--
.../unit_tests/pandas_postprocessing/test_compare.py | 20 +++++++++++++++++++-
4 files changed, 42 insertions(+), 3 deletions(-)
diff --git a/superset/errors.py b/superset/errors.py
index 9f0f5bed05..dfcf538bf4 100644
--- a/superset/errors.py
+++ b/superset/errors.py
@@ -74,6 +74,7 @@ class SupersetErrorType(StrEnum):
BACKEND_TIMEOUT_ERROR = "BACKEND_TIMEOUT_ERROR"
DATABASE_NOT_FOUND_ERROR = "DATABASE_NOT_FOUND_ERROR"
TABLE_NOT_FOUND_ERROR = "TABLE_NOT_FOUND_ERROR"
+ DATA_PROCESSING_ERROR = "DATA_PROCESSING_ERROR"
# Sql Lab errors
MISSING_TEMPLATE_PARAMS_ERROR = "MISSING_TEMPLATE_PARAMS_ERROR"
diff --git a/superset/exceptions.py b/superset/exceptions.py
index 0315ee30f4..9696d93a40 100644
--- a/superset/exceptions.py
+++ b/superset/exceptions.py
@@ -388,3 +388,15 @@ class TableNotFoundException(SupersetErrorException):
level=ErrorLevel.ERROR,
)
)
+
+class PandasProcessingException(SupersetErrorException):
+ status = 422
+
+ def __init__(self, message: str):
+ super().__init__(
+ SupersetError(
+ message=message,
+ error_type=SupersetErrorType.DATA_PROCESSING_ERROR,
+ level=ErrorLevel.WARNING,
+ )
+ )
diff --git a/superset/utils/pandas_postprocessing/compare.py b/superset/utils/pandas_postprocessing/compare.py
index b20682027f..4a53365caf 100644
--- a/superset/utils/pandas_postprocessing/compare.py
+++ b/superset/utils/pandas_postprocessing/compare.py
@@ -19,12 +19,17 @@ from typing import Optional
import pandas as pd
from flask_babel import gettext as _
from pandas import DataFrame
+from pandas.errors import PerformanceWarning
from superset.constants import PandasPostprocessingCompare
-from superset.exceptions import InvalidPostProcessingError
+from superset.exceptions import InvalidPostProcessingError, PandasProcessingException, SupersetException
from superset.utils.core import TIME_COMPARISON
from superset.utils.pandas_postprocessing.utils import validate_column_args
+import logging
+
+logger = logging.getLogger(__name__)
+
@validate_column_args("source_columns", "compare_columns")
def compare( # pylint: disable=too-many-arguments
@@ -81,5 +86,8 @@ def compare( # pylint: disable=too-many-arguments
df = pd.concat([df, diff_df], axis=1)
if drop_original_columns:
- df = df.drop(source_columns + compare_columns, axis=1)
+ try:
+ df = df.drop(source_columns + compare_columns, axis=1)
+ except PerformanceWarning as ex:
+ raise PandasProcessingException(str(ex))
return df
diff --git a/tests/unit_tests/pandas_postprocessing/test_compare.py b/tests/unit_tests/pandas_postprocessing/test_compare.py
index 9da8a31535..4e70748f74 100644
--- a/tests/unit_tests/pandas_postprocessing/test_compare.py
+++ b/tests/unit_tests/pandas_postprocessing/test_compare.py
@@ -14,13 +14,18 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
+from unittest.mock import patch
import pandas as pd
+import pytest
+from pandas.errors import PerformanceWarning
+
from superset.constants import PandasPostprocessingCompare as PPC
+from superset.exceptions import PandasProcessingException
from superset.utils import pandas_postprocessing as pp
from superset.utils.pandas_postprocessing.utils import FLAT_COLUMN_SEPARATOR
from tests.unit_tests.fixtures.dataframes import multiple_metrics_df, timeseries_df2
-
+from superset.utils.pandas_postprocessing.compare import logger
def test_compare_should_not_side_effect():
_timeseries_df2 = timeseries_df2.copy()
@@ -229,3 +234,16 @@ def test_compare_after_pivot():
}
)
)
+def test_exception_called(mocker):
+ drop_mock = mocker.patch("pandas.core.frame.DataFrame.drop")
+ drop_mock.side_effect = PerformanceWarning("warning message")
+
+ with pytest.raises(PandasProcessingException):
+ pp.compare(
+ df=timeseries_df2,
+ source_columns=["y"],
+ compare_columns=["z"],
+ compare_type=PPC.DIFF,
+ drop_original_columns=True,
+ )
+