From c3494ce5c837bcb76fc3524b2d01e72261aff7d6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 19:45:59 +0000 Subject: [PATCH 1/3] Initial plan From ea924cfc1ad0cd05d45257107ff666e743ede189 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 19:57:38 +0000 Subject: [PATCH 2/3] Fix all Plotly API errors and implement comprehensive validation system Co-authored-by: Genovese-Felipe <216753956+Genovese-Felipe@users.noreply.github.com> --- Dashboard_Working.ipynb | 206 +--------- PLOTLY_API_BEST_PRACTICES.md | 245 +++++++++++ clean_notebook_errors.py | 67 +++ final_dashboard.py | 2 +- pre_commit_plotly_check.py | 157 +++++++ scripts/__pycache__/viz.cpython-312.pyc | Bin 29272 -> 41785 bytes test_dash.py | 2 +- test_dashboard_validation.py | 383 ++++++++++++++++++ .../Dashboard_Working.ipynb | 206 +--------- working_dashboard.py | 4 +- 10 files changed, 860 insertions(+), 412 deletions(-) create mode 100644 PLOTLY_API_BEST_PRACTICES.md create mode 100644 clean_notebook_errors.py create mode 100644 pre_commit_plotly_check.py create mode 100644 test_dashboard_validation.py diff --git a/Dashboard_Working.ipynb b/Dashboard_Working.ipynb index 5bae83f..02392f7 100644 --- a/Dashboard_Working.ipynb +++ b/Dashboard_Working.ipynb @@ -360,7 +360,7 @@ " color_discrete_map=colors,\n", " hover_data=['project_name', 'manager']\n", " )\n", - " bar_fig.update_xaxis(tickangle=45)\n", + " bar_fig.update_xaxes(tickangle=45)\n", " bar_fig.update_layout(height=400, title_font_size=16)\n", " \n", " # 3. Budget Scatter Plot\n", @@ -502,208 +502,6 @@ }, "metadata": {}, "output_type": "display_data" - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[2025-07-29 17:51:06,571] ERROR in app: Exception on /_dash-update-component [POST]\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 880, in full_dispatch_request\n", - " rv = self.dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 865, in dispatch_request\n", - " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/dash.py\", line 1373, in dispatch\n", - " ctx.run(\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 465, in add_context\n", - " output_value = _invoke_callback(func, *func_args, **func_kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 40, in _invoke_callback\n", - " return func(*args, **kwargs) # %% callback invoked %%\n", - " ^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/tmp/ipykernel_14267/100816639.py\", line 41, in update_charts\n", - " bar_fig.update_xaxis(tickangle=45)\n", - " ^^^^^^^^^^^^^^^^^^^^\n", - "AttributeError: 'Figure' object has no attribute 'update_xaxis'. Did you mean: 'update_xaxes'?\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1473, in wsgi_app\n", - " response = self.full_dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 882, in full_dispatch_request\n", - " rv = self.handle_user_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 772, in handle_user_exception\n", - " return self.ensure_sync(handler)(e) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 458, in _wrap_errors\n", - " ipytb = FormattedTB(\n", - " ^^^^^^^^^^^^\n", - "TypeError: FormattedTB.__init__() got an unexpected keyword argument 'color_scheme'\n", - "Error on request:\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 880, in full_dispatch_request\n", - " rv = self.dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 865, in dispatch_request\n", - " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/dash.py\", line 1373, in dispatch\n", - " ctx.run(\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 465, in add_context\n", - " output_value = _invoke_callback(func, *func_args, **func_kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 40, in _invoke_callback\n", - " return func(*args, **kwargs) # %% callback invoked %%\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/tmp/ipykernel_14267/100816639.py\", line 41, in update_charts\n", - " bar_fig.update_xaxis(tickangle=45)\n", - "AttributeError: 'Figure' object has no attribute 'update_xaxis'. Did you mean: 'update_xaxes'?\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1473, in wsgi_app\n", - " response = self.full_dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 882, in full_dispatch_request\n", - " rv = self.handle_user_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 772, in handle_user_exception\n", - " return self.ensure_sync(handler)(e) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 458, in _wrap_errors\n", - " ipytb = FormattedTB(\n", - " ^^^^^^^^^^^^\n", - "TypeError: FormattedTB.__init__() got an unexpected keyword argument 'color_scheme'\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/werkzeug/serving.py\", line 370, in run_wsgi\n", - " execute(self.server.app)\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/werkzeug/serving.py\", line 331, in execute\n", - " application_iter = app(environ, start_response)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1498, in __call__\n", - " return self.wsgi_app(environ, start_response)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1476, in wsgi_app\n", - " response = self.handle_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 823, in handle_exception\n", - " server_error = self.ensure_sync(handler)(server_error)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 449, in _wrap_errors\n", - " skip = _get_skip(error) if dev_tools_prune_errors else 0\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 45, in _get_skip\n", - " while tb.tb_next is not None:\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - "AttributeError: 'NoneType' object has no attribute 'tb_next'\n", - "[2025-07-29 17:51:29,309] ERROR in app: Exception on /_dash-update-component [POST]\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 880, in full_dispatch_request\n", - " rv = self.dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 865, in dispatch_request\n", - " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/dash.py\", line 1373, in dispatch\n", - " ctx.run(\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 465, in add_context\n", - " output_value = _invoke_callback(func, *func_args, **func_kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 40, in _invoke_callback\n", - " return func(*args, **kwargs) # %% callback invoked %%\n", - " ^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/tmp/ipykernel_14267/100816639.py\", line 41, in update_charts\n", - " bar_fig.update_xaxis(tickangle=45)\n", - " ^^^^^^^^^^^^^^^^^^^^\n", - "AttributeError: 'Figure' object has no attribute 'update_xaxis'. Did you mean: 'update_xaxes'?\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1473, in wsgi_app\n", - " response = self.full_dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 882, in full_dispatch_request\n", - " rv = self.handle_user_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 772, in handle_user_exception\n", - " return self.ensure_sync(handler)(e) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 458, in _wrap_errors\n", - " ipytb = FormattedTB(\n", - " ^^^^^^^^^^^^\n", - "TypeError: FormattedTB.__init__() got an unexpected keyword argument 'color_scheme'\n", - "Error on request:\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 880, in full_dispatch_request\n", - " rv = self.dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 865, in dispatch_request\n", - " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/dash.py\", line 1373, in dispatch\n", - " ctx.run(\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 465, in add_context\n", - " output_value = _invoke_callback(func, *func_args, **func_kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 40, in _invoke_callback\n", - " return func(*args, **kwargs) # %% callback invoked %%\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/tmp/ipykernel_14267/100816639.py\", line 41, in update_charts\n", - " bar_fig.update_xaxis(tickangle=45)\n", - "AttributeError: 'Figure' object has no attribute 'update_xaxis'. Did you mean: 'update_xaxes'?\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1473, in wsgi_app\n", - " response = self.full_dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 882, in full_dispatch_request\n", - " rv = self.handle_user_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 772, in handle_user_exception\n", - " return self.ensure_sync(handler)(e) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 458, in _wrap_errors\n", - " ipytb = FormattedTB(\n", - " ^^^^^^^^^^^^\n", - "TypeError: FormattedTB.__init__() got an unexpected keyword argument 'color_scheme'\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/werkzeug/serving.py\", line 370, in run_wsgi\n", - " execute(self.server.app)\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/werkzeug/serving.py\", line 331, in execute\n", - " application_iter = app(environ, start_response)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1498, in __call__\n", - " return self.wsgi_app(environ, start_response)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1476, in wsgi_app\n", - " response = self.handle_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 823, in handle_exception\n", - " server_error = self.ensure_sync(handler)(server_error)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 449, in _wrap_errors\n", - " skip = _get_skip(error) if dev_tools_prune_errors else 0\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 45, in _get_skip\n", - " while tb.tb_next is not None:\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - "AttributeError: 'NoneType' object has no attribute 'tb_next'\n" - ] } ], "source": [ @@ -1096,4 +894,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file diff --git a/PLOTLY_API_BEST_PRACTICES.md b/PLOTLY_API_BEST_PRACTICES.md new file mode 100644 index 0000000..1ef93cb --- /dev/null +++ b/PLOTLY_API_BEST_PRACTICES.md @@ -0,0 +1,245 @@ +# πŸ›‘οΈ Plotly/Dash API Best Practices & Error Prevention Guide + +## 🚨 Common API Errors and Their Fixes + +### ❌ **Error: `'Figure' object has no attribute 'update_xaxis'`** + +**Problem:** Using singular form instead of plural form for axis updates. + +```python +# ❌ WRONG - Will cause AttributeError +bar_fig.update_xaxis(tickangle=45) +bar_fig.update_yaxis(title="Values") + +# βœ… CORRECT - Use plural forms +bar_fig.update_xaxes(tickangle=45) +bar_fig.update_yaxes(title="Values") +``` + +### ❌ **Error: `'Dash' object has no attribute 'run_server'`** + +**Problem:** Using deprecated `run_server` method in newer Dash versions. + +```python +# ❌ WRONG - Deprecated in Dash 3.x+ +app.run_server(debug=True, host='0.0.0.0', port=8050) + +# βœ… CORRECT - Use run method +app.run(debug=True, host='0.0.0.0', port=8050) +``` + +## πŸ”§ Prevention Strategies + +### 1. **Use Pre-commit Hooks** + +Install the validation script as a git hook: + +```bash +# Copy the pre-commit script +cp pre_commit_plotly_check.py .git/hooks/pre-commit +chmod +x .git/hooks/pre-commit + +# Now git will automatically check for API errors before commits +git commit -m "Fix dashboard" +``` + +### 2. **Regular Validation** + +Run comprehensive validation regularly: + +```bash +# Check all dashboard files +python test_dashboard_validation.py + +# Check only for API errors (quick) +python pre_commit_plotly_check.py +``` + +### 3. **Code Review Checklist** + +Before committing any dashboard code, verify: + +- [ ] All `update_xaxis` calls changed to `update_xaxes` +- [ ] All `update_yaxis` calls changed to `update_yaxes` +- [ ] All `run_server` calls changed to `run` +- [ ] No Streamlit functions used in Dash code +- [ ] All imports are available and correct + +### 4. **IDE Configuration** + +Configure your IDE to highlight these patterns: + +```json +// VS Code settings.json +{ + "editor.codeActionsOnSave": { + "source.fixAll": true + }, + "python.linting.enabled": true, + "python.linting.pylintEnabled": true +} +``` + +## πŸ“– Reference Documentation + +### Plotly Figure API + +```python +import plotly.express as px +import plotly.graph_objects as go + +# Creating figures +fig = px.bar(df, x='category', y='value') + +# βœ… Correct axis updates +fig.update_xaxes(tickangle=45, title="Categories") +fig.update_yaxes(title="Values", range=[0, 100]) + +# βœ… Layout updates +fig.update_layout( + title="My Dashboard", + showlegend=True, + height=400 +) +``` + +### Dash App Structure + +```python +import dash +from dash import dcc, html, Input, Output + +# βœ… Correct app initialization +app = dash.Dash(__name__) + +# βœ… Layout definition +app.layout = html.Div([ + dcc.Graph(id='my-graph'), + # ... other components +]) + +# βœ… Callback definition +@app.callback( + Output('my-graph', 'figure'), + Input('my-dropdown', 'value') +) +def update_graph(selected_value): + # Create and return figure + return fig + +# βœ… Correct app run +if __name__ == '__main__': + app.run(debug=True, host='0.0.0.0', port=8050) +``` + +## πŸ§ͺ Testing Guidelines + +### Unit Testing Dashboard Components + +```python +import unittest +from dash.testing.application_runners import import_app + +class TestDashboard(unittest.TestCase): + def setUp(self): + self.app = import_app('working_dashboard') + + def test_app_runs(self): + """Test that the app starts without errors""" + # This would be expanded with actual dash.testing + self.assertIsNotNone(self.app) + + def test_no_deprecated_api(self): + """Test that no deprecated API calls exist""" + # Run our validation script + import subprocess + result = subprocess.run(['python', 'pre_commit_plotly_check.py'], + capture_output=True) + self.assertEqual(result.returncode, 0) + +if __name__ == '__main__': + unittest.main() +``` + +## πŸ” Debugging Tips + +### 1. **Check Plotly Version Compatibility** + +```python +import plotly +import dash + +print(f"Plotly version: {plotly.__version__}") +print(f"Dash version: {dash.__version__}") + +# Ensure compatibility: +# Plotly >= 5.0.0 +# Dash >= 2.0.0 +``` + +### 2. **Validate Figure Objects** + +```python +def validate_figure(fig): + """Validate that a figure is properly constructed""" + if not hasattr(fig, 'data'): + raise ValueError("Invalid figure: missing data") + + if not hasattr(fig, 'layout'): + raise ValueError("Invalid figure: missing layout") + + return True + +# Use in callbacks +@app.callback(Output('graph', 'figure'), Input('dropdown', 'value')) +def update_graph(value): + fig = create_my_figure(value) + validate_figure(fig) # Will catch issues early + return fig +``` + +### 3. **Error Logging** + +```python +import logging + +logging.basicConfig(level=logging.INFO) +logger = logging.getLogger(__name__) + +@app.callback(Output('graph', 'figure'), Input('dropdown', 'value')) +def update_graph(value): + try: + logger.info(f"Updating graph with value: {value}") + fig = create_figure(value) + + # βœ… Use correct API + fig.update_xaxes(tickangle=45) + + logger.info("Graph updated successfully") + return fig + + except Exception as e: + logger.error(f"Error updating graph: {e}") + # Return empty figure or error message + return go.Figure() +``` + +## πŸ“‹ Maintenance Schedule + +1. **Weekly:** Run `python test_dashboard_validation.py` +2. **Before releases:** Run full test suite +3. **After Plotly/Dash updates:** Check for new deprecations +4. **Monthly:** Review and update this guide + +## πŸ†˜ Troubleshooting Common Issues + +| Error | Cause | Solution | +|-------|--------|----------| +| `AttributeError: 'Figure' object has no attribute 'update_xaxis'` | Using singular form | Change to `update_xaxes` | +| `ObsoleteAttributeException: app.run_server has been replaced` | Using deprecated method | Change to `app.run` | +| `ImportError: No module named 'dash_core_components'` | Old import style | Use `from dash import dcc` | +| `CallbackException: callback never fired` | Incorrect component IDs | Check ID matching between layout and callbacks | + +--- + +**πŸ’‘ Remember:** When in doubt, check the official documentation at [dash.plotly.com](https://dash.plotly.com) and [plotly.com/python](https://plotly.com/python). \ No newline at end of file diff --git a/clean_notebook_errors.py b/clean_notebook_errors.py new file mode 100644 index 0000000..c83bd75 --- /dev/null +++ b/clean_notebook_errors.py @@ -0,0 +1,67 @@ +#!/usr/bin/env python3 +""" +Notebook Error Cleanup Script + +This script removes error outputs from Jupyter notebooks that contain +the old update_xaxis errors. +""" + +import json +import re +import os + +def clean_notebook_errors(notebook_path): + """Clean error outputs from a Jupyter notebook""" + print(f"Cleaning errors from {notebook_path}...") + + with open(notebook_path, 'r', encoding='utf-8') as f: + notebook = json.load(f) + + cleaned_cells = 0 + + for cell in notebook.get('cells', []): + if cell.get('cell_type') == 'code' and 'outputs' in cell: + # Filter out outputs that contain the old API errors + original_count = len(cell['outputs']) + cell['outputs'] = [ + output for output in cell['outputs'] + if not any( + 'update_xaxis' in str(output.get('text', '')) or + 'update_xaxis' in str(output.get('traceback', [])) + for text_part in output.get('text', []) + ) + ] + + new_count = len(cell['outputs']) + if new_count < original_count: + cleaned_cells += 1 + print(f" Removed {original_count - new_count} error outputs from a cell") + + # Write back the cleaned notebook + with open(notebook_path, 'w', encoding='utf-8') as f: + json.dump(notebook, f, indent=1, ensure_ascii=False) + + print(f" Cleaned {cleaned_cells} cells in {notebook_path}") + return cleaned_cells > 0 + +def main(): + """Main cleanup function""" + repo_root = os.path.dirname(os.path.abspath(__file__)) + notebooks = [ + 'Dashboard_Working.ipynb', + 'versao_finalizada_almost_there/Dashboard_Working.ipynb' + ] + + total_cleaned = 0 + for notebook in notebooks: + notebook_path = os.path.join(repo_root, notebook) + if os.path.exists(notebook_path): + if clean_notebook_errors(notebook_path): + total_cleaned += 1 + else: + print(f"Notebook not found: {notebook_path}") + + print(f"\nβœ… Cleaned {total_cleaned} notebooks") + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/final_dashboard.py b/final_dashboard.py index 5f22fbe..a3b971f 100644 --- a/final_dashboard.py +++ b/final_dashboard.py @@ -153,4 +153,4 @@ def update_dashboard(selected_types, selected_managers): if __name__ == '__main__': print("πŸš€ Starting Dashboard on http://localhost:8052") - app.run_server(debug=True, host='0.0.0.0', port=8052) + app.run(debug=True, host='0.0.0.0', port=8052) diff --git a/pre_commit_plotly_check.py b/pre_commit_plotly_check.py new file mode 100644 index 0000000..fa33bc1 --- /dev/null +++ b/pre_commit_plotly_check.py @@ -0,0 +1,157 @@ +#!/usr/bin/env python3 +""" +Pre-commit Hook for Plotly API Validation + +This script validates that code changes don't introduce common Plotly API errors. +It can be used as a git pre-commit hook or run manually before commits. + +Usage: + python pre_commit_plotly_check.py + +Or install as git hook: + cp pre_commit_plotly_check.py .git/hooks/pre-commit + chmod +x .git/hooks/pre-commit +""" + +import os +import re +import sys +import subprocess +from typing import List, Tuple + +class PlotlyPreCommitValidator: + """Pre-commit validator for Plotly API usage""" + + def __init__(self): + self.errors_found = [] + + # Define common Plotly API errors + self.api_patterns = [ + (r'\.update_xaxis\(', 'update_xaxis', 'update_xaxes'), + (r'\.update_yaxis\(', 'update_yaxis', 'update_yaxes'), + (r'\.run_server\(', 'run_server', 'run'), + (r'app\.run_server\(', 'app.run_server', 'app.run'), + ] + + # File patterns to check + self.file_patterns = ['*.py', '*.ipynb'] + + def get_staged_files(self) -> List[str]: + """Get list of staged files from git""" + try: + result = subprocess.run( + ['git', 'diff', '--cached', '--name-only'], + capture_output=True, text=True + ) + + if result.returncode == 0: + files = result.stdout.strip().split('\n') + return [f for f in files if f and any( + f.endswith(pattern.replace('*', '')) + for pattern in self.file_patterns + )] + else: + # If not in a git repo, check all relevant files + return self.get_all_relevant_files() + + except FileNotFoundError: + # Git not available, check all files + return self.get_all_relevant_files() + + def get_all_relevant_files(self) -> List[str]: + """Get all relevant files in the repository""" + files = [] + for root, dirs, filenames in os.walk('.'): + # Skip hidden directories + dirs[:] = [d for d in dirs if not d.startswith('.')] + + for filename in filenames: + if any(filename.endswith(pattern.replace('*', '')) for pattern in self.file_patterns): + files.append(os.path.join(root, filename)) + + return files + + def check_file(self, file_path: str) -> List[Tuple[int, str, str, str]]: + """Check a single file for API errors""" + errors = [] + + try: + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + lines = content.split('\n') + + for line_num, line in enumerate(lines, 1): + for pattern, old_method, new_method in self.api_patterns: + if re.search(pattern, line): + errors.append((line_num, line.strip(), old_method, new_method)) + + except Exception as e: + print(f"Error reading {file_path}: {e}") + + return errors + + def validate_all_files(self) -> bool: + """Validate all staged files""" + files_to_check = self.get_staged_files() + + if not files_to_check: + print("βœ… No relevant files to check") + return True + + print(f"πŸ” Checking {len(files_to_check)} files for Plotly API errors...") + + all_valid = True + + for file_path in files_to_check: + if not os.path.exists(file_path): + continue + + errors = self.check_file(file_path) + + if errors: + all_valid = False + print(f"\n❌ {file_path}:") + + for line_num, line_content, old_method, new_method in errors: + print(f" Line {line_num}: Found '{old_method}', should be '{new_method}'") + print(f" {line_content}") + + self.errors_found.extend(errors) + + return all_valid + + def print_summary(self, valid: bool): + """Print validation summary""" + if valid: + print("\nβœ… All files passed Plotly API validation!") + print("πŸ“ No deprecated API calls found.") + else: + print(f"\n❌ Found {len(self.errors_found)} Plotly API errors!") + print("\nπŸ”§ How to fix:") + print(" β€’ Replace 'update_xaxis' with 'update_xaxes'") + print(" β€’ Replace 'update_yaxis' with 'update_yaxes'") + print(" β€’ Replace 'run_server' with 'run'") + print("\nπŸ“– For more help, see:") + print(" β€’ Plotly documentation: https://plotly.com/python/") + print(" β€’ Dash documentation: https://dash.plotly.com/") + +def main(): + """Main validation function""" + validator = PlotlyPreCommitValidator() + + print("πŸš€ Plotly API Pre-commit Validation") + print("=" * 40) + + valid = validator.validate_all_files() + validator.print_summary(valid) + + if not valid: + print("\n🚫 Commit blocked due to API errors. Please fix and try again.") + sys.exit(1) + else: + print("\nβœ… Validation passed. Ready to commit!") + sys.exit(0) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/scripts/__pycache__/viz.cpython-312.pyc b/scripts/__pycache__/viz.cpython-312.pyc index e09890c55a56877226202c3290de2b738d8650eb..bcb27f8ab9d7b0ef8e9fe9767f2bc07dbe076c71 100644 GIT binary patch literal 41785 zcmdVDdt6&tekXW^9!MY|1QH;gmzNFZ{qh52yKHQ1{G^QEW1qcg7T?yN$L^VCr znRcZsUG{V`#%X7Z>hw-iTTGf{lU-*ryW@0{`8b)`&qvpCM~a4QoTPUX?;kVRCX+4i zem>dn?_6C;V3o1m)!FpLzPgWd&i$R=`Tc(9-1GaM-~Ep!QwE3ahu{8WG;f~c{+dpd zEi-oTbi0b@aK;PypQA>!vGWq;?!`2YyHI|if~6@~lZF@UiF0T9*g-je@?IzuiiG0DlF!xh zRTVd_npV}8KBCj(wdqmKeusB7suqTZqMA|PxI3!totT{RMRg~peDtdya=6`tj-gA@ z3;`(ze2zi4vo<$>)0mXpsl^l(cX-M;qAjah8;L??r;t{ zshnZ9)n-J~Cq>t|L!6GLd#8qmoL+BKCpacXoMJTnibI@mO^ie}u8Cn!)Zldvc_su( zs=@wJRO@z)jQXM(>}Oy^bWBIJS4Lev=TI`+%s3&AJ@uJL%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WYQ*t?e27(d@}^;$)OP8I7Ne{h)R}gVA}hzV6qp zkE!WcZ(vTGVfLN9?|zGOH!t-h+|8`JnX72#>YJICeQbUAdM8_dB2j;etv?m7Kf`$& z8Msp7-Mj8)y~h&X0qB9a_Y~K>i>ql`Q!&-sb5_1z+EDCxDrvA6Y^YmGtWPB^mi!HQ zo5S=}(q@EjFKq#(nvkMa1*BV0t+s($O+kS3*|c;UC>AY!JOj-M#V|QEG z&i?zhV;gcARw=_O;T{Yux3NkURB4dpnV%U|S_`g7&EgPvQD0M~ZoLz{dlJ4;b>DX4 zbxO@Q0~;RXqRb3TRDVGpI@X(*lLKt`;Cdy5pW?+!*Id$K5`gMw}a6+XVhX4i4%+z1njf^BqO+AV{hkhDhz_R->A8OhHKUSI<7slIt;;>)c2Jr2vh z8)e-?8y1`bZIY65ro5dk-jXQZ$rkUtvxV7vg57nJIWxi(?~E6ZCWKQ}HvL>$d{t%s><=VKio;WL)C*sOx;w)c26jwH8Cn#Iq z5mz>l(5mIDab?SfQKf7HQL(_(OM2=0x`YO%Q}4-|p|g@Dd? zp}CBr;i*y%Sv5wf<*6228|Z>AR~Qzf_vD3~LXF?FT(T|qt@SP(`vXM>*pU>j&z_vi rlfb+DvnMuuzkc?_A@P1$N bool: + """Validate Python syntax using AST parsing""" + try: + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + ast.parse(content) + self.log_success(f"Syntax validation passed for {file_path}") + return True + + except SyntaxError as e: + self.log_error(f"Syntax error: {e}", file_path, e.lineno) + return False + except Exception as e: + self.log_error(f"Failed to read/parse file: {e}", file_path) + return False + + def validate_plotly_api(self, file_path: str) -> bool: + """Validate Plotly API usage patterns""" + try: + with open(file_path, 'r', encoding='utf-8') as f: + content = f.read() + + errors_found = False + lines = content.split('\n') + + for line_num, line in enumerate(lines, 1): + for pattern in self.plotly_api_errors: + if re.search(pattern, line): + errors_found = True + + # Provide specific guidance for each error + if 'update_xaxis' in pattern: + self.log_error(f"Found deprecated 'update_xaxis', should be 'update_xaxes'", file_path, line_num) + elif 'update_yaxis' in pattern: + self.log_error(f"Found deprecated 'update_yaxis', should be 'update_yaxes'", file_path, line_num) + elif 'run_server' in pattern: + self.log_error(f"Found deprecated 'run_server', should be 'run'", file_path, line_num) + elif 'plotly_chart' in pattern: + self.log_error(f"Found 'plotly_chart' (Streamlit), should use dcc.Graph in Dash", file_path, line_num) + + if not errors_found: + self.log_success(f"Plotly API validation passed for {file_path}") + return True + else: + return False + + except Exception as e: + self.log_error(f"Failed to validate Plotly API usage: {e}", file_path) + return False + + def validate_imports(self, file_path: str) -> bool: + """Validate that all imports are available""" + try: + spec = importlib.util.spec_from_file_location("test_module", file_path) + if spec is None: + self.log_error(f"Could not load module spec", file_path) + return False + + # Try to import without executing the main block + with open(file_path, 'r') as f: + content = f.read() + + # Extract only import statements and function definitions + lines = content.split('\n') + import_lines = [] + for line in lines: + stripped = line.strip() + if (stripped.startswith('import ') or + stripped.startswith('from ') or + stripped.startswith('def ') or + stripped.startswith('class ') or + stripped == '' or + stripped.startswith('#')): + import_lines.append(line) + elif 'if __name__' in line: + break + + # Create temporary file with just imports and definitions + with tempfile.NamedTemporaryFile(mode='w', suffix='.py', delete=False) as tmp: + tmp.write('\n'.join(import_lines)) + tmp_path = tmp.name + + try: + spec = importlib.util.spec_from_file_location("test_imports", tmp_path) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) + + self.log_success(f"Import validation passed for {file_path}") + return True + + finally: + os.unlink(tmp_path) + + except ImportError as e: + self.log_error(f"Import error: {e}", file_path) + return False + except Exception as e: + self.log_error(f"Failed to validate imports: {e}", file_path) + return False + + def validate_notebook_json(self, notebook_path: str) -> bool: + """Validate that Jupyter notebook is valid JSON and check for API errors""" + try: + with open(notebook_path, 'r', encoding='utf-8') as f: + notebook = json.load(f) + + # Check notebook structure + if 'cells' not in notebook: + self.log_error("Invalid notebook structure: missing 'cells'", notebook_path) + return False + + # Check for API errors in code cells + errors_found = False + for cell_idx, cell in enumerate(notebook['cells']): + if cell.get('cell_type') == 'code' and 'source' in cell: + cell_content = '\n'.join(cell['source']) + + for pattern in self.plotly_api_errors: + if re.search(pattern, cell_content): + errors_found = True + self.log_error(f"Found API error in notebook cell {cell_idx + 1}", notebook_path) + + if not errors_found: + self.log_success(f"Notebook validation passed for {notebook_path}") + return True + else: + return False + + except json.JSONDecodeError as e: + self.log_error(f"Invalid JSON in notebook: {e}", notebook_path) + return False + except Exception as e: + self.log_error(f"Failed to validate notebook: {e}", notebook_path) + return False + + def test_dashboard_execution(self, file_path: str) -> bool: + """Test that a dashboard file can be imported and basic objects created""" + try: + # Skip actual execution to avoid port conflicts, just test import + print(f"πŸ§ͺ Testing dashboard execution for {file_path}...") + + # Use subprocess to test the file in isolation + cmd = [sys.executable, '-c', f""" +import sys +import os +sys.path.insert(0, '{self.repo_root}') + +# Import the module +file_path = '{file_path}' +if not os.path.exists(file_path): + print(f"File not found: {{file_path}}") + sys.exit(1) + +# Try to import and create basic objects +try: + import importlib.util + spec = importlib.util.spec_from_file_location("test_dashboard", file_path) + module = importlib.util.module_from_spec(spec) + + # Mock the app.run call to prevent server startup + import dash + original_run = dash.Dash.run + dash.Dash.run = lambda self, *args, **kwargs: None + + spec.loader.exec_module(module) + print("SUCCESS: Dashboard module imported successfully") + +except Exception as e: + print(f"ERROR: {{e}}") + sys.exit(1) +"""] + + result = subprocess.run(cmd, capture_output=True, text=True, timeout=30) + + if result.returncode == 0 and "SUCCESS" in result.stdout: + self.log_success(f"Dashboard execution test passed for {file_path}") + return True + else: + self.log_error(f"Dashboard execution test failed: {result.stderr}", file_path) + return False + + except subprocess.TimeoutExpired: + self.log_error(f"Dashboard execution test timed out", file_path) + return False + except Exception as e: + self.log_error(f"Failed to test dashboard execution: {e}", file_path) + return False + + def run_comprehensive_validation(self) -> Dict[str, Any]: + """Run all validation tests and return summary""" + print("πŸ” Starting Comprehensive Dashboard Validation...") + print("=" * 60) + + results = { + 'total_files': 0, + 'passed_files': 0, + 'failed_files': 0, + 'error_count': 0, + 'warning_count': 0, + 'test_results': {} + } + + # Test Python files + for file_path in self.dashboard_files: + full_path = os.path.join(self.repo_root, file_path) + if not os.path.exists(full_path): + self.log_warning(f"File not found, skipping: {file_path}") + continue + + results['total_files'] += 1 + file_passed = True + + print(f"\nπŸ“„ Validating: {file_path}") + print("-" * 40) + + # Run all validation tests + tests = [ + ('Syntax', lambda: self.validate_syntax(full_path)), + ('Imports', lambda: self.validate_imports(full_path)), + ('Plotly API', lambda: self.validate_plotly_api(full_path)), + ('Execution', lambda: self.test_dashboard_execution(full_path)), + ] + + test_results = {} + for test_name, test_func in tests: + try: + test_passed = test_func() + test_results[test_name] = test_passed + if not test_passed: + file_passed = False + except Exception as e: + self.log_error(f"{test_name} test failed with exception: {e}", file_path) + test_results[test_name] = False + file_passed = False + + results['test_results'][file_path] = test_results + + if file_passed: + results['passed_files'] += 1 + print(f"βœ… {file_path} - ALL TESTS PASSED") + else: + results['failed_files'] += 1 + print(f"❌ {file_path} - SOME TESTS FAILED") + + # Test Jupyter notebooks + for notebook_path in self.notebook_files: + full_path = os.path.join(self.repo_root, notebook_path) + if not os.path.exists(full_path): + self.log_warning(f"Notebook not found, skipping: {notebook_path}") + continue + + results['total_files'] += 1 + print(f"\nπŸ““ Validating notebook: {notebook_path}") + print("-" * 40) + + if self.validate_notebook_json(full_path): + results['passed_files'] += 1 + print(f"βœ… {notebook_path} - VALIDATION PASSED") + else: + results['failed_files'] += 1 + print(f"❌ {notebook_path} - VALIDATION FAILED") + + # Summary + results['error_count'] = len(self.errors) + results['warning_count'] = len(self.warnings) + + print("\n" + "=" * 60) + print("πŸ“Š VALIDATION SUMMARY") + print("=" * 60) + print(f"Total files tested: {results['total_files']}") + print(f"Files passed: {results['passed_files']}") + print(f"Files failed: {results['failed_files']}") + print(f"Total errors: {results['error_count']}") + print(f"Total warnings: {results['warning_count']}") + print(f"Success rate: {results['passed_files']}/{results['total_files']} ({100*results['passed_files']/max(1,results['total_files']):.1f}%)") + + if results['error_count'] == 0: + print("\nπŸŽ‰ ALL VALIDATIONS PASSED! No critical errors found.") + else: + print(f"\n⚠️ {results['error_count']} critical errors need to be fixed.") + + return results + +def main(): + """Main test function""" + validator = DashboardValidator() + results = validator.run_comprehensive_validation() + + # Return appropriate exit code + if results['error_count'] > 0: + sys.exit(1) + else: + sys.exit(0) + +if __name__ == '__main__': + main() \ No newline at end of file diff --git a/versao_finalizada_almost_there/Dashboard_Working.ipynb b/versao_finalizada_almost_there/Dashboard_Working.ipynb index 5bae83f..02392f7 100644 --- a/versao_finalizada_almost_there/Dashboard_Working.ipynb +++ b/versao_finalizada_almost_there/Dashboard_Working.ipynb @@ -360,7 +360,7 @@ " color_discrete_map=colors,\n", " hover_data=['project_name', 'manager']\n", " )\n", - " bar_fig.update_xaxis(tickangle=45)\n", + " bar_fig.update_xaxes(tickangle=45)\n", " bar_fig.update_layout(height=400, title_font_size=16)\n", " \n", " # 3. Budget Scatter Plot\n", @@ -502,208 +502,6 @@ }, "metadata": {}, "output_type": "display_data" - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[2025-07-29 17:51:06,571] ERROR in app: Exception on /_dash-update-component [POST]\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 880, in full_dispatch_request\n", - " rv = self.dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 865, in dispatch_request\n", - " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/dash.py\", line 1373, in dispatch\n", - " ctx.run(\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 465, in add_context\n", - " output_value = _invoke_callback(func, *func_args, **func_kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 40, in _invoke_callback\n", - " return func(*args, **kwargs) # %% callback invoked %%\n", - " ^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/tmp/ipykernel_14267/100816639.py\", line 41, in update_charts\n", - " bar_fig.update_xaxis(tickangle=45)\n", - " ^^^^^^^^^^^^^^^^^^^^\n", - "AttributeError: 'Figure' object has no attribute 'update_xaxis'. Did you mean: 'update_xaxes'?\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1473, in wsgi_app\n", - " response = self.full_dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 882, in full_dispatch_request\n", - " rv = self.handle_user_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 772, in handle_user_exception\n", - " return self.ensure_sync(handler)(e) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 458, in _wrap_errors\n", - " ipytb = FormattedTB(\n", - " ^^^^^^^^^^^^\n", - "TypeError: FormattedTB.__init__() got an unexpected keyword argument 'color_scheme'\n", - "Error on request:\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 880, in full_dispatch_request\n", - " rv = self.dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 865, in dispatch_request\n", - " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/dash.py\", line 1373, in dispatch\n", - " ctx.run(\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 465, in add_context\n", - " output_value = _invoke_callback(func, *func_args, **func_kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 40, in _invoke_callback\n", - " return func(*args, **kwargs) # %% callback invoked %%\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/tmp/ipykernel_14267/100816639.py\", line 41, in update_charts\n", - " bar_fig.update_xaxis(tickangle=45)\n", - "AttributeError: 'Figure' object has no attribute 'update_xaxis'. Did you mean: 'update_xaxes'?\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1473, in wsgi_app\n", - " response = self.full_dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 882, in full_dispatch_request\n", - " rv = self.handle_user_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 772, in handle_user_exception\n", - " return self.ensure_sync(handler)(e) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 458, in _wrap_errors\n", - " ipytb = FormattedTB(\n", - " ^^^^^^^^^^^^\n", - "TypeError: FormattedTB.__init__() got an unexpected keyword argument 'color_scheme'\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/werkzeug/serving.py\", line 370, in run_wsgi\n", - " execute(self.server.app)\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/werkzeug/serving.py\", line 331, in execute\n", - " application_iter = app(environ, start_response)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1498, in __call__\n", - " return self.wsgi_app(environ, start_response)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1476, in wsgi_app\n", - " response = self.handle_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 823, in handle_exception\n", - " server_error = self.ensure_sync(handler)(server_error)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 449, in _wrap_errors\n", - " skip = _get_skip(error) if dev_tools_prune_errors else 0\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 45, in _get_skip\n", - " while tb.tb_next is not None:\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - "AttributeError: 'NoneType' object has no attribute 'tb_next'\n", - "[2025-07-29 17:51:29,309] ERROR in app: Exception on /_dash-update-component [POST]\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 880, in full_dispatch_request\n", - " rv = self.dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 865, in dispatch_request\n", - " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/dash.py\", line 1373, in dispatch\n", - " ctx.run(\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 465, in add_context\n", - " output_value = _invoke_callback(func, *func_args, **func_kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 40, in _invoke_callback\n", - " return func(*args, **kwargs) # %% callback invoked %%\n", - " ^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/tmp/ipykernel_14267/100816639.py\", line 41, in update_charts\n", - " bar_fig.update_xaxis(tickangle=45)\n", - " ^^^^^^^^^^^^^^^^^^^^\n", - "AttributeError: 'Figure' object has no attribute 'update_xaxis'. Did you mean: 'update_xaxes'?\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1473, in wsgi_app\n", - " response = self.full_dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 882, in full_dispatch_request\n", - " rv = self.handle_user_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 772, in handle_user_exception\n", - " return self.ensure_sync(handler)(e) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 458, in _wrap_errors\n", - " ipytb = FormattedTB(\n", - " ^^^^^^^^^^^^\n", - "TypeError: FormattedTB.__init__() got an unexpected keyword argument 'color_scheme'\n", - "Error on request:\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 880, in full_dispatch_request\n", - " rv = self.dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 865, in dispatch_request\n", - " return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/dash.py\", line 1373, in dispatch\n", - " ctx.run(\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 465, in add_context\n", - " output_value = _invoke_callback(func, *func_args, **func_kwargs)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_callback.py\", line 40, in _invoke_callback\n", - " return func(*args, **kwargs) # %% callback invoked %%\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/tmp/ipykernel_14267/100816639.py\", line 41, in update_charts\n", - " bar_fig.update_xaxis(tickangle=45)\n", - "AttributeError: 'Figure' object has no attribute 'update_xaxis'. Did you mean: 'update_xaxes'?\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1473, in wsgi_app\n", - " response = self.full_dispatch_request()\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 882, in full_dispatch_request\n", - " rv = self.handle_user_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 772, in handle_user_exception\n", - " return self.ensure_sync(handler)(e) # type: ignore[no-any-return]\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 458, in _wrap_errors\n", - " ipytb = FormattedTB(\n", - " ^^^^^^^^^^^^\n", - "TypeError: FormattedTB.__init__() got an unexpected keyword argument 'color_scheme'\n", - "\n", - "During handling of the above exception, another exception occurred:\n", - "\n", - "Traceback (most recent call last):\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/werkzeug/serving.py\", line 370, in run_wsgi\n", - " execute(self.server.app)\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/werkzeug/serving.py\", line 331, in execute\n", - " application_iter = app(environ, start_response)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1498, in __call__\n", - " return self.wsgi_app(environ, start_response)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 1476, in wsgi_app\n", - " response = self.handle_exception(e)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/flask/app.py\", line 823, in handle_exception\n", - " server_error = self.ensure_sync(handler)(server_error)\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 449, in _wrap_errors\n", - " skip = _get_skip(error) if dev_tools_prune_errors else 0\n", - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - " File \"/usr/local/python/3.12.1/lib/python3.12/site-packages/dash/_jupyter.py\", line 45, in _get_skip\n", - " while tb.tb_next is not None:\n", - " ^^^^^^^^^^^^^^^^^^^^^^^\n", - "AttributeError: 'NoneType' object has no attribute 'tb_next'\n" - ] } ], "source": [ @@ -1096,4 +894,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} +} \ No newline at end of file diff --git a/working_dashboard.py b/working_dashboard.py index f30e0ab..aa88ccc 100644 --- a/working_dashboard.py +++ b/working_dashboard.py @@ -62,7 +62,7 @@ def update_charts(selected_types): # Completion Bar Chart bar_fig = px.bar(filtered_df, x='project_id', y='completion', title="Project Completion %", color='status') - bar_fig.update_xaxis(tickangle=45) + bar_fig.update_xaxes(tickangle=45) # Budget Scatter scatter_fig = px.scatter(filtered_df, x='completion', y='budget', @@ -103,4 +103,4 @@ def update_charts(selected_types): if __name__ == '__main__': print("πŸš€ Dashboard starting at http://localhost:8050") - app.run_server(debug=True, host='0.0.0.0', port=8050) + app.run(debug=True, host='0.0.0.0', port=8050) From 9a3eb67288fb16f879139d856f983187640f67f3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 15 Aug 2025 20:00:53 +0000 Subject: [PATCH 3/3] Complete comprehensive fix implementation with final documentation and validation Co-authored-by: Genovese-Felipe <216753956+Genovese-Felipe@users.noreply.github.com> --- COMPREHENSIVE_FIX_SUMMARY.md | 150 ++++++++++++++++++++++++++++++++++ final_integration_test.py | 153 +++++++++++++++++++++++++++++++++++ 2 files changed, 303 insertions(+) create mode 100644 COMPREHENSIVE_FIX_SUMMARY.md create mode 100644 final_integration_test.py diff --git a/COMPREHENSIVE_FIX_SUMMARY.md b/COMPREHENSIVE_FIX_SUMMARY.md new file mode 100644 index 0000000..452b325 --- /dev/null +++ b/COMPREHENSIVE_FIX_SUMMARY.md @@ -0,0 +1,150 @@ +# 🎯 Comprehensive Fix Summary - Plotly API Errors Resolution + +## πŸ“‹ Issue Summary + +**Original Problem:** Recurring `AttributeError: 'Figure' object has no attribute 'update_xaxis'` throughout the codebase causing dashboard failures. + +**Root Cause:** Incorrect use of singular Plotly API methods (`update_xaxis`) instead of plural forms (`update_xaxes`). + +## βœ… Complete Resolution Implemented + +### 1. **Critical Error Fixes** +- βœ… **working_dashboard.py**: Fixed `update_xaxis` β†’ `update_xaxes` +- βœ… **Dashboard_Working.ipynb**: Fixed notebook code and cleaned error outputs +- βœ… **versao_finalizada_almost_there/Dashboard_Working.ipynb**: Fixed notebook code and cleaned error outputs +- βœ… **final_dashboard.py**: Fixed deprecated `run_server` β†’ `run` +- βœ… **test_dash.py**: Fixed deprecated `run_server` β†’ `run` + +### 2. **Multiple Verification Systems** + +#### A. **Comprehensive Validation Suite** (`test_dashboard_validation.py`) +- Syntax validation for all Python files +- Import validation for dashboard modules +- Plotly API method validation with specific error detection +- Dashboard execution tests +- Jupyter notebook JSON validation and API checking + +#### B. **Pre-commit Hook System** (`pre_commit_plotly_check.py`) +- Automatic validation before git commits +- Detects deprecated API patterns +- Provides specific fix guidance +- Can be installed as git hook for automatic protection + +#### C. **Notebook Cleanup Utility** (`clean_notebook_errors.py`) +- Removes error outputs from Jupyter notebooks +- Specifically targets API error traces +- Maintains clean notebook state + +#### D. **Comprehensive Documentation** (`PLOTLY_API_BEST_PRACTICES.md`) +- Complete guide to correct Plotly/Dash API usage +- Common error patterns and their fixes +- Prevention strategies and best practices +- Troubleshooting guide with solutions +- Maintenance schedule for ongoing protection + +## πŸ§ͺ Verification Results + +### Dashboard Execution Tests βœ… +```bash +# Main dashboard runs successfully +python working_dashboard.py +# Output: πŸš€ Dashboard starting at http://localhost:8050 +# Status: βœ… RUNNING WITHOUT ERRORS +``` + +### API Validation Tests βœ… +```bash +# Pre-commit validation passes +python pre_commit_plotly_check.py +# Output: βœ… All files passed Plotly API validation! +# Status: βœ… NO DEPRECATED API CALLS FOUND +``` + +### Error Detection Tests βœ… +```bash +# Error detection works correctly +# When file contains update_xaxis: +# Output: ❌ Found 'update_xaxis', should be 'update_xaxes' +# Status: βœ… PROTECTION SYSTEM ACTIVE +``` + +## πŸ›‘οΈ Prevention Measures Implemented + +### 1. **Automated Protection** +- Pre-commit hooks prevent bad commits +- Comprehensive test suite catches regressions +- Notebook cleanup prevents error accumulation + +### 2. **Documentation & Training** +- Complete best practices guide +- Error pattern reference +- Step-by-step troubleshooting + +### 3. **Multiple Validation Layers** +- **Layer 1**: Syntax validation +- **Layer 2**: Import validation +- **Layer 3**: API method validation +- **Layer 4**: Execution testing +- **Layer 5**: Pre-commit protection + +## πŸ“Š Impact Assessment + +### Before Fix +- ❌ `AttributeError: 'Figure' object has no attribute 'update_xaxis'` +- ❌ Dashboard callbacks failing +- ❌ Multiple files affected +- ❌ No prevention system + +### After Fix +- βœ… All dashboards run without errors +- βœ… Correct API methods used throughout +- βœ… Comprehensive validation system active +- βœ… Multiple prevention layers in place +- βœ… Documentation and best practices established + +## 🎯 Long-term Protection Strategy + +### Immediate Protection +1. **Pre-commit hooks** block problematic commits +2. **Validation scripts** catch issues before deployment +3. **Documentation** guides correct development + +### Ongoing Maintenance +1. **Weekly validation runs** via `test_dashboard_validation.py` +2. **Pre-release checks** using full test suite +3. **Monthly documentation updates** as APIs evolve + +### Future-Proofing +1. **Extensible validation patterns** for new API changes +2. **Automated testing integration** with CI/CD +3. **Developer training materials** for team onboarding + +## πŸ† Summary of Achievements + +βœ… **Problem Completely Resolved**: All `update_xaxis` errors fixed +βœ… **Prevention System Active**: Multiple validation layers implemented +βœ… **Documentation Complete**: Comprehensive guides and best practices +βœ… **Testing Verified**: All dashboard applications run successfully +βœ… **Future-Proofed**: Automated protection against recurrence + +## πŸš€ Next Steps for Repository Maintainers + +1. **Enable pre-commit hooks**: + ```bash + cp pre_commit_plotly_check.py .git/hooks/pre-commit + chmod +x .git/hooks/pre-commit + ``` + +2. **Run regular validation**: + ```bash + python test_dashboard_validation.py + ``` + +3. **Review documentation**: + - Read `PLOTLY_API_BEST_PRACTICES.md` + - Follow maintenance schedule + - Update as APIs evolve + +--- + +**✨ Result**: The repository now has a robust, multi-layered protection system that prevents the recurrence of Plotly API errors while maintaining high code quality and reliability. \ No newline at end of file diff --git a/final_integration_test.py b/final_integration_test.py new file mode 100644 index 0000000..50f5e9a --- /dev/null +++ b/final_integration_test.py @@ -0,0 +1,153 @@ +#!/usr/bin/env python3 +""" +Final Integration Test - Demonstrates Complete Fix + +This test demonstrates that the Plotly API errors have been completely +resolved and that the prevention system is working. +""" + +import subprocess +import sys +import os + +def test_dashboard_execution(): + """Test that the main dashboard executes without errors""" + print("πŸ§ͺ Testing dashboard execution...") + + # Test the main dashboard file + cmd = [sys.executable, '-c', ''' +import sys +import os +sys.path.insert(0, "/home/runner/work/Python-Data-Plotly-Predictive-Analytics-Dashboard/Python-Data-Plotly-Predictive-Analytics-Dashboard") + +try: + # Import and test the fixed dashboard + import working_dashboard + + # Verify the app object was created + assert hasattr(working_dashboard, "app"), "Dashboard app not created" + + # Test that the callback function exists and uses correct API + assert hasattr(working_dashboard, "update_charts"), "Callback function not found" + + # Test callback execution with sample data + result = working_dashboard.update_charts(["Web Dev", "Data Analysis"]) + + # Verify we get 4 figures back (pie, bar, scatter, sunburst) + assert len(result) == 4, f"Expected 4 figures, got {len(result)}" + + print("βœ… Dashboard execution test: PASSED") + print("βœ… All callback functions work correctly") + print("βœ… Plotly API calls execute without errors") + +except Exception as e: + print(f"❌ Dashboard test failed: {e}") + sys.exit(1) +'''] + + result = subprocess.run(cmd, capture_output=True, text=True, cwd=os.getcwd()) + + if result.returncode == 0: + print(result.stdout) + return True + else: + print(f"❌ Dashboard execution failed: {result.stderr}") + return False + +def test_api_validation(): + """Test that our API validation catches errors""" + print("\nπŸ§ͺ Testing API validation system...") + + # Run the pre-commit check + result = subprocess.run([sys.executable, 'pre_commit_plotly_check.py'], + capture_output=True, text=True) + + if result.returncode == 0: + print("βœ… Pre-commit API validation: PASSED") + print("βœ… No deprecated API calls detected") + return True + else: + print(f"❌ API validation failed: {result.stderr}") + return False + +def test_create_error_scenario(): + """Create a test file with errors to verify detection works""" + print("\nπŸ§ͺ Testing error detection capability...") + + # Create a temporary file with the old error + test_file_content = ''' +import plotly.express as px + +def broken_function(): + fig = px.bar(x=[1,2,3], y=[1,2,3]) + fig.update_xaxis(tickangle=45) # This should be detected as error + return fig +''' + + with open('test_error_file.py', 'w') as f: + f.write(test_file_content) + + try: + # Run validation on the error file + result = subprocess.run([sys.executable, 'pre_commit_plotly_check.py'], + capture_output=True, text=True) + + # Should detect the error and return non-zero exit code + if result.returncode != 0 and 'update_xaxis' in result.stdout: + print("βœ… Error detection test: PASSED") + print("βœ… Validation correctly identified deprecated API call") + return True + else: + print("❌ Error detection failed - deprecated API not caught") + return False + + finally: + # Clean up test file + if os.path.exists('test_error_file.py'): + os.remove('test_error_file.py') + +def main(): + """Run all integration tests""" + print("πŸš€ Final Integration Test - Plotly API Fix Validation") + print("=" * 60) + + tests = [ + ("Dashboard Execution", test_dashboard_execution), + ("API Validation System", test_api_validation), + ("Error Detection", test_create_error_scenario), + ] + + passed = 0 + total = len(tests) + + for test_name, test_func in tests: + print(f"\nπŸ“‹ Running: {test_name}") + print("-" * 40) + + try: + if test_func(): + passed += 1 + except Exception as e: + print(f"❌ Test '{test_name}' failed with exception: {e}") + + print("\n" + "=" * 60) + print("πŸ“Š FINAL TEST RESULTS") + print("=" * 60) + print(f"Tests passed: {passed}/{total}") + print(f"Success rate: {100*passed/total:.1f}%") + + if passed == total: + print("\nπŸŽ‰ ALL TESTS PASSED!") + print("βœ… Plotly API errors have been completely resolved") + print("βœ… Prevention system is working correctly") + print("βœ… Multiple verification levels are active") + print("\nπŸ›‘οΈ The system is now protected against recurrence!") + return True + else: + print(f"\n⚠️ {total - passed} tests failed") + print("❌ Additional fixes may be needed") + return False + +if __name__ == '__main__': + success = main() + sys.exit(0 if success else 1) \ No newline at end of file