Async Request-Response for Bulk Variation Registration#480
Merged
Conversation
Add liftover return and flag to docs
jennifer-bowser
requested changes
Jun 10, 2026
jennifer-bowser
left a comment
Contributor
There was a problem hiding this comment.
Nice, this looks great! Just a couple of comments for you
Only define functions requiring async dependencies if the imports are available
Contributor
Author
|
@jennifer-bowser This is ready for re-review |
theferrit32
approved these changes
Jun 24, 2026
jennifer-bowser
approved these changes
Jun 24, 2026
theferrit32
added a commit
that referenced
this pull request
Jun 24, 2026
Resolve conflicts from #480, which moved bulk-registration logic from variations_router.py into the shared translate/register.py module. - anyvar.py: keep both sides (projection helpers + main's queueing/error additions) - variations_router.py: drop locally-defined registration funcs, import them from translate.register; keep `import os` - translate/register.py: port the projection hook and add_projection_mappings onto main's relocated register_variations (also covers the Celery async path)
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.
Async Request-Response for Bulk Variation Registration
Summary
This PR adds asynchronous request-response support to the
PUT /variationsendpoint, following the same async request-reply pattern already used by the/vcfendpoints. Large batches of variation registrations can now be submitted asynchronously viaPUT /variations?run_async=true, returning a202 Acceptedwith arun_idthat the client polls atGET /variations/{run_id}until the result is ready.As part of this work, the shared async task lifecycle logic (Celery state machine handling, run-ID validation, async-enabled checks) was extracted from the VCF router into a new reusable module, and the VCF router was refactored to consume it.
Key Changes
New module:
src/anyvar/restapi/async_utils.pyExtracts three reusable helpers previously inline in the VCF router:
check_async_enabled()— returns anErrorResponse(400) if async prerequisites are missingvalidate_run_id_available()— rejects duplicaterun_idvalues that are still active in Celeryresolve_async_task_status()— encapsulates the full Celery task state machine: SUCCESS → callon_successcallback and forget; FAILURE → extract error code, optional cleanup, forget; PENDING → poll up to 5s then 404; SENT → 202 withRetry-AfterModified:
src/anyvar/restapi/variations_router.pyPUT /variationsgainsrun_async(bool) andrun_id(optional str) query parameters. Whenrun_async=true, the request body is serialized and dispatched to a Celery task, returning aRunStatusResponsewithLocationandRetry-Afterheaders.GET /variations/{run_id}endpoint delegates toresolve_async_task_status()to return status or completed results.Modified:
src/anyvar/restapi/vcf_router.pyRefactored to import and use the shared helpers from
async_utilsinstead of inline implementations.New Celery task:
register_variationsinsrc/anyvar/queueing/celery_worker.pyDeserializes
VariationRequestdicts, calls_register_variations()via the worker'sAnyVarinstance, and returns serializedRegisterVariationResponsedicts. Uses the sameenter_task()/exit_task()/maybe_teardown_anyvar_app()lifecycle as existing VCF tasks.New:
has_variations_queueing_enabled()insrc/anyvar/anyvar.pyA lighter prerequisite check than the VCF equivalent — requires only
celery+CELERY_BROKER_URL(noaiofilesorANYVAR_VCF_ASYNC_WORK_DIR), since variation registration doesn't involve file I/O.Configuration
New environment variables (documented in
docs/source/configuration/async.rst):ANYVAR_VARIATIONS_ASYNC_FAILURE_STATUS_CODE500GET /variations/{run_id}on task failureANYVAR_EXPECTED_VARIATIONS_PER_SECOND100Retry-Afterheader valueAsync variation registration requires only
CELERY_BROKER_URLandCELERY_BACKEND_URL— not the VCF-specificANYVAR_VCF_ASYNC_WORK_DIR.Tests
tests/unit/restapi/test_async_utils.py— unit tests for all three shared helpers covering success, failure, timeout, cleanup, and edge casestests/unit/restapi/test_variations_router.py— endpoint tests forPUT /variations(async disabled, duplicate run_id, async success, custom run_id, sync fallback) andGET /variations/{run_id}(async disabled, delegation to resolver)Documentation
docs/source/usage/rest_api.rst— new "Asynchronous Bulk Registration" section with usage examplesdocs/source/configuration/async.rst— new "Variation Registration Settings" section; clarifying note that variation async doesn't requireANYVAR_VCF_ASYNC_WORK_DIRCloses #473