Skip to content

fix(layouts): run layouts on Polars-bound graphs (#1966) - #2173

Open
lmeyerov wants to merge 2 commits into
fix/polars-graph-algorithms-2025from
fix/polars-layouts-1966
Open

lmeyerov wants to merge 2 commits into
fix/polars-graph-algorithms-2025from
fix/polars-layouts-1966

Conversation

@lmeyerov

Copy link
Copy Markdown
Contributor

Closes #1966. Stacked on #2172, which adds bridge_polars_graph. Retarget to master after #2172 merges.

Problem

Freshly reproduced at master 599c405a on eager and lazy Polars:

  • ring_categorical, ring_continuous, time_ring: AttributeError: reset_index for every engine value, including engine='pandas'.
  • mercator_layout: Polars was routed to the cupy branch, causing an AttributeError.
  • group_in_a_box_layout: "Could not infer engine".
  • tree_layout: crashed on a LazyFrame.
  • circle, tree and modularity_weighted: silently returned pandas frames.

Change

All nine layout entry points are wrapped with bridge_polars_graph(Engine.PANDAS). Polars-bound graphs, eager or lazy, run on pandas and return eager Polars frames with their identifier dtypes. An explicit engine='pandas' or 'cudf' returns that engine's frames. fa2_layout still needs a GPU engine or allow_cpu_fallback=True, exactly as for pandas input. This intentionally changes circle, tree and modularity from returning pandas to returning Polars; the CHANGELOG and engines.rst document it.

Validation (dgx-spark, polars 1.35.2, igraph 1.0.0)

  • New test_polars_layouts.py: 35 pass. Each layout's Polars result matches the pandas-bound result on rows, deterministic values, edges, bindings and id dtypes, for eager and lazy input. The tests also cover explicit engine='pandas' and engine='polars', and that fa2 without a GPU engine declines just as it does on pandas.
  • Layout, plugin and GFQL call regression: the base has 3 failures and 705 passes; this branch has the same 3 pre-existing cuGraph failures and 740 passes.
  • ruff, mypy, comment-density and type-hygiene guards: clean.

Out of scope and unchanged: rotate() and label_components() on Polars, and engine='polars' on pandas-bound graphs, which layouts still decline.

Merge note: this needs an admin merge (no self-approval possible), which means no human review.

🤖 Generated with Claude Code

lmeyerov and others added 2 commits October 9, 2026 22:51
Six layouts crashed on polars frames (ring layouts called reset_index before
resolving the engine, mercator routed polars to the cupy branch,
group_in_a_box could not infer an engine) and three silently returned
pandas. Even engine='pandas' did not help.

All nine layout entry points now use bridge_polars_graph(Engine.PANDAS):
Polars-bound graphs (eager or lazy) run on pandas and return eager Polars
frames; explicit engine='pandas'/'cudf' returns that engine; fa2_layout keeps
requiring a GPU engine or allow_cpu_fallback, as for pandas input.

Tests compare each layout's Polars result with the pandas-bound result
(rows, values for deterministic layouts, edges, bindings, id dtypes) on
eager and lazy input, plus explicit engine='pandas' and engine='polars'.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

This branch has not been deployed

No deployments
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.

1 participant