-
Notifications
You must be signed in to change notification settings - Fork 14
Endpoint for stats about verified occurrences #1307
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
165ae9b
feat(occurrence-stats): add lca_rank_between helper
mihow 7b1660c
feat(occurrence-stats): aggregate human-model agreement over filtered…
mihow 3110418
feat(occurrence-stats): wire human-model-agreement action
mihow ba9c901
test(occurrence-stats): HTTP coverage for human-model-agreement action
mihow 5b1bde7
feat(ui): useHumanModelAgreement hook for occurrence stats
mihow e050a1f
docs(prompts): handoff for PR #1307 rework — rename + SQL push-down +…
mihow f49c9ca
refactor(occurrence-stats): rename to model-agreement + push aggregat…
mihow da2a232
docs(plan): add text lang to fenced block (markdownlint MD040)
mihow 7ba8689
perf(occurrence-stats): scope agreement subqueries to verified set
mihow 6ad1885
feat(occurrence-stats): drop ORDER threshold; add coarsest_rank query…
6f51da5
feat(ui): align model-agreement hook with BE rename + multi-value que…
7c144b0
chore(docs): drop NEXT_SESSION_PROMPT.md from PR
34aace5
chore(docs): drop session-scratchpad planning docs from PR
36cc677
test(occurrence-stats): make any-rank bucket test deterministic
mihow b74b3cd
chore(occurrence-stats): move FE hook to UI PR #1308
mihow 2c65cce
feat(occurrence-stats): add Wilson CI + Cohen's kappa to model-agreement
mihow 336c1fe
refactor(stats): move wilson_interval + cohens_kappa to ami/utils/stats
mihow 6748631
feat(stats): expose response schema via OPTIONS metadata
mihow 8bea80f
fix(stats): exclude taxon-less verifications from agreement denominator
mihow 75b21c3
fix(stats): validate agreement_coarsest_rank via ChoiceField
mihow b65100f
fix(stats): wilson_interval rejects successes outside [0, total]
mihow 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
This file contains hidden or 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,39 @@ | ||
| """Metadata classes for DRF OPTIONS responses. | ||
|
|
||
| DRF's default ``SimpleMetadata`` only emits serializer field schema under | ||
| ``actions.POST`` / ``actions.PUT`` — write operations. Read-only endpoints | ||
| (stats actions, scalar aggregates) return just ``name`` + ``description`` on | ||
| OPTIONS, so their ``help_text=`` annotations on response serializers are | ||
| invisible to clients. | ||
|
|
||
| ``ResponseSchemaMetadata`` adds ``actions.GET`` carrying the response | ||
| serializer's field info (``type``, ``label``, ``help_text``, etc.), so | ||
| frontends can fetch one OPTIONS request per stats endpoint and render | ||
| tooltips / labels from the field metadata without hardcoding copy. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import typing | ||
|
|
||
| from rest_framework.metadata import SimpleMetadata | ||
|
|
||
|
|
||
| class ResponseSchemaMetadata(SimpleMetadata): | ||
| """Adds ``actions.GET`` with the response serializer's field schema. | ||
|
|
||
| Falls back gracefully if the view doesn't expose a serializer for GET | ||
| (anonymous endpoints, raw responses) — in that case the OPTIONS body | ||
| is unchanged from ``SimpleMetadata``'s default. | ||
| """ | ||
|
|
||
| def determine_metadata(self, request, view) -> dict[str, typing.Any]: | ||
| metadata = super().determine_metadata(request, view) | ||
| if "GET" in view.allowed_methods and hasattr(view, "get_serializer"): | ||
| try: | ||
| serializer = view.get_serializer() | ||
| except Exception: | ||
| return metadata | ||
| actions = metadata.setdefault("actions", {}) | ||
| actions.setdefault("GET", self.get_serializer_info(serializer)) | ||
| return metadata |
This file contains hidden or 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 hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.