Skip to content

Commit 17e5100

Browse files
committed
Remove Streamlit dependency and migrate to Flask dashboard
- Remove streamlit from pyproject.toml dependencies - Update CLI dash command to launch Flask instead of Streamlit - Add environment variable support for Flask host/port configuration - Remove mock_streamlit fixture from tests - Update README to reflect Flask-based dashboard - Fix mypy error: use os.environ instead of subprocess.os.environ
1 parent 1d20427 commit 17e5100

5 files changed

Lines changed: 21 additions & 50 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ emergent/
4949
│ ├── training/ # Training loops and optimization
5050
│ ├── experiments/ # Population dynamics and ablation studies
5151
│ ├── analysis/ # Language analysis and evaluation
52-
│ ├── apps/ # CLI and Streamlit dashboard
52+
│ ├── apps/ # CLI interface
5353
│ └── tracking/ # MLflow experiment tracking
5454
├── tests/ # Unit and integration tests
5555
├── docs/ # Documentation and figures

dashboard/main.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,9 @@ def get_stats() -> Response:
151151

152152

153153
if __name__ == "__main__":
154-
app.run(debug=True, host="0.0.0.0", port=5000)
154+
import os
155+
156+
host = os.environ.get("FLASK_RUN_HOST", "0.0.0.0")
157+
port = int(os.environ.get("FLASK_RUN_PORT", "5000"))
158+
159+
app.run(debug=True, host=host, port=port)

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ dependencies = [
3636
"numpy>=1.21.0",
3737
"matplotlib>=3.5.0",
3838
"seaborn>=0.11.0",
39-
"streamlit>=1.28.0",
4039
"pandas>=1.5.0",
4140
"scipy>=1.7.0",
4241
"mlflow>=2.0.0",

src/langlab/apps/cli.py

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -570,47 +570,35 @@ def parse_heldout(heldout_str: str) -> list:
570570

571571

572572
@main.command()
573-
@click.option("--port", default=8888, help="Port to run the dashboard on")
574-
@click.option("--host", default="localhost", help="Host to run the dashboard on")
573+
@click.option("--port", default=5000, help="Port to run the dashboard on")
574+
@click.option("--host", default="0.0.0.0", help="Host to run the dashboard on")
575575
def dash(port: int, host: str) -> None:
576-
"""Launch the interactive Streamlit dashboard for visualizing language emergence."""
576+
"""Launch the Flask dashboard for visualizing language emergence."""
577+
import os
577578
import subprocess
578579
import sys
579-
import os
580+
from pathlib import Path
580581

581-
# Get the path to the app.py file
582-
app_path = os.path.join(os.path.dirname(__file__), "app.py")
582+
dashboard_dir = Path(__file__).parent.parent.parent.parent / "dashboard"
583+
app_path = dashboard_dir / "main.py"
583584

584-
if not os.path.exists(app_path):
585-
click.echo("Error: Dashboard app not found", err=True)
585+
if not app_path.exists():
586+
click.echo("Error: Dashboard not found at dashboard/main.py", err=True)
586587
return
587588

588589
logger.info(f"Launching dashboard on {host}:{port}")
589590
click.echo("Launching Language Emergence Dashboard...")
590-
click.echo(f"Dashboard will be available at: http://{host}:{port}")
591+
click.echo(f"Dashboard will be available at: http://localhost:{port}")
591592
click.echo("Press Ctrl+C to stop the dashboard")
592593

593594
try:
594-
# Launch Streamlit
595-
cmd = [
596-
sys.executable,
597-
"-m",
598-
"streamlit",
599-
"run",
600-
app_path,
601-
"--server.headless",
602-
"true",
603-
"--server.port",
604-
str(port),
605-
"--server.address",
606-
host,
607-
]
608-
subprocess.run(cmd, check=True)
595+
cmd = [sys.executable, str(app_path)]
596+
env = {**os.environ, "FLASK_RUN_PORT": str(port), "FLASK_RUN_HOST": host}
597+
subprocess.run(cmd, check=True, env=env)
609598
except subprocess.CalledProcessError as e:
610599
logger.error(f"Failed to launch dashboard: {e}")
611600
click.echo(
612-
"Error: Failed to launch dashboard. Make sure Streamlit is installed.",
613-
err=True,
601+
"Error: Failed to launch dashboard. Make sure Flask is installed.", err=True
614602
)
615603
except KeyboardInterrupt:
616604
click.echo("\nDashboard stopped.")

tests/conftest.py

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -226,27 +226,6 @@ def sample_ablation_params() -> Dict[str, Any]:
226226
}
227227

228228

229-
@pytest.fixture
230-
def mock_streamlit() -> Generator[Any, None, None]:
231-
"""Mock Streamlit for testing dashboard components."""
232-
with patch("streamlit.set_page_config"), patch("streamlit.title"), patch(
233-
"streamlit.markdown"
234-
), patch("streamlit.sidebar"), patch("streamlit.selectbox"), patch(
235-
"streamlit.warning"
236-
), patch(
237-
"streamlit.success"
238-
), patch(
239-
"streamlit.error"
240-
), patch(
241-
"streamlit.metric"
242-
), patch(
243-
"streamlit.plotly_chart"
244-
), patch(
245-
"streamlit.pyplot"
246-
) as mock_plt:
247-
yield mock_plt
248-
249-
250229
@pytest.fixture
251230
def mock_torch_load() -> Generator[Any, None, None]:
252231
"""Mock torch.load for testing checkpoint loading."""

0 commit comments

Comments
 (0)