-
Notifications
You must be signed in to change notification settings - Fork 204
Implement Vizro dashboard generation POC #2082
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
Convert Mito's code generation system from Streamlit to Vizro. Updated prompts to generate Vizro dashboard applications instead of Streamlit apps, disabled validation for the POC, and modified the preview manager to launch Vizro apps on dynamically allocated ports. Added vizro as a project dependency. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
| app_code = re.sub(r'\.run\(\s*\)', f'.run(port={port})', app_code) | ||
| elif re.search(r'\.run\(', app_code): | ||
| # Has arguments - insert port as first argument | ||
| app_code = re.sub(r'\.run\(', f'.run(port={port}, ', app_code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Regex replaces all .run() calls, not just Vizro
The regex patterns \.run\(\s*\) and \.run\( match any .run( call in the code, not specifically the Vizro Vizro().build(dashboard).run() call. This will incorrectly modify unrelated method calls like subprocess.run(), asyncio.run(), or df.run() that may be present in the generated code. Additionally, if the preview is started multiple times without regenerating the file, the port injection will stack (e.g., .run(port=X) becomes .run(port=Y, port=X)), causing a runtime error from duplicate keyword arguments.
- Update system prompt with @capture decorator requirements for vm.Graph and vm.Table - Add comprehensive examples showing correct vs incorrect Vizro patterns - Fix port injection to remove existing port arguments before adding new ones - Use sys.executable for subprocess to ensure correct Python interpreter - Add detailed guidance for chart type conversions using @capture("graph") 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
|
|
||
| # Write back the modified code | ||
| with open(app_path, 'w') as f: | ||
| f.write(app_code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Race condition when modifying app file for port
The file read/modify/write sequence for port injection is not atomic or protected by a lock. If two concurrent preview requests target the same app file, one request can read the file, a second request can overwrite it with a different port, and then the first request's subprocess reads the modified file with the wrong port. The first request will then wait on a port where nothing is listening, causing a timeout. The original Streamlit implementation passed the port via command-line argument which didn't have this issue.
Re-enables the validation loop for Vizro dashboards with a new validate_vizro_app module that checks syntax and runtime errors by building the dashboard in a subprocess without running the server. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
| import os | ||
| app_path = os.path.join(app_directory, app_file_name) | ||
| with open(app_path, 'r') as f: | ||
| app_code = f.read() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Missing UTF-8 encoding when reading/writing app file
The file operations at lines 61 and 82 use open() without specifying encoding='utf-8', but the app file was originally created with UTF-8 encoding in create_app_file(). On Windows, Python uses the system default encoding (often not UTF-8) when no encoding is specified. This can cause encoding errors or data corruption when the generated code contains non-ASCII characters like unicode symbols, accented characters, or emoji.
Additional Locations (1)
| # First, remove any existing port= arguments to avoid duplicates | ||
| import re | ||
| # Remove existing port=XXXX arguments (with optional trailing comma and space) | ||
| app_code = re.sub(r'port=\d+,?\s*', '', app_code) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Regex pattern may corrupt non-run port arguments
The regex pattern r'port=\d+,?\s*' used to remove existing port arguments is overly broad and matches port= anywhere in the code, not just within .run() calls. This could unintentionally corrupt other parts of generated code, such as database connection strings, configuration dictionaries, or variable assignments that contain port= parameters.
Includes the generated Vizro dashboard app for bike violations analysis and updated notebook with cell outputs from testing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Developer local file paths committed in notebook output
The notebook cell output for pip install folium contains developer-specific local file paths exposing personal information like the developer's username (aarondiamond-reivich) and internal project structure (/Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/...). Notebook outputs containing environment-specific paths are typically cleared before committing to avoid leaking local configuration details.
mito-ai/example-notebooks/geospatial/bike-violations.ipynb#L45-L67
mito/mito-ai/example-notebooks/geospatial/bike-violations.ipynb
Lines 45 to 67 in d567a5d
| }, | |
| "outputs": [ | |
| { | |
| "name": "stdout", | |
| "output_type": "stream", | |
| "text": [ | |
| "Requirement already satisfied: folium in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (0.20.0)\n", | |
| "Requirement already satisfied: branca>=0.6.0 in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (from folium) (0.8.2)\n", | |
| "Requirement already satisfied: jinja2>=2.9 in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (from folium) (3.1.6)\n", | |
| "Requirement already satisfied: numpy in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (from folium) (2.3.5)\n", | |
| "Requirement already satisfied: requests in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (from folium) (2.32.5)\n", | |
| "Requirement already satisfied: xyzservices in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (from folium) (2025.11.0)\n", | |
| "Requirement already satisfied: MarkupSafe>=2.0 in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (from jinja2>=2.9->folium) (3.0.3)\n", | |
| "Requirement already satisfied: charset_normalizer<4,>=2 in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (from requests->folium) (3.4.4)\n", | |
| "Requirement already satisfied: idna<4,>=2.5 in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (from requests->folium) (3.11)\n", | |
| "Requirement already satisfied: urllib3<3,>=1.21.1 in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (from requests->folium) (2.6.1)\n", | |
| "Requirement already satisfied: certifi>=2017.4.17 in /Users/aarondiamond-reivich/Mito/mito/.conductor/kinshasa/mito-ai/venv/lib/python3.12/site-packages (from requests->folium) (2025.11.12)\n", | |
| "\n", | |
| "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.3\u001b[0m\n", | |
| "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", | |
| "Note: you may need to restart the kernel to use updated packages.\n" | |
| ] | |
| } |
Convert Mito's code generation system from Streamlit to Vizro. Updated prompts to generate Vizro dashboard applications instead of Streamlit apps, disabled validation for the POC, and modified the preview manager to launch Vizro apps on dynamically allocated ports. Added vizro as a project dependency.
🤖 Generated with Claude Code
Description
Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context, and the specification if there is one.
Testing
Please provide a list of the ways you can "access" or use the functionality. Please try and be exhaustive here, and make sure that you test everything you list.
Documentation
Note if any new documentation needs to addressed or reviewed.
Note
Adds a folium installation cell and replaces Mito-specific DataFrame HTML with styled pandas tables in the bike-violations notebook.
mito-ai/example-notebooks/geospatial/bike-violations.ipynb):foliumwith captured output.Written by Cursor Bugbot for commit d567a5d. This will update automatically on new commits. Configure here.