Skip to content

Add interactive rendering for network inspector manifold plots#99

Merged
mariama-design merged 4 commits into
mainfrom
97-add-interactive-rendering-for-network-inspector-manifold-plots
Jul 21, 2026
Merged

Add interactive rendering for network inspector manifold plots#99
mariama-design merged 4 commits into
mainfrom
97-add-interactive-rendering-for-network-inspector-manifold-plots

Conversation

@mariama-design

@mariama-design mariama-design commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add Plotly-backed interactive 3D manifold rendering for network inspector plots
  • Expose the interactive plot path through the manifold API
  • Add focused API and plotting tests for the interactive surface output

Tests

  • uv run pytest tests/test_network_inspectors_api.py tests/test_network_inspectors_plotting.py
  • uv run ruff format --check .
  • uv run ruff check src/lanfactory
  • uv run pytest

Summary by CodeRabbit

  • New Features
    • Network manifold visualizations now return interactive Plotly 3D charts.
    • Charts can be displayed and exported as HTML files.
  • Bug Fixes
    • Improved preparation of model inputs so parameter portions are populated consistently for reaction-time and choice analyses.
    • Strengthened validation and deterministic failure modes for missing, empty, or incorrectly shaped parameter inputs.
  • Documentation
    • Updated the network inspector tutorial to reflect the revised input preparation behavior.
  • Tests
    • Added coverage for parameter validation, ordering/normalization, and Plotly figure output.

@mariama-design mariama-design linked an issue Jul 20, 2026 that may be closed by this pull request
@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Network inspector APIs now validate parameter inputs and ordering explicitly. Manifold plots use interactive Plotly surfaces with optional HTML export, supported by a dependency update, tutorial input preparation, and pytest coverage.

Changes

Network inspector updates

Layer / File(s) Summary
API validation and parameter preparation
src/lanfactory/network_inspectors/api.py, tests/test_network_inspectors_api.py, notebooks/network_inspectors_tutorial.ipynb
API entry points reject invalid or empty inputs, enforce parameter shapes and ordering, normalize arrays, and return a typed Plotly figure. Tutorial initialization populates the parameter portion of the network input.
Interactive Plotly manifold rendering
pyproject.toml, src/lanfactory/network_inspectors/plotting.py, tests/test_network_inspectors_plotting.py
plot_manifold returns a Plotly surface figure, optionally displays it and writes HTML output, with tests covering figure contents and saved output.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant lan_manifold
  participant plot_manifold
  participant Plotly
  lan_manifold->>plot_manifold: pass manifold data and varying parameter
  plot_manifold->>Plotly: construct interactive surface figure
  plot_manifold->>Plotly: export HTML when configured
  Plotly-->>lan_manifold: return go.Figure
Loading

Possibly related issues

  • lnccbrown/LANfactory issue 97: Covers replacing the static network-inspector manifold plot with an interactive Plotly figure and HTML export.

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding interactive Plotly rendering for network inspector manifold plots.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 97-add-interactive-rendering-for-network-inspector-manifold-plots

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/lanfactory/network_inspectors/plotting.py (1)

157-198: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Pivot/sort/surface construction verified correct against test expectations.

Traced signed_rt, pivot, and double-sort logic against test_plot_manifold_returns_interactive_plotly_figure values — x/y/z outputs match exactly.

One consideration: include_plotlyjs="cdn" (Line 192) requires network access to render the saved HTML plotly.js bundle offline. If the exported HTML is meant to be viewable without internet access (e.g., shared/archived), consider include_plotlyjs=True to embed the full library at the cost of file size.

♻️ Optional: embed plotly.js for offline viewing
         fig.write_html(
             os.path.join(cfg.save_dir, "mlp_manifold_" + spec.name + ".html"),
-            include_plotlyjs="cdn",
+            include_plotlyjs=True,
         )
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lanfactory/network_inspectors/plotting.py` around lines 157 - 198, Update
the save branch in the manifold plotting function around fig.write_html to embed
Plotly.js with include_plotlyjs=True, ensuring exported HTML files render
without network access while preserving the existing output path and plotting
behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/lanfactory/network_inspectors/api.py`:
- Around line 119-129: Update the row-count guard before the “Using only the
first row” log to check whether parameter_df contains more than one row, while
preserving the existing empty validation and first-row parameter selection.

---

Nitpick comments:
In `@src/lanfactory/network_inspectors/plotting.py`:
- Around line 157-198: Update the save branch in the manifold plotting function
around fig.write_html to embed Plotly.js with include_plotlyjs=True, ensuring
exported HTML files render without network access while preserving the existing
output path and plotting behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e5dc09c0-3bb8-4d1a-8538-41af4d24b71c

📥 Commits

Reviewing files that changed from the base of the PR and between 2ec5cf9 and b2efd1f.

📒 Files selected for processing (6)
  • notebooks/network_inspectors_tutorial.ipynb
  • pyproject.toml
  • src/lanfactory/network_inspectors/api.py
  • src/lanfactory/network_inspectors/plotting.py
  • tests/test_network_inspectors_api.py
  • tests/test_network_inspectors_plotting.py

Comment thread src/lanfactory/network_inspectors/api.py
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.85714% with 13 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/lanfactory/network_inspectors/api.py 53.84% 9 Missing and 3 partials ⚠️
src/lanfactory/network_inspectors/plotting.py 88.88% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/lanfactory/network_inspectors/plotting.py 30.37% <88.88%> (ø)
src/lanfactory/network_inspectors/api.py 62.50% <53.84%> (+32.95%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enhances the lanfactory.network_inspectors tooling by switching the LAN manifold visualization from a static Matplotlib surface to an interactive Plotly 3D surface, and by surfacing that interactive figure through the manifold API for easier downstream use (display/export).

Changes:

  • Replaced Matplotlib-based manifold rendering with an interactive Plotly Surface and HTML export.
  • Updated the network inspector API to validate parameter inputs more strictly and to return the Plotly figure from lan_manifold.
  • Added focused tests covering new validation behavior and the interactive manifold surface output.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/lanfactory/network_inspectors/plotting.py Reworks plot_manifold to produce and optionally save an interactive Plotly 3D surface.
src/lanfactory/network_inspectors/api.py Adds parameter validation and returns the Plotly figure from lan_manifold; enforces model parameter column ordering.
tests/test_network_inspectors_plotting.py New test asserting Plotly surface structure and HTML output for the manifold renderer.
tests/test_network_inspectors_api.py New tests for validation of empty/mis-shaped inputs and correct parameter ordering/normalization.
pyproject.toml Adds Plotly as a runtime dependency to support interactive rendering.
notebooks/network_inspectors_tutorial.ipynb Updates tutorial code snippet for revised network input preparation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lanfactory/network_inspectors/api.py Outdated
width=int(900 * cfg.fig_scale),
height=int(620 * cfg.fig_scale),
scene={
"xaxis_title": "RT",

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lanfactory/network_inspectors/api.py (1)

102-108: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Require a 1D sweep array here. np.asarray will let scalar or nested inputs through this size check, but build_manifold() iterates over vary_values directly. A 0-D scalar sweep will fail at iteration time, and higher-rank inputs can produce ambiguous assignments. Use vary_values.ndim == 1 (or np.atleast_1d if scalars are intended).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/lanfactory/network_inspectors/api.py` around lines 102 - 108, Update the
vary_values validation in the build_manifold sweep setup to require a
one-dimensional array before checking or using its contents. Reject scalar and
higher-rank inputs with an appropriate ValueError, while preserving the existing
non-empty requirement for valid 1D sweeps.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@src/lanfactory/network_inspectors/api.py`:
- Around line 102-108: Update the vary_values validation in the build_manifold
sweep setup to require a one-dimensional array before checking or using its
contents. Reject scalar and higher-rank inputs with an appropriate ValueError,
while preserving the existing non-empty requirement for valid 1D sweeps.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 306ae530-4587-4ca4-942a-6233be2d9444

📥 Commits

Reviewing files that changed from the base of the PR and between b2efd1f and 284a85e.

📒 Files selected for processing (2)
  • src/lanfactory/network_inspectors/api.py
  • src/lanfactory/network_inspectors/plotting.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lanfactory/network_inspectors/plotting.py

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@cpaniaguam cpaniaguam left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! @mariama-design feel free to click the merge button, thanks!

@mariama-design
mariama-design merged commit d725ae3 into main Jul 21, 2026
9 of 10 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.

Add interactive rendering for network-inspector manifold plots

3 participants