Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- __pycache__/app.cpython-311.pyc +3 -0
- app.py +17 -19
- logs/privacy_audit_detailed.log +6 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
__pycache__/app.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
|
__pycache__/app.cpython-311.pyc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9d2e94e8d6585623c209a4414c0b97fb78ab638af6a3af7c935c5be12a0e5b94
|
| 3 |
+
size 116322
|
app.py
CHANGED
|
@@ -1415,14 +1415,16 @@ An error occurred while generating the executive report:
|
|
| 1415 |
*Please contact support for assistance*
|
| 1416 |
"""
|
| 1417 |
|
| 1418 |
-
def safe_export_results(result: Dict[str, Any]) -> Optional[
|
| 1419 |
"""Safe export with comprehensive error handling"""
|
| 1420 |
try:
|
| 1421 |
logger.info("Generating export package")
|
| 1422 |
|
| 1423 |
-
|
|
|
|
|
|
|
| 1424 |
|
| 1425 |
-
with zipfile.ZipFile(
|
| 1426 |
|
| 1427 |
# Core results (with safe JSON conversion)
|
| 1428 |
try:
|
|
@@ -1547,9 +1549,10 @@ Export completed: {datetime.now().isoformat()}
|
|
| 1547 |
except Exception as e:
|
| 1548 |
logger.warning(f"Failed to add audit log: {e}")
|
| 1549 |
|
| 1550 |
-
|
|
|
|
| 1551 |
logger.info("Export package generated successfully")
|
| 1552 |
-
return
|
| 1553 |
|
| 1554 |
except Exception as e:
|
| 1555 |
logger.error(f"Export generation failed: {e}")
|
|
@@ -1557,13 +1560,13 @@ Export completed: {datetime.now().isoformat()}
|
|
| 1557 |
|
| 1558 |
# Create minimal error export
|
| 1559 |
try:
|
| 1560 |
-
|
| 1561 |
-
|
| 1562 |
-
|
| 1563 |
-
|
| 1564 |
-
|
| 1565 |
-
|
| 1566 |
-
return
|
| 1567 |
except Exception:
|
| 1568 |
return None
|
| 1569 |
|
|
@@ -1701,13 +1704,8 @@ def run_enhanced_audit(real_file, synthetic_file, confidence, subsample_size,
|
|
| 1701 |
except Exception as e:
|
| 1702 |
logger.warning(f"Export generation failed: {e}")
|
| 1703 |
|
| 1704 |
-
#
|
| 1705 |
risk_level = result.get("privacy_assessment", {}).get("risk_level", "UNKNOWN")
|
| 1706 |
-
epsilon = result.get("privacy_assessment", {}).get("primary_epsilon", 0)
|
| 1707 |
-
duration = result.get("audit_metadata", {}).get("duration_seconds", 0)
|
| 1708 |
-
|
| 1709 |
-
success_msg = f"SUCCESS: Audit completed!\nRisk Level: {risk_level}\nε-DP Bound: {epsilon:.6f}\nDuration: {duration:.2f}s"
|
| 1710 |
-
|
| 1711 |
logger.info(f"Audit completed - ID: {result.get('audit_id')}, Risk: {risk_level}")
|
| 1712 |
|
| 1713 |
return result, dist_plot, eps_plot, report, export_data
|
|
@@ -2036,7 +2034,7 @@ Run a privacy audit to generate a comprehensive executive report including:
|
|
| 2036 |
result[1], # distance_plot
|
| 2037 |
result[2], # epsilon_plot
|
| 2038 |
result[3], # audit_report
|
| 2039 |
-
gr.update(value=result[4], visible=export_visible) if
|
| 2040 |
)
|
| 2041 |
|
| 2042 |
except Exception as e:
|
|
|
|
| 1415 |
*Please contact support for assistance*
|
| 1416 |
"""
|
| 1417 |
|
| 1418 |
+
def safe_export_results(result: Dict[str, Any]) -> Optional[str]:
|
| 1419 |
"""Safe export with comprehensive error handling"""
|
| 1420 |
try:
|
| 1421 |
logger.info("Generating export package")
|
| 1422 |
|
| 1423 |
+
# Create temporary file for export
|
| 1424 |
+
import tempfile
|
| 1425 |
+
export_file = tempfile.NamedTemporaryFile(mode='wb', suffix='.zip', delete=False)
|
| 1426 |
|
| 1427 |
+
with zipfile.ZipFile(export_file, 'w', zipfile.ZIP_DEFLATED) as zip_file:
|
| 1428 |
|
| 1429 |
# Core results (with safe JSON conversion)
|
| 1430 |
try:
|
|
|
|
| 1549 |
except Exception as e:
|
| 1550 |
logger.warning(f"Failed to add audit log: {e}")
|
| 1551 |
|
| 1552 |
+
|
| 1553 |
+
export_file.close()
|
| 1554 |
logger.info("Export package generated successfully")
|
| 1555 |
+
return export_file.name
|
| 1556 |
|
| 1557 |
except Exception as e:
|
| 1558 |
logger.error(f"Export generation failed: {e}")
|
|
|
|
| 1560 |
|
| 1561 |
# Create minimal error export
|
| 1562 |
try:
|
| 1563 |
+
import tempfile
|
| 1564 |
+
error_file = tempfile.NamedTemporaryFile(mode='w', suffix='.txt', delete=False)
|
| 1565 |
+
error_file.write(f"Export failed: {str(e)}\n\nTimestamp: {datetime.now().isoformat()}")
|
| 1566 |
+
if result:
|
| 1567 |
+
error_file.write(f"\n\nRaw result: {str(result)}")
|
| 1568 |
+
error_file.close()
|
| 1569 |
+
return error_file.name
|
| 1570 |
except Exception:
|
| 1571 |
return None
|
| 1572 |
|
|
|
|
| 1704 |
except Exception as e:
|
| 1705 |
logger.warning(f"Export generation failed: {e}")
|
| 1706 |
|
| 1707 |
+
# Log success
|
| 1708 |
risk_level = result.get("privacy_assessment", {}).get("risk_level", "UNKNOWN")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1709 |
logger.info(f"Audit completed - ID: {result.get('audit_id')}, Risk: {risk_level}")
|
| 1710 |
|
| 1711 |
return result, dist_plot, eps_plot, report, export_data
|
|
|
|
| 2034 |
result[1], # distance_plot
|
| 2035 |
result[2], # epsilon_plot
|
| 2036 |
result[3], # audit_report
|
| 2037 |
+
gr.update(value=result[4], visible=export_visible) if export_visible else gr.update(visible=False)
|
| 2038 |
)
|
| 2039 |
|
| 2040 |
except Exception as e:
|
logs/privacy_audit_detailed.log
CHANGED
|
@@ -11,3 +11,9 @@
|
|
| 11 |
2025-09-07 02:22:32,173 - httpx - INFO - _send_single_request:1038 - HTTP Request: GET http://localhost:7860/startup-events "HTTP/1.1 200 OK"
|
| 12 |
2025-09-07 02:22:32,185 - httpx - INFO - _send_single_request:1038 - HTTP Request: HEAD http://localhost:7860/ "HTTP/1.1 200 OK"
|
| 13 |
2025-09-07 02:22:32,459 - httpx - INFO - _send_single_request:1038 - HTTP Request: GET https://api.gradio.app/v2/tunnel-request "HTTP/1.1 200 OK"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
2025-09-07 02:22:32,173 - httpx - INFO - _send_single_request:1038 - HTTP Request: GET http://localhost:7860/startup-events "HTTP/1.1 200 OK"
|
| 12 |
2025-09-07 02:22:32,185 - httpx - INFO - _send_single_request:1038 - HTTP Request: HEAD http://localhost:7860/ "HTTP/1.1 200 OK"
|
| 13 |
2025-09-07 02:22:32,459 - httpx - INFO - _send_single_request:1038 - HTTP Request: GET https://api.gradio.app/v2/tunnel-request "HTTP/1.1 200 OK"
|
| 14 |
+
2025-09-07 02:35:12,323 - app - INFO - <module>:72 - ============================================================
|
| 15 |
+
2025-09-07 02:35:12,323 - app - INFO - <module>:73 - Application Startup at 2025-09-07 02:35:12
|
| 16 |
+
2025-09-07 02:35:12,323 - app - INFO - <module>:74 - ============================================================
|
| 17 |
+
2025-09-07 02:35:12,324 - app - INFO - __init__:285 - Initialized Privacy Auditor - Session: 7f2e35dc
|
| 18 |
+
2025-09-07 02:35:12,324 - app - INFO - __init__:286 - Configuration: {'confidence_level': 0.95, 'subsample_size': None, 'categorical_encoding': 'onehot', 'numerical_scaling': 'standard', 'distance_metric': 'euclidean', 'enable_preprocessing_report': True, 'max_file_size_mb': 500, 'timeout_seconds': 300, 'enable_data_validation': True, 'chunk_size': 10000, 'max_categories_onehot': 50}
|
| 19 |
+
2025-09-07 02:35:12,324 - app - INFO - <module>:1014 - Privacy auditor initialized successfully
|