Skip to content

FEAT support circular pointers - #549

Merged
adrinjalali merged 6 commits into
skops-dev:mainfrom
adrinjalali:worktree-gh184-circular-refs
Sep 29, 2026
Merged

adrinjalali merged 6 commits into
skops-dev:mainfrom
adrinjalali:worktree-gh184-circular-refs

Conversation

@adrinjalali

Copy link
Copy Markdown
Member

Fixes #184 and Birch, supporting circular imports.

Copilot AI 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.

Copilot review overview

🟡 Changes recommended

The new circular schema remains protocol 2, allowing released readers to accept files they cannot construct.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds circular-reference persistence, enabling SciPy distributions and fitted Birch models to round-trip correctly.

Changes:

  • Detects and reconstructs supported circular object graphs.
  • Prevents recursion during auditing and visualization.
  • Adds regression, compatibility, and corruption tests.
File Description
skops/​io/​_audit.py Safely constructs recursive nodes.
skops/​io/​_general.py Builds mutable containers in place.
skops/​io/​_sklearn.py Enables Birch persistence.
skops/​io/​_utils.py Detects circular references while saving.
skops/​io/​_visualize.py Marks and stops at circular nodes.
skops/​io/​tests/​_utils.py Handles cycles in equality helpers.
skops/​io/​tests/​test_audit.py Tests recursive-node auditing.
skops/​io/​tests/​test_persist.py Tests circular-reference round trips.
skops/​io/​tests/​test_persist_old.py Tests collision-free downgraded IDs.
skops/​io/​tests/​test_visualize.py Tests circular visualization.
docs/​changes.rst Documents the new support.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread skops/io/_utils.py

Copilot AI 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.

Copilot review overview

🔵 Needs a closer look

The new circular-reference schema remains protocol 3 and can cause recursion in released protocol-3 readers.

Review effort: Balanced
Findings: None

Resolved since last review (1)

@adrinjalali
adrinjalali merged commit fd22119 into skops-dev:main Sep 29, 2026
27 of 28 checks passed
@adrinjalali
adrinjalali deleted the worktree-gh184-circular-refs branch September 29, 2026 07:19
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: loading certain scipy functions fails

2 participants