Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 17 additions & 15 deletions packages/pyodide-runtime-agent/src/cache-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,24 @@ export function getEssentialPackages(): string[] {
"matplotlib",
"numpy",
"pandas",
"polars", // Fast DataFrames
"duckdb", // SQL analytics
"pyarrow", // Arrow format for polars/duckdb interop
"polars",
"duckdb",
"pyarrow",
"requests",
"micropip",
"scipy", // Scientific computing
"sympy", // Symbolic mathematics
"bokeh", // Interactive visualization
"scikit-learn", // Machine learning
"altair", // Statistical visualization
"geopandas", // Geospatial data analysis
"rich", // Beautiful terminal output with colors
"networkx", // Network analysis
"beautifulsoup4", // Web scraping
"lxml", // XML/HTML parsing
"pillow", // Image processing
"statsmodels", // Statistical modeling
"pyodide-http",
"scipy",
"sympy",
"bokeh",
"scikit-learn",
"altair",
"geopandas",
"rich",
"networkx",
"beautifulsoup4",
"lxml",
"pillow",
"statsmodels",
];
}

Expand Down Expand Up @@ -64,6 +65,7 @@ export function getPreloadPackages(): string[] {
"scipy",
"requests",
"micropip",
"pyodide-http",
"ipython",
"rich",
];
Expand Down
22 changes: 13 additions & 9 deletions packages/pyodide-runtime-agent/src/ipython-setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@

This module sets up a complete IPython environment with rich display support,
matplotlib integration, enhanced error formatting, and proper output handling.

Note: For HTTPS requests, use the `requests` library instead of urllib:
import requests
import pandas as pd
from io import StringIO

response = requests.get("https://example.com/data.csv")
df = pd.read_csv(StringIO(response.text))
"""

import os
Expand Down Expand Up @@ -284,21 +292,17 @@ def setup_rich_formatters():


def format_exception(exc_type, exc_value, exc_traceback):
"""Format exceptions with rich formatting and color support"""
"""Format exceptions with standard Python traceback formatting"""
try:
# Use IPython's enhanced traceback formatting
from IPython.core.ultratb import VerboseTB

tb_formatter = VerboseTB(mode="Minimal", color_scheme="Neutral")
formatted_tb = tb_formatter.format_exception(exc_type, exc_value, exc_traceback)
return "".join(formatted_tb)
# Use standard traceback formatting to preserve exception type information
return "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
except Exception as format_error:
# Log formatting errors to structured logs instead of stderr
print(
f"[FORMATTER_ERROR] Failed to format exception: {format_error}", flush=True
)
# Fallback to standard traceback
return "".join(traceback.format_exception(exc_type, exc_value, exc_traceback))
# Fallback to basic formatting
return f"{exc_type.__name__}: {exc_value}"


# Override exception formatting
Expand Down