Skip to content

Commit

Permalink
Removing path and line number from warnings. (#447)
Browse files Browse the repository at this point in the history
* Removing path and line number from warnings.

* Declutters the warning message so the message is easier to see
* Removes the `warnings.warn(message)` from the message as well.
* Difference between old and new shown below:

Previous:
```
/Users/DevinPetersohn/software_builds/modin/modin/error_message.py:32: UserWarning: `cov` defaulting to pandas implementation.
To request implementation, send an email to feature_requests@modin.org.
  warnings.warn(message)
```

This commit:
```
WARN: `cov` defaulting to pandas implementation.
To request implementation, send an email to feature_requests@modin.org.
```

* Adding warning type to the message instead of "WARN"

* Code reorganization
  • Loading branch information
devin-petersohn committed Feb 6, 2019
1 parent 66bef31 commit 5f72f94
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions modin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@
import warnings


def custom_formatwarning(msg, category, *args, **kwargs):
# ignore everything except the message
return "{}: {}\n".format(category.__name__, msg)


warnings.formatwarning = custom_formatwarning
# Filter numpy version warnings because they are not relevant
warnings.filterwarnings("ignore", message="numpy.dtype size changed")


def get_execution_engine():
# In the future, when there are multiple engines and different ways of
# backing the DataFrame, there will have to be some changed logic here to
Expand All @@ -24,9 +34,6 @@ def get_partition_format():
__execution_engine__ = get_execution_engine()
__partition_format__ = get_partition_format()

# Filter numpy version warnings because they are not relevant
warnings.filterwarnings("ignore", message="numpy.dtype size changed")

# We don't want these used outside of this file.
del get_execution_engine
del get_partition_format

0 comments on commit 5f72f94

Please sign in to comment.