Add local mock for NABat's GraphQL API and file-download pipeline - #541
Merged
Merged
Conversation
naglepuff
force-pushed
the
mln/mock-nabat-server
branch
from
October 1, 2026 14:05
922ac91 to
a925db7
Compare
BatAI's NABat integration could only be exercised locally as far as the Keycloak login flow - actual recording fetches still hit NABat's real GraphQL API and S3 storage, neither of which is reachable from a local dev setup. Since BatAI never uses a real GraphQL client (every query is a plain templated string with no schema or variables), a minimal stand-in service can dispatch on substrings in the query text instead of running an actual GraphQL server. Renames dev/keycloak to dev/nabat_mock and docker-compose-keycloak.yml to docker-compose-nabat-mock.yml, and adds: - mock_server.py: mocks the single-recording fetch query, the annotation-push mutation, and the presigned-URL access check, generating real presigned URLs against the existing minio service so the download and spectrogram-generation pipeline runs end to end. Also seeds one already-vetted annotation per newly-fetched recording, so the annotations list isn't empty on first load. - upload_recording.py: uploads a .wav file (defaulting to the repo's own assets/example.wav) into minio for those presigned URLs to resolve to. - Env wiring for both full-Docker and native (host-run Django/celery) development, since the two need different minio hostnames baked into the signed URLs. - A Keycloak realm fix: the "sub" claim was missing from access tokens under this realm's lightweight-token configuration, which broke annotation creation. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
naglepuff
force-pushed
the
mln/mock-nabat-server
branch
from
October 1, 2026 14:20
a925db7 to
46c1ce2
Compare
naglepuff
commented
Oct 1, 2026
naglepuff
commented
Oct 1, 2026
naglepuff
commented
Oct 1, 2026
BryonLewis
approved these changes
Oct 1, 2026
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
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.
Summary
BatAI's NABat integration could previously only be exercised locally as far as the Keycloak login flow - actual recording fetches still hit NABat's real GraphQL API and S3 storage, neither of which is reachable from a local dev setup. Since BatAI never uses a real GraphQL client (every query is a plain templated string with no schema or variables), this adds a minimal stand-in service that dispatches on substrings in the query text instead of running an actual GraphQL server.
Renames
dev/keycloaktodev/nabat_mockanddocker-compose-keycloak.ymltodocker-compose-nabat-mock.yml, and adds:mock_server.py: mocks the single-recording fetch query, the annotation-push mutation, and the presigned-URL access check, generating real presigned URLs against the existingminioservice so the download and spectrogram-generation pipeline runs end to end. Also seeds one already-vetted annotation per newly-fetched recording, so the annotations list isn't empty on first load.upload_recording.py: uploads a.wavfile (defaulting to the repo's ownassets/example.wav) into minio for those presigned URLs to resolve to.subclaim was missing from access tokens under this realm's lightweight-token configuration, which broke annotation creation.Scoped to the single-recording fetch flow only - NABat's new "file list" feature (tracked separately) and species sync are not mocked.
Test plan
ruff check/ruff format --checkon all new Python filesnabat_recording_initialize→ real download from minio → real spectrogram generationupdateAcousticFileVetmutation mock and seeded annotation via direct queries to the running mocksubclaim fix against a fresh Keycloak realm import🤖 Generated with Claude Code