-
Notifications
You must be signed in to change notification settings - Fork 25
Add support for optional enum queryables #390
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
base: main
Are you sure you want to change the base?
Conversation
Hi @Zaczero Looks great - what do you think about adding a test for this? |
Changelog entry |
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.
Looks good to me but maybe @jamesfisher-geo or someone else can have a look too.
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.
Looks good! One question in regard to raising a ValueError.
stac_fastapi/opensearch/stac_fastapi/opensearch/database_logic.py
Outdated
Show resolved
Hide resolved
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.
Looks good to me
# Arrange | ||
# Enforce instant database refresh | ||
# TODO: Is there a better way to do this? | ||
monkeypatch.setenv("DATABASE_REFRESH", "true") |
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.
We shouldn't have to refresh the database in our tests because we add so little data to the db. We could do something like this to refresh as well:
r = await app_client.post(
f"/collections/{collection_id}/items",
json=item_data,
params={"refresh": "true"}
)
r.raise_for_status()
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 needed for the tests to pass. After the last item is added, data may not be immediately available for queries (up to a second of delay), which causes tests to be flaky. I don't know a better way to force a refresh, so I just monkey-patched the env config. I tried adding ?refresh=true
to the request URL, but that didn't work.
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.
Weird 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.
We do add items in other tests that seem to be available immediately
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.
In my testing, that wasn't the case, so maybe I'm doing something incorrectly? Some tests pass the refresh=True
argument to the db directly (https://github.com/search?q=repo%3Astac-utils%2Fstac-fastapi-elasticsearch-opensearch%20refresh%3DTrue&type=code), which achieves the same goal, but here the tests are hitting the final HTTP endpoint for maximum coverage, and I couldn't find a better way to enforce refresh with it.
It would be nice to document this functionality somewhere as it is potentially very valuable. |
Description:
This enables support for generating "enum" fields for selected queryables. There is also now a concept of optional queryable parameters - so it's possible to indicate enum fields without requiring that field to be present in all collections. This enum generation is very efficient as it's basically an index-only scan.
Other small changes include adding the previously missing get_items_mapping abstract to the base database logic. I also got confused by the existence of "OS_HOST" and "OS_PORT" variables in the Makefile which appear to be unused, so I simply removed them too.
PR Checklist:
pre-commit run --all-files
)make test
)