Spaces:
Running
Running
Pulastya B
commited on
Commit
·
e237c76
1
Parent(s):
50a857f
fix: Add NumPy 2.x compatibility handling for Sweetviz
Browse files- Add deprecation warning suppression to reduce noise
- Detect NumPy 2.x AttributeError and provide clear guidance
- Suggest YData Profiling as a fully compatible alternative
- Include solution steps for downgrading NumPy if needed
- Improve error messages with actionable workarounds
- src/tools/eda_reports.py +21 -3
src/tools/eda_reports.py
CHANGED
|
@@ -35,9 +35,14 @@ def generate_sweetviz_report(
|
|
| 35 |
Dict with success status, report path, and summary
|
| 36 |
"""
|
| 37 |
try:
|
| 38 |
-
import
|
| 39 |
import pandas as pd
|
| 40 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
# Read dataset (Sweetviz requires pandas)
|
| 42 |
if file_path.endswith('.csv'):
|
| 43 |
df = pd.read_csv(file_path)
|
|
@@ -103,13 +108,26 @@ def generate_sweetviz_report(
|
|
| 103 |
return {
|
| 104 |
"success": False,
|
| 105 |
"error": "Sweetviz not installed. Install with: pip install sweetviz",
|
| 106 |
-
"error_type": "MissingDependency"
|
|
|
|
| 107 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
except Exception as e:
|
| 109 |
return {
|
| 110 |
"success": False,
|
| 111 |
"error": f"Failed to generate Sweetviz report: {str(e)}",
|
| 112 |
-
"error_type": type(e).__name__
|
|
|
|
| 113 |
}
|
| 114 |
|
| 115 |
|
|
|
|
| 35 |
Dict with success status, report path, and summary
|
| 36 |
"""
|
| 37 |
try:
|
| 38 |
+
import warnings
|
| 39 |
import pandas as pd
|
| 40 |
|
| 41 |
+
# Suppress NumPy deprecation warnings that Sweetviz triggers
|
| 42 |
+
warnings.filterwarnings('ignore', category=DeprecationWarning)
|
| 43 |
+
|
| 44 |
+
import sweetviz as sv
|
| 45 |
+
|
| 46 |
# Read dataset (Sweetviz requires pandas)
|
| 47 |
if file_path.endswith('.csv'):
|
| 48 |
df = pd.read_csv(file_path)
|
|
|
|
| 108 |
return {
|
| 109 |
"success": False,
|
| 110 |
"error": "Sweetviz not installed. Install with: pip install sweetviz",
|
| 111 |
+
"error_type": "MissingDependency",
|
| 112 |
+
"workaround": "Use generate_ydata_profiling_report as an alternative for comprehensive EDA reports."
|
| 113 |
}
|
| 114 |
+
except AttributeError as e:
|
| 115 |
+
if "VisibleDeprecationWarning" in str(e) or "numpy" in str(e).lower():
|
| 116 |
+
return {
|
| 117 |
+
"success": False,
|
| 118 |
+
"error": "Sweetviz is incompatible with NumPy 2.x. NumPy version downgrade required.",
|
| 119 |
+
"error_type": "DependencyConflict",
|
| 120 |
+
"solution": "Downgrade NumPy to 1.x: py -m pip install 'numpy<2.0'",
|
| 121 |
+
"workaround": "Use generate_ydata_profiling_report instead - it's fully compatible with NumPy 2.x and provides more comprehensive analysis.",
|
| 122 |
+
"alternative_report_path": output_path.replace("sweetviz", "ydata_profile")
|
| 123 |
+
}
|
| 124 |
+
raise
|
| 125 |
except Exception as e:
|
| 126 |
return {
|
| 127 |
"success": False,
|
| 128 |
"error": f"Failed to generate Sweetviz report: {str(e)}",
|
| 129 |
+
"error_type": type(e).__name__,
|
| 130 |
+
"workaround": "Try generate_ydata_profiling_report for a comprehensive EDA report instead."
|
| 131 |
}
|
| 132 |
|
| 133 |
|