This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
forked from HHS/simpler-grants-gov
-
Notifications
You must be signed in to change notification settings - Fork 0
[Issue #16] Connect the API to use the search index #63
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
62ba7f1
[Issue #9] Setup opensearch locally
chouinar 1922340
Some rearranging of files
chouinar 649339c
Dependency fixes
chouinar 2126171
Trying something else for the network setup?
chouinar 8f80852
Simplify the networking/docker setup
chouinar f02f3d3
[Issue #10] Populate the search index from the opportunity tables
chouinar 49c2a2b
Slightly tidying up
chouinar 25edfab
[Issue #14] Setup utils for creating requests and parsing responses f…
chouinar 1058287
Merge branch 'main' into chouinar/14-req-resp-tools
chouinar 327f242
A lot of tests / comments / cleanup
chouinar eaba30d
Add an example
chouinar 641ebd1
[Issue #16] Connect the API to use the search index
chouinar bba9a52
Docs and logging
chouinar 3b9fec9
Update OpenAPI spec
nava-platform-bot 01a5bc0
Adjust the allow_none logic
chouinar 3d933e8
Update OpenAPI spec
nava-platform-bot 28e106b
Merge branch 'main' into chouinar/14-req-resp-tools
chouinar 354654c
Merge branch 'chouinar/14-req-resp-tools' into chouinar/16-actual-impl
chouinar 2edec64
Merge branch 'main' into chouinar/16-actual-impl
chouinar 7dfe55b
Merge branch 'main' into chouinar/16-actual-impl
chouinar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
from src.adapters.search.opensearch_client import SearchClient | ||
from src.adapters.search.opensearch_config import get_opensearch_config | ||
from src.adapters.search.opensearch_query_builder import SearchQueryBuilder | ||
|
||
__all__ = ["SearchClient", "get_opensearch_config"] | ||
__all__ = ["SearchClient", "get_opensearch_config", "SearchQueryBuilder"] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from functools import wraps | ||
from typing import Callable, Concatenate, ParamSpec, TypeVar | ||
|
||
from flask import Flask, current_app | ||
|
||
from src.adapters.search import SearchClient | ||
|
||
_SEARCH_CLIENT_KEY = "search-client" | ||
|
||
|
||
def register_search_client(search_client: SearchClient, app: Flask) -> None: | ||
app.extensions[_SEARCH_CLIENT_KEY] = search_client | ||
|
||
|
||
def get_search_client(app: Flask) -> SearchClient: | ||
return app.extensions[_SEARCH_CLIENT_KEY] | ||
|
||
|
||
P = ParamSpec("P") | ||
T = TypeVar("T") | ||
|
||
|
||
def with_search_client() -> Callable[[Callable[Concatenate[SearchClient, P], T]], Callable[P, T]]: | ||
""" | ||
Decorator for functions that need a search client. | ||
|
||
This decorator will return the shared search client object which | ||
has an internal connection pool that is shared. | ||
|
||
Usage: | ||
@with_search_client() | ||
def foo(search_client: search.SearchClient): | ||
... | ||
|
||
@with_search_client() | ||
def bar(search_client: search.SearchClient, x: int, y: int): | ||
... | ||
""" | ||
|
||
def decorator(f: Callable[Concatenate[SearchClient, P], T]) -> Callable[P, T]: | ||
@wraps(f) | ||
def wrapper(*args: P.args, **kwargs: P.kwargs) -> T: | ||
return f(get_search_client(current_app), *args, **kwargs) | ||
|
||
return wrapper | ||
|
||
return decorator |
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Does this need to match the stemmer chosen in the utils?
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 is the utils, I found some issues with what I had configured in the prior PR when setting it up with our actual data and fixed it here.