Spaces:
Sleeping
Sleeping
gauravlochab
commited on
Commit
·
785d2a0
1
Parent(s):
f4fef41
removed logging
Browse files
app.py
CHANGED
|
@@ -598,10 +598,7 @@ def fetch_apr_data_from_db():
|
|
| 598 |
logger.info("All values are APR type (excluding zero and -100 values)")
|
| 599 |
logger.info(f"Agents count: {global_df['agent_name'].value_counts().to_dict()}")
|
| 600 |
|
| 601 |
-
#
|
| 602 |
-
logger.debug("Final DataFrame contents:")
|
| 603 |
-
for idx, row in global_df.iterrows():
|
| 604 |
-
logger.debug(f"Row {idx}: {row.to_dict()}")
|
| 605 |
|
| 606 |
# Add this at the end, right before returning
|
| 607 |
logger.info("Analyzing adjusted_apr data availability...")
|
|
@@ -1113,10 +1110,7 @@ def create_combined_roi_time_series_graph(df):
|
|
| 1113 |
logger.info(f"ROI Graph data - unique agents: {df['agent_name'].unique().tolist()}")
|
| 1114 |
logger.info(f"ROI Graph data - min ROI: {df['roi'].min()}, max ROI: {df['roi'].max()}")
|
| 1115 |
|
| 1116 |
-
#
|
| 1117 |
-
debug_csv = "debug_roi_data.csv"
|
| 1118 |
-
df.to_csv(debug_csv)
|
| 1119 |
-
logger.info(f"Exported ROI graph data to {debug_csv} for debugging")
|
| 1120 |
|
| 1121 |
# Create Plotly figure in a clean state
|
| 1122 |
fig = go.Figure()
|
|
@@ -1628,14 +1622,9 @@ def create_time_series_graph_per_agent(df):
|
|
| 1628 |
return fig
|
| 1629 |
|
| 1630 |
def write_debug_info(df, fig):
|
| 1631 |
-
"""
|
| 1632 |
-
|
| 1633 |
-
|
| 1634 |
-
logger.debug(f"Graph created with {len(df)} data points and {len(fig.data)} traces")
|
| 1635 |
-
return True
|
| 1636 |
-
except Exception as e:
|
| 1637 |
-
logger.error(f"Error writing debug info: {e}")
|
| 1638 |
-
return False
|
| 1639 |
|
| 1640 |
def create_combined_time_series_graph(df):
|
| 1641 |
"""Create a time series graph showing average APR values across all agents"""
|
|
@@ -1666,39 +1655,8 @@ def create_combined_time_series_graph(df):
|
|
| 1666 |
logger.info("Graph data - all positive APR values only")
|
| 1667 |
logger.info(f"Graph data - min APR: {df['apr'].min()}, max APR: {df['apr'].max()}")
|
| 1668 |
|
| 1669 |
-
#
|
| 1670 |
-
|
| 1671 |
-
df.to_csv(debug_csv)
|
| 1672 |
-
logger.info(f"Exported graph data to {debug_csv} for debugging")
|
| 1673 |
-
|
| 1674 |
-
# Write detailed data report
|
| 1675 |
-
with open("debug_graph_data_report.txt", "w") as f:
|
| 1676 |
-
f.write("==== GRAPH DATA REPORT ====\n\n")
|
| 1677 |
-
f.write(f"Total data points: {len(df)}\n")
|
| 1678 |
-
f.write(f"Timestamp range: {df['timestamp'].min()} to {df['timestamp'].max()}\n\n")
|
| 1679 |
-
|
| 1680 |
-
# Output per-agent details
|
| 1681 |
-
unique_agents = df['agent_id'].unique()
|
| 1682 |
-
f.write(f"Number of agents: {len(unique_agents)}\n\n")
|
| 1683 |
-
|
| 1684 |
-
for agent_id in unique_agents:
|
| 1685 |
-
agent_data = df[df['agent_id'] == agent_id]
|
| 1686 |
-
agent_name = agent_data['agent_name'].iloc[0]
|
| 1687 |
-
|
| 1688 |
-
f.write(f"== Agent: {agent_name} (ID: {agent_id}) ==\n")
|
| 1689 |
-
f.write(f" Total data points: {len(agent_data)}\n")
|
| 1690 |
-
|
| 1691 |
-
apr_data = agent_data[agent_data['metric_type'] == 'APR']
|
| 1692 |
-
|
| 1693 |
-
f.write(f" APR data points: {len(apr_data)}\n")
|
| 1694 |
-
|
| 1695 |
-
if not apr_data.empty:
|
| 1696 |
-
f.write(f" APR values: {apr_data['apr'].tolist()}\n")
|
| 1697 |
-
f.write(f" APR timestamps: {[ts.strftime('%Y-%m-%d %H:%M:%S') if ts is not None else 'None' for ts in apr_data['timestamp']]}\n")
|
| 1698 |
-
|
| 1699 |
-
f.write("\n")
|
| 1700 |
-
|
| 1701 |
-
logger.info("Generated detailed graph data report")
|
| 1702 |
|
| 1703 |
# ENSURE THERE ARE NO CONFLICTING AXES OR TRACES
|
| 1704 |
# Create Plotly figure in a clean state
|
|
|
|
| 598 |
logger.info("All values are APR type (excluding zero and -100 values)")
|
| 599 |
logger.info(f"Agents count: {global_df['agent_name'].value_counts().to_dict()}")
|
| 600 |
|
| 601 |
+
# Debug logging disabled for HF Spaces to prevent Content-Length issues
|
|
|
|
|
|
|
|
|
|
| 602 |
|
| 603 |
# Add this at the end, right before returning
|
| 604 |
logger.info("Analyzing adjusted_apr data availability...")
|
|
|
|
| 1110 |
logger.info(f"ROI Graph data - unique agents: {df['agent_name'].unique().tolist()}")
|
| 1111 |
logger.info(f"ROI Graph data - min ROI: {df['roi'].min()}, max ROI: {df['roi'].max()}")
|
| 1112 |
|
| 1113 |
+
# Debug CSV export disabled for HF Spaces to prevent Content-Length issues
|
|
|
|
|
|
|
|
|
|
| 1114 |
|
| 1115 |
# Create Plotly figure in a clean state
|
| 1116 |
fig = go.Figure()
|
|
|
|
| 1622 |
return fig
|
| 1623 |
|
| 1624 |
def write_debug_info(df, fig):
|
| 1625 |
+
"""Disabled debug info function to prevent Content-Length issues"""
|
| 1626 |
+
# Completely disable debug file generation for HF Spaces
|
| 1627 |
+
return True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1628 |
|
| 1629 |
def create_combined_time_series_graph(df):
|
| 1630 |
"""Create a time series graph showing average APR values across all agents"""
|
|
|
|
| 1655 |
logger.info("Graph data - all positive APR values only")
|
| 1656 |
logger.info(f"Graph data - min APR: {df['apr'].min()}, max APR: {df['apr'].max()}")
|
| 1657 |
|
| 1658 |
+
# Debug file generation disabled for HF Spaces to prevent Content-Length issues
|
| 1659 |
+
logger.debug(f"Graph data processed: {len(df)} records")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1660 |
|
| 1661 |
# ENSURE THERE ARE NO CONFLICTING AXES OR TRACES
|
| 1662 |
# Create Plotly figure in a clean state
|