Dispatch Lambda processing by instrument_type instead of ID allowlists - #169
Merged
Conversation
Adds a type→processor registry with catch-all S3 notifications, an fplc enum value, and type-based reprocess gating so new instruments don't need per-ID infra or handler branches. Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Cache instrument lookups, fail Function URL no-ops so files aren't stranded in processing, and tighten InstrumentType typing across the reprocess UI. Co-authored-by: Cursor <cursoragent@cursor.com>
Longer API outages should rely on Lambda async retries so we don't bill 10 GB sleep time inside each invocation. Co-authored-by: Cursor <cursoragent@cursor.com>
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
Lambda file processing no longer keys off hardcoded instrument IDs. The handler now resolves an instrument's
instrument_typethrough the API and looks up a processor in a single registry, so onboarding an instrument that reuses an existing vendor format needs no Lambda code change, noInstrumentenum entry, and no new S3 trigger.Three allowlists collapse into one registry plus one mirrored TypeScript constant:
lambda/src/data_hub_lambda/processors.py: mapsinstrument_typeto aprocess_filefunction and a filename gate.web/lib/instruments/processable-types.ts: replacesprocessable-ids.tsand gates the reprocess UI and API on type.infra/template.yaml: nine per-instrumentLambdaConfigurationfilter blocks collapse to one catch-allObjectCreated:*notification.Why
Adding an instrument previously meant editing the shared
Instrumentenum,INSTRUMENT_ID_TO_NAME_MAP, anelifchain inhandler.py,PROCESSABLE_INSTRUMENT_IDS, and a prefix/suffix filter pair in the SAM template. Every one of those was keyed on a specific instrument ID, so a second SpectraMax or a second gel doc required touching all five. Instrument type already exists as a Postgres enum on theinstrumentstable and is the property that actually determines which parser applies.Behavior changes worth reviewing
ObjectCreatedevent on the raw bucket. A union gate over all processor suffixes runs before any API call, so non-matching files return without network I/O.processingafter the web app already transitioned it. If the Function URL path still cannot dispatch (unmapped type / instrument 404), the handler PATCHes the file tofailedso it is not stranded.GET /instruments/:idper event (cached ~60s on a warm container). One short in-invocation retry (0.5s) covers blips; exhausted transient errors re-raise so S3 async retries can take over. 404 skips (and fails the file on reprocess); 401/403 log a scope hint and re-raise.fplcinstrument type added toinstrumentTypeEnum(migration0034). Seeded / livejolene-fplcdeliberately staysgeneric: its PDFs have not been confirmed against the ÄKTA parser, and mistyping it would feed non-ÄKTA files into that processor.instrument_typeadded to the run list API response socanReprocessRuncan gate on type client-side.Test plan
lambda/tests/test_processors.py: registry lookup, gates, union gate, web/Python allowlist sync, instrument cache, Function URL fail-to-failed, single transient retry.lambda/tests/integration/test_lambda_api.py: updated for type dispatch, 404/401/403 paths, and gate-skipping on reprocess.web/tests/integration/files.test.ts: reprocess eligibility on type, including 409 for unprocessable types.make check-allpasses.Docs
developer-docs/updated acrosslambda.md,conventions.md,ci-and-deployment.md,first-time-deployment.md, andshared-library.mdto describe type dispatch and drop the enum-registration steps.Made with Cursor