-
Notifications
You must be signed in to change notification settings - Fork 38
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
Add paginated post_search
and scroll
to SearchClient, plus role methods
#507
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Enable paginated searches via this method. Pagination is different in this API from any existing APIs because `limit` and `offset` are sent as body parameters. As a result, some changes need to be made. The client method must support passing these and setting them in the passed data (as overrides). In the case that these are passed, the body therefore needs to be (shallow) copied before being updated. Tests ensure that this is done correctly, and that paging will therefore not be side-effecting.
A new method of `SearchClient`, `scroll`, allows access to the scrolling API. `SearchScrollQuery` is a helper type for easily building query documents. Scroll queries are similar to typical searches, but do not support all of the same fields, including boosts and facets. As a result, to support this alternate type, it and SearchQuery now share an internal base class which provides several of their shared methods. A new test exercises `paginated.scroll`, confirming that it works as expected with both dict data and `SearchScrollQuery`. Like paginated `post_search`, the method is written carefully to not be side-effecting on the data it is passed, and the test confirms this.
show-inheritance in autodoc behaves badly by default on these classes because they inherit from UserDict, and it therefore shows all of their dict-like methods. In order to have clear, but non-repetitious, documentation, the SearchQueryBase class is now documented, with a note that it is only included in docs to show the methods it provides. None of the methods of the search helpers were being picked up under autodoc because they had no docstrings. To rectify, add docstrings to all methods.
post_search
and scroll
to SearchClientpost_search
and scroll
to SearchClient, plus role methods
I've added the methods which would be needed for globus/globus-cli#597 to this PR, and updated the title. It was easier to add them here than to deal with the (inevitable) merge conflicts that would arise from adding them separately. The methods are extremely simple and easy to test. |
sirosen
commented
Jan 27, 2022
sirosen
commented
Feb 10, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The SearchClient gains three new methods here:
paginated.post_search
,scroll
, andpaginated.scroll
This also begins the long road towards having more complete test coverage of the SearchClient, its helpers, and methods.
These APIs are slightly different from some of the existing paginated ones, in that their pagination parameters are body params, not query params. However, because the paginator objects "just" pass their relevant arguments through to the client methods (
marker
,limit
, etc), it is possible to support these only by ensuring thatmarker
,limit
, andoffset
are supported as keyword args.Some care is taken not to mutate the data which was passed in to these methods, but otherwise the implementation does not require special efforts.
In order to make
scroll
more usable, an additional helper object is added,SearchScrollQuery
, for this specialized query type.The newly fleshed out documentation on this and
SearchQuery
should clarify the difference.