-
Notifications
You must be signed in to change notification settings - Fork 68
[AL-4886] Introduce ModelSlice #931
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ class Slice(DbObject): | |
| updated_at (datetime) | ||
| filter (json) | ||
| """ | ||
|
|
||
| name = Field.String("name") | ||
| description = Field.String("description") | ||
| created_at = Field.DateTime("created_at") | ||
|
|
@@ -57,3 +58,40 @@ def get_data_row_ids(self) -> PaginatedCollection: | |
| dereferencing=['getDataRowIdsBySavedQuery', 'nodes'], | ||
| obj_class=lambda _, data_row_id: data_row_id, | ||
| cursor_path=['getDataRowIdsBySavedQuery', 'pageInfo', 'endCursor']) | ||
|
|
||
|
|
||
| class ModelSlice(Slice): | ||
| """ | ||
| Represents a Slice used for filtering data rows in Model. | ||
| """ | ||
|
|
||
| def get_data_row_ids(self) -> PaginatedCollection: | ||
| """ | ||
| Fetches all data row ids that match this Slice | ||
|
|
||
| Returns: | ||
| A PaginatedCollection of data row ids | ||
| """ | ||
| query_str = """ | ||
| query getDataRowIdsBySavedQueryPyApi($id: ID!, $from: String, $first: Int!) { | ||
| getDataRowIdsBySavedQuery(input: { | ||
| savedQueryId: $id, | ||
| after: $from | ||
| first: $first | ||
| }) { | ||
| totalCount | ||
| nodes | ||
| pageInfo { | ||
| endCursor | ||
| hasNextPage | ||
| } | ||
| } | ||
| } | ||
| """ | ||
| return PaginatedCollection( | ||
| client=self.client, | ||
| query=query_str, | ||
| params={'id': self.uid}, | ||
| dereferencing=['getDataRowIdsBySavedQuery', 'nodes'], | ||
| obj_class=lambda _, data_row_id: data_row_id, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not following here... according to PaginatedCollection documentation, obj_class is a class of an object...
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That documentation is 4 years old, I think it's outdated. I was actually just copying the code from CatalogSlice here 😅 |
||
| cursor_path=['getDataRowIdsBySavedQuery', 'pageInfo', 'endCursor']) | ||
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.
according to gql above, $first is required, but I do not see it in the params. Is it ok?
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.
prob handled in
PaginatedCollection?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.
Yup https://github.com/Labelbox/labelbox-python/blob/develop/labelbox/pagination.py#L148