-
Notifications
You must be signed in to change notification settings - Fork 0
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
Features/beacon network #93
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.
first pass
bento_beacon/authz/headers.py
Outdated
@@ -2,6 +2,9 @@ | |||
|
|||
|
|||
def auth_header_getter(r: Request) -> dict[str, str]: |
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.
type hint seems wrong here if request can be false-y - should be Request | 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 one is fiddly.. r is not actually a request, it's a werkzeug LocalProxy that acts like a request when a request happens to present. When no request is present it's just LocalProxy
rather than 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.
hmm...
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.
I'm considering just removing this and handling the no-request edge case elsewhere. Seems inelegant to ask for headers when there's no request.
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.
removed
from ..endpoints.variants import get_variants | ||
from .bento_public_query import fields_intersection, fields_union | ||
|
||
PUBLIC_SEARCH_FIELDS_PATH = "/api/metadata/api/public_search_fields" |
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.
it'd be better to accept the katsu URL from a configuration variable and then build from there (so just katsu URL + /api/public_search_fields
)
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.
ah, hmm. These are calls to other katsus in the network:
- PUBLIC_SEARCH_FIELDS_PATH probably belongs in config rather than hidden in this file. I probably left it here because this entire file will be gone in the next version.
- beacon network is configured by passing in beacon base urls. We find the katsu search fields by figuring out the base bento url (ie remove
/api/beacon
) and adding on PUBLIC_SEARCH_FIELDS_PATH. So, you have your choice of which is least inelegant:
- url surgery as above
- configure network by using bento base urls instead of beacon urls
- configure network by passing both beacon and katsu urls
In the next iteration this will all be replaced by calls to network beacons only, so this sort of url modification will no longer be needed.
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.
if it's temporary it's fine to leave in, but in general I think not relying on Bento's particular URL setup at time of code-writing (so configuring Katsu URL separately) is the best long-term approach if any contact is needed.
return fields | ||
|
||
|
||
def public_search_fields_url(beacon_url): |
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 shouldn't rely on katsu being under the portal.
subdomain forever in bento. instead, take the Katsu URL as an env var (similar to aggregation or WES) and build it from Katsu + whatever subpath is required.
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.
see above
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.
from a quick scan of the code. i should also try this out... is there an easy way I can set this up locally?
bento_beacon/utils/katsu_utils.py
Outdated
def get_katsu_config_search_fields(): | ||
# Use forwarded auth for getting available search fields, which may be limited based on access level | ||
fields = katsu_get(current_app.config["KATSU_PUBLIC_CONFIG_ENDPOINT"], requires_auth="forwarded") | ||
def get_katsu_config_search_fields(requires_auth): |
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.
would be good to type hint this argument the same as the other one - you could make a type RequiresAuthOptions = Literal["none", "forwarded", "full"]
and use that as the type hint both here and above.
bento_beacon/config_files/config.py
Outdated
@@ -1,5 +1,6 @@ | |||
import json | |||
import os | |||
from ..constants import GRANULARITY_COUNT, GRANULARITY_RECORD |
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.
it's nice to have local imports below module imports (urllib3 here)
for local test, use Bento v17 branch and see setup instructions here. You'll probably need to change bento_public version to pr-165 Edit: also requires this patch if not already merged |
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.
tested with the default config for now - seems to work well.
First pass at code for networking Bento beacons together.
Aggregation is done in the client rather than here. This allows for real-time updates in the frontend, rather than waiting for the slowest beacon to respond. However, aggregation is easy and should come in a later version, since it lets us:
Some features are still experimental:
sex=MALE
orBMI<18
) since that's what our beacons currently use. Once changes are rolled out to all beacons, we can use beacon spec filtering terms instead.Related PRS:
Todos for next version: