-
Notifications
You must be signed in to change notification settings - Fork 7
[EQL] Cleaning, Dataclass Failures, Refactor Quantification Constraints, Doc update #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
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 refactors the quantification constraint API in the Entity Query Language (EQL) by introducing a new type-safe constraint system based on dataclasses. The main changes include converting exception classes to use a dataclass pattern and replacing the previous at_least/at_most/exactly parameters with explicit constraint types (AtLeast, AtMost, Exactly, and Range).
- Introduces new
ResultQuantificationConstrainthierarchy with type-safe constraint classes - Converts exception classes to use the
DataclassExceptionbase pattern - Updates API to use explicit constraint objects instead of integer parameters
- Updates documentation and examples to reflect the new API
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
src/krrood/entity_query_language/result_quantification_constraint.py |
New file defining the constraint class hierarchy |
src/krrood/utils.py |
Adds DataclassException base class for exception pattern |
src/krrood/entity_query_language/failures.py |
Converts exceptions to dataclass pattern and adds new exception types |
src/krrood/entity_query_language/symbolic.py |
Refactors ResultQuantifier to use new constraint objects |
src/krrood/entity_query_language/entity.py |
Updates an() function API to use constraint parameter |
test/test_eql/test_core/test_queries.py |
Updates tests to use new constraint API |
examples/eql/writing_rule_trees.md |
Updates documentation example |
examples/eql/result_quantifiers.md |
Updates documentation with new API usage |
Comments suppressed due to low confidence (1)
src/krrood/entity_query_language/failures.py:112
- Missing space between sentences in the error message. Add a space at the end of line 111 or beginning of line 112 to properly separate 'compute.' from 'To'.
f" because it is ambiguous and can be very expensive to compute."
f"To Negate Conditions do:"
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
LucaKro
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool stuff, just some small notes 💪
This pull request refactors how result quantification constraints are specified and handled in the entity query language package. The main change is replacing the previous approach of passing separate
at_least,at_most, andexactlyarguments with a unifiedquantificationconstraint object. This improves clarity, extensibility, and error handling for queries. The update also introduces new exception classes and refactors documentation and usage examples to match the new API.Result quantification constraint API overhaul:
ResultQuantificationConstraintclass hierarchy (Exactly,AtLeast,AtMost,Range) insrc/krrood/entity_query_language/result_quantification_constraint.py, replacing separate cardinality arguments for queries.anfunction insrc/krrood/entity_query_language/entity.pyto accept a singlequantificationargument of typeResultQuantificationConstraint, removingat_least,at_most, andexactly.ResultQuantifierclass insrc/krrood/entity_query_language/symbolic.pyto use the new constraint object and refactored cardinality limit logic accordingly. [1] [2]Thequantifier to useExactly(1)as its default constraint.Exception and error handling improvements:
src/krrood/entity_query_language/failures.py, including new types for negative cardinality, invalid entity types, and clearer error messages using dataclasses. [1] [2]Documentation and usage updates:
examples/eql/result_quantifiers.mdto use the newquantificationparameter, demonstrating usage withExactly,AtLeast,AtMost, andRange. [1] [2] [3] [4] [5]Codebase cleanup and consistency:
These changes make the quantification API more robust, easier to use, and extensible for future enhancements.