fix: Fix gliner2 1.3 compatibility (engine submodule removal)#259
Conversation
…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>
Greptile SummaryThis PR fixes a compatibility break introduced by
Confidence Score: 5/5Safe 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
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_"]
Reviews (1): Last reviewed commit: "fix: Support gliner2 1.3 by resolving Sc..." | Re-trigger Greptile |
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
🚀 New features to boost your workflow:
|
Description
gliner21.3.1 (2026-05-06) removed thegliner2.inference.enginesubmodule and re-exportsSchema/StructureBuilderat the package root. The existinggliner2>=1.2,<2pin admits 1.3.x, but the code unconditionally imported fromgliner2.inference.engine— installs against 1.3+ fail at import time.Related Issues
-
Changes Made
Schema/StructureBuilderonce insieves/model_wrappers/gliner_.py, preferring the 1.3+ top-level re-exports and falling back togliner2.inference.enginefor 1.2.gliner_bridge.py,tasks/predictive/utils.py, the four predictiveschemas/*.pyfiles, and the two affected tests) throughgliner_.Schema/gliner_.StructureBuilderinstead of importing fromgliner2.inference.enginedirectly.Checklist
Screenshots/Examples (if applicable)