Skip to content

fix: Declare pandas in the dashboard extra - #95

Merged
m96-chan merged 1 commit into
mainfrom
fix/93-dashboard-extra-pandas
Sep 6, 2026
Merged

fix: Declare pandas in the dashboard extra#95
m96-chan merged 1 commit into
mainfrom
fix/93-dashboard-extra-pandas

Conversation

@m96-chan

@m96-chan m96-chan commented Sep 6, 2026

Copy link
Copy Markdown
Owner

Summary

dashboard.py guards its gradio import and then imports pandas unguarded, but the dashboard extra only listed gradio.

try:
    import gradio as gr
except ImportError as e:
    raise ImportError("Gradio is required for the dashboard. "
                      "Install it with: pip install pyetwkit[dashboard]") from e

import pandas as pd          # not guarded, not declared

It works today only because gradio depends on pandas — the extra has been relying on another package's dependency list to be complete.

Changes

  • pyproject.toml: dashboard extra declares pandas>=2.0
  • Two tests in test_dashboard.py

Related Issue

Closes #93

Test Plan

Added/Modified Tests

The test reads the installed metadata rather than importing gradio, which is heavy and not installed in CI. It asserts the extra declares what the module imports, so another unguarded import added later without declaring it will fail here.

A second test pins that importing pyetwkit.dashboard needs neither package — only _create_gradio_app does.

Test Results

Failing before the fix, against the previous metadata:

FAILED tests/test_dashboard.py::TestDashboardExtra::test_extra_declares_every_package_the_dashboard_imports
1 failed, 24 passed

After:

25 passed
351 passed        # full suite
ruff / black      clean
$ python -c "import importlib.metadata as m; print([r for r in m.requires('pyetwkit') if 'dashboard' in r])"
["gradio>=4.0 ; extra == 'dashboard'", "pandas>=2.0 ; extra == 'dashboard'"]

One thing worth noting: my first version of the test matched extra == "dashboard" with double quotes and kept failing after the fix was already correct. The metadata uses single quotes. It now matches either, rather than one build backend's formatting.

Checklist

  • Tests have been added/updated
  • All tests pass
  • Ready for code review
  • Documentation updated (if applicable)
  • CHANGELOG.md updated (if applicable)

Additional Notes

Not done: putting the dashboard extra in CI, the way #87 did for export. _create_gradio_app() has no test coverage at all — tests/test_dashboard.py never mentions gradio — so installing it would currently buy nothing without new tests to go with it, and gradio is a heavy install across five matrix entries. Worth deciding separately.

🤖 Generated with Claude Code

https://claude.ai/code/session_01HhPcm483PrDmuQEUSALBFn

`dashboard.py` guards its gradio import and then imports pandas unguarded, but
the extra only listed gradio. It has worked so far because gradio depends on
pandas, so the extra has been relying on another package's dependency list to
be complete.

If gradio ever drops that dependency the failure is a bare ModuleNotFoundError,
and the advice already attached to the gradio guard -- "Install it with: pip
install pyetwkit[dashboard]" -- is no help, because the user has run exactly
that.

The test reads the installed metadata rather than importing gradio, which is
heavy and not installed in CI. It checks the extra declares what the module
imports, so adding another unguarded import without declaring it will fail.

Closes #93

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HhPcm483PrDmuQEUSALBFn
@m96-chan
m96-chan merged commit d9b5757 into main Sep 6, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] dashboard extra が pandas を宣言していない(gradio の推移的依存で動いている)

1 participant