Skip to content

fix: Fix gliner2 1.3 compatibility (engine submodule removal)#259

Merged
rmitsch merged 1 commit into
mainfrom
fix/gliner-refactor
May 11, 2026
Merged

fix: Fix gliner2 1.3 compatibility (engine submodule removal)#259
rmitsch merged 1 commit into
mainfrom
fix/gliner-refactor

Conversation

@rmitsch

@rmitsch rmitsch commented May 11, 2026

Copy link
Copy Markdown
Collaborator

Description

gliner2 1.3.1 (2026-05-06) removed the gliner2.inference.engine submodule and re-exports Schema/StructureBuilder at the package root. The existing gliner2>=1.2,<2 pin admits 1.3.x, but the code unconditionally imported from gliner2.inference.engine — installs against 1.3+ fail at import time.

Related Issues

-

Changes Made

  • Resolve Schema / StructureBuilder once in sieves/model_wrappers/gliner_.py, preferring the 1.3+ top-level re-exports and falling back to gliner2.inference.engine for 1.2.
  • Route all other call sites (gliner_bridge.py, tasks/predictive/utils.py, the four predictive schemas/*.py files, and the two affected tests) through gliner_.Schema / gliner_.StructureBuilder instead of importing from gliner2.inference.engine directly.

Checklist

  • Tests have been extended to cover changes in functionality (existing tests cover the affected code paths; verified against gliner2 1.3.1)
  • Existing and new tests succeed
  • Documentation updated (if applicable)
  • Related issues linked

Screenshots/Examples (if applicable)

…kage root.

gliner2 1.3 removed the `gliner2.inference.engine` submodule. Resolve the
`Schema` and `StructureBuilder` types via `gliner_.Schema` / `gliner_.StructureBuilder`,
which prefers the 1.3+ top-level re-exports and falls back to the engine submodule
for 1.2.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@rmitsch rmitsch changed the title Fix gliner2 1.3 compatibility (engine submodule removal) fix: Fix gliner2 1.3 compatibility (engine submodule removal) May 11, 2026
@greptile-apps

greptile-apps Bot commented May 11, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a compatibility break introduced by gliner2 1.3.1, which removed the gliner2.inference.engine submodule and moved Schema/StructureBuilder to the package root. The fix centralises version detection in sieves/model_wrappers/gliner_.py with a try/except AttributeError shim, then routes all downstream consumers through gliner_.Schema / gliner_.StructureBuilder.

  • Compatibility shim (gliner_.py): attempts gliner2.Schema / gliner2.StructureBuilder first (1.3+) and falls back to gliner2.inference.engine (1.2), exposing both at the module level so the rest of the codebase never touches the versioned import path directly.
  • Consumer updates (bridge, schemas, utils, tests): all direct gliner2.inference.engine references are replaced with imports from the new compatibility layer, keeping the change minimal and consistent.

Confidence Score: 5/5

Safe to merge — the change is a targeted import compatibility shim with no behavioural changes, and all nine affected files have been updated consistently.

The shim correctly tries the 1.3+ top-level attributes first and falls back to the engine submodule for 1.2; the except block reassigns both names so the final state is always consistent. No remaining direct gliner2.inference.engine references exist outside the fallback clause, and the type annotations downstream all flow through the new module-level aliases.

No files require special attention. The only remaining gliner2.inference import is the intentional fallback in sieves/model_wrappers/gliner_.py.

Important Files Changed

Filename Overview
sieves/model_wrappers/gliner_.py Introduces the version-detection shim via try/except AttributeError; correct logic for both gliner2 1.2 and 1.3+.
sieves/tasks/predictive/gliner_bridge.py Replaces all direct gliner2.inference.engine references with gliner_.Schema / gliner_.StructureBuilder; consistent with the new shim.
sieves/tasks/predictive/utils.py Adds two targeted imports from the compatibility layer and updates the return-type annotation; _GlinerStructureBuilder import correctly used in type annotation.
sieves/tasks/predictive/schemas/classification.py TaskPromptSignature type alias updated to gliner_.Schema
sieves/tasks/predictive/schemas/information_extraction.py Same pattern as classification.py; TaskPromptSignature updated to use the compatibility layer.
sieves/tasks/predictive/schemas/ner.py Same pattern; TaskPromptSignature updated to use gliner_.Schema
sieves/tasks/predictive/schemas/relation_extraction.py Same pattern; TaskPromptSignature updated to use gliner_.Schema
sieves/tests/tasks/predictive/test_signature_utils.py Test imports updated from gliner2.inference.engine to the compatibility layer; test logic unchanged.
sieves/tests/tasks/predictive/test_task_signature_migration.py Same test import update pattern; all gliner2.inference.engine.Schema references replaced with _GlinerSchema.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[gliner_.py module load] --> B{gliner2.Schema exists?}
    B -->|Yes - gliner2 1.3+| C["Schema = gliner2.Schema\nStructureBuilder = gliner2.StructureBuilder"]
    B -->|AttributeError - gliner2 1.2| D["from gliner2.inference import engine\nSchema = engine.Schema\nStructureBuilder = engine.StructureBuilder"]
    C --> E["PromptSignature = Schema or StructureBuilder"]
    D --> E
    E --> F["gliner_bridge.py\ngliner_.Schema / gliner_.StructureBuilder"]
    E --> G["utils.py\n_GlinerSchema / _GlinerStructureBuilder"]
    E --> H["schemas/*.py\nTaskPromptSignature type aliases"]
    E --> I["tests/\n_GlinerSchema imported from gliner_"]
Loading

Reviews (1): Last reviewed commit: "fix: Support gliner2 1.3 by resolving Sc..." | Re-trigger Greptile

@codecov

codecov Bot commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #259      +/-   ##
==========================================
- Coverage   91.99%   91.99%   -0.01%     
==========================================
  Files          80       80              
  Lines        4462     4461       -1     
==========================================
- Hits         4105     4104       -1     
  Misses        357      357              
Files with missing lines Coverage Δ
sieves/model_wrappers/gliner_.py 94.11% <100.00%> (+0.36%) ⬆️
sieves/tasks/predictive/gliner_bridge.py 90.04% <100.00%> (-0.05%) ⬇️
sieves/tasks/predictive/schemas/classification.py 91.17% <ø> (-0.26%) ⬇️
...tasks/predictive/schemas/information_extraction.py 90.90% <100.00%> (-0.40%) ⬇️
sieves/tasks/predictive/schemas/ner.py 86.11% <100.00%> (-0.38%) ⬇️
...es/tasks/predictive/schemas/relation_extraction.py 96.87% <100.00%> (-0.10%) ⬇️
sieves/tasks/predictive/utils.py 90.38% <100.00%> (+0.09%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@rmitsch rmitsch merged commit b5f985e into main May 11, 2026
3 checks passed
@rmitsch rmitsch deleted the fix/gliner-refactor branch May 11, 2026 14:16
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