Skip to content

Commit

Permalink
FIX-modin-project#4518: Fix Modin Logging to report specific Modin wa…
Browse files Browse the repository at this point in the history
…rnings/errors (modin-project#4519)


Signed-off-by: Naren Krishna <naren@ponder.io>

Co-authored-by: Mahesh Vashishtha <mvashishtha@users.noreply.github.com>
  • Loading branch information
naren-ponder and mvashishtha authored Jun 1, 2022
1 parent aabedd1 commit 4aefe86
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
1 change: 1 addition & 0 deletions docs/release_notes/release_notes-0.15.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Key Features and Updates
* FIX-#4461: Fix S3 CSV data path (#4462)
* FIX-#4467: `drop_duplicates` no longer removes items based on index values (#4468)
* FIX-#4449: Drain the call queue before waiting on result in benchmark mode (#4472)
* FIX-#4518: Fix Modin Logging to report specific Modin warnings/errors (#4519)
* FIX-#4481: Allow clipping with a Modin Series of bounds (#4486)
* FIX-#4504: Support na_action in applymap (#4505)
* FIX-#4503: Stop the memory logging thread after session exit (#4515)
Expand Down
24 changes: 14 additions & 10 deletions modin/error_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# governing permissions and limitations under the License.

import warnings
from modin.logging import logger_decorator
from modin.logging import get_logger


class ErrorMessage(object):
Expand All @@ -21,10 +21,10 @@ class ErrorMessage(object):
printed_warnings = set()

@classmethod
@logger_decorator("MODIN-ERROR", "ErrorMessage.not_implemented", "debug")
def not_implemented(cls, message=""):
if message == "":
message = "This functionality is not yet available in Modin."
get_logger().info(f"Modin Error: NotImplementedError: {message}")
raise NotImplementedError(
f"{message}\n"
+ "To request implementation, file an issue at "
Expand All @@ -33,17 +33,20 @@ def not_implemented(cls, message=""):
)

@classmethod
@logger_decorator("MODIN-ERROR", "ErrorMessage.single_warning", "debug")
def single_warning(cls, message):
message_hash = hash(message)
logger = get_logger()
if message_hash in cls.printed_warnings:
logger.debug(
f"Modin Warning: Single Warning: {message} was raised and suppressed."
)
return

logger.debug(f"Modin Warning: Single Warning: {message} was raised.")
warnings.warn(message)
cls.printed_warnings.add(message_hash)

@classmethod
@logger_decorator("MODIN-ERROR", "ErrorMessage.default_to_pandas", "debug")
def default_to_pandas(cls, message=""):
if message != "":
message = f"{message} defaulting to pandas implementation."
Expand All @@ -57,14 +60,13 @@ def default_to_pandas(cls, message=""):
+ "https://modin.readthedocs.io/en/stable/supported_apis/defaulting_to_pandas.html for explanation."
)
cls.printed_default_to_pandas = True
get_logger().debug(f"Modin Warning: Default to pandas: {message}")
warnings.warn(message)

@classmethod
@logger_decorator(
"MODIN-ERROR", "ErrorMessage.catch_bugs_and_request_email", "debug"
)
def catch_bugs_and_request_email(cls, failure_condition, extra_log=""):
if failure_condition:
get_logger().info(f"Modin Error: Internal Error: {extra_log}")
raise Exception(
"Internal Error. "
+ "Please visit https://github.com/modin-project/modin/issues "
Expand All @@ -74,23 +76,25 @@ def catch_bugs_and_request_email(cls, failure_condition, extra_log=""):
)

@classmethod
@logger_decorator("MODIN-ERROR", "ErrorMessage.non_verified_udf", "debug")
def non_verified_udf(cls):
get_logger().debug("Modin Warning: Non Verified UDF")
warnings.warn(
"User-defined function verification is still under development in Modin. "
+ "The function provided is not verified."
)

@classmethod
@logger_decorator("MODIN-ERROR", "ErrorMessage.mismatch_with_pandas", "debug")
def missmatch_with_pandas(cls, operation, message):
get_logger().debug(
f"Modin Warning: {operation} mismatch with pandas: {message}"
)
cls.single_warning(
f"`{operation}` implementation has mismatches with pandas:\n{message}."
)

@classmethod
@logger_decorator("MODIN-ERROR", "ErrorMessage.not_initialized", "debug")
def not_initialized(cls, engine, code):
get_logger().debug(f"Modin Warning: Not Initialized: {engine}")
warnings.warn(
f"{engine} execution environment not yet initialized. Initializing...\n"
+ "To remove this warning, run the following python code before doing dataframe operations:\n"
Expand Down

0 comments on commit 4aefe86

Please sign in to comment.