-
Notifications
You must be signed in to change notification settings - Fork 2
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
Neat 242 allow arbitrary filters but raise warning that we do not support them #451
Neat 242 allow arbitrary filters but raise warning that we do not support them #451
Conversation
…arning-that-we-do-not-support-them
☂️ Python Coverage
Overall Coverage
New FilesNo new covered files... Modified Files
|
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.
A few improvements possible. Pre-approving, but suggest you do them. In particular, avoid introducing filter
in the Base class.
@@ -15,6 +17,7 @@ class WrappedEntity(BaseModel, ABC): | |||
name: ClassVar[str] | |||
_inner_cls: ClassVar[type[Entity]] | |||
inner: list[Entity] | None | |||
filter: str | None = None |
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.
This seems to be only used by the RawFilter, so is there any reason to have it on the base class?
filter: str | None = None |
if self.filter: | ||
return self.filter | ||
else: | ||
return self.id |
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.
Suggest just overriding the __repr__
in the RawFilter class
@@ -150,6 +192,7 @@ class HasDataFilter(DMSFilter): | |||
name: ClassVar[str] = "hasData" | |||
_inner_cls: ClassVar[type[ContainerEntity]] = ContainerEntity | |||
inner: list[ContainerEntity] | None = None # type: ignore[assignment] | |||
filter: str | None = None |
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.
filter: str | None = None |
@@ -112,10 +129,35 @@ def from_dms_filter(cls, filter: dm.Filter) -> "DMSFilter": | |||
if isinstance(entry, dict) and "space" in entry and "externalId" in entry | |||
] | |||
) | |||
else: | |||
return RawFilter(filter=json.dumps(dumped)) | |||
|
|||
raise ValueError(f"Cannot convert {filter._filter_name} to {cls.__name__}") |
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.
This can now be removed as it cannot be reached. (The exception)
|
||
raise ValueError(f"Cannot convert {filter._filter_name} to {cls.__name__}") | ||
|
||
|
||
class RawFilter(DMSFilter): | ||
name: ClassVar[str] = "rawFilter" | ||
inner: list[ContainerEntity] | None = None # type: ignore[assignment] |
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.
Overwriting the base class forcing this to None
inner: list[ContainerEntity] | None = None # type: ignore[assignment] | |
inner: None = None # type: ignore[assignment] |
[0.77.1] - 14-05-24
Added
RawFilters
allow arbitrary filters to be applied to the data model.