Skip to content

Migrate to Starlette 1.0#271

Merged
khoroshevskyi merged 7 commits intodevfrom
starlette-upgrade
Apr 22, 2026
Merged

Migrate to Starlette 1.0#271
khoroshevskyi merged 7 commits intodevfrom
starlette-upgrade

Conversation

@nsheff
Copy link
Copy Markdown
Member

@nsheff nsheff commented Apr 20, 2026

Summary

  • Migrate bedhost to Starlette 1.0 (TemplateResponse new signature, lifespan handler, app.state + Depends() for bbagent/usage_data/ref_validator, Pydantic v2 kwargs, fastapi.responses, duplicate endpoint name fixes, HTTPException detail cleanup, uvicorn import-string form).
  • Guard analyze_reference_genome against None ref_validator when BEDHOST_INIT_ML=false.
  • Pin sentence_transformers>=5.0 (bbconf imports SparseEncoder).
  • Bump version to 0.12.7.

Fixes the HTTP 500 on /v1 caused by the deprecated pre-1.0 TemplateResponse(name, context_with_request) signature that Starlette 1.0 finalized as removed.

Test plan

  • CI passes
  • Deploy to yeti and confirm /v1, /v1/openapi.json, /v1/docs/changelog, /v1/stats, /v1/bed/list all return 200
  • Compliance tests (on compliance-tests branch) pass against redeployed API

nsheff added 4 commits April 20, 2026 16:39
Starlette 1.0.0 is now the installed version (pulled in by an unrelated
CI rebuild on 2026-04-16). This commit migrates the codebase to the
Starlette 1.0 idioms that replace the removed/deprecated pre-1.0 APIs.

- TemplateResponse: use (request, name, context) signature; drop
  request from the context dict (was causing TypeError: unhashable
  type: 'dict' on GET /v1).
- Lifespan handler replaces module-import-time global state
  (BackgroundScheduler, bbagent, usage_data, ref_validator) with
  app.state + FastAPI Depends() injection in dependencies.py.
- Pydantic v2 / FastAPI 0.100+ kwargs: regex= -> pattern=,
  example= -> examples=[...] in data_models.py.
- starlette.responses imports -> fastapi.responses in helpers.py.
- Duplicate endpoint function names renamed (get_bedbase_db_stats x3,
  get_bedset_metadata x3, embed_bed_file x2, get_tokens x2) to
  unblock request.url_for(name=...) lookups.
- HTTPException(status_code=...) calls in bed_api.py get explicit
  detail=; fix return HTTPException(...) -> raise.
- uvicorn.run("bedhost.main:app", ...) import-string form.
- dependencies.py no longer imports from main; fetch_detailed_stats
  takes bbagent as argument.

No version pins added. No backwards-compatibility shims.
When BEDHOST_INIT_ML=false, app.state.ref_validator is None.
Previously analyze_reference_genome would unconditionally call
ref_validator.determine_compatibility, raising AttributeError
and returning 500. Return a clean 503 instead.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 20, 2026

Deploying bedhost-ui with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9d2a7d8
Status:⚡️  Build in progress...

View logs

@khoroshevskyi khoroshevskyi merged commit d325693 into dev Apr 22, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants