Skip to content

Commit

Permalink
commit this
Browse files Browse the repository at this point in the history
  • Loading branch information
jsstevenson committed Aug 5, 2024
1 parent aa90292 commit ce5138b
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions server/src/curfu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,21 @@
validate,
)


@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncGenerator:
"""Configure FastAPI instance lifespan.
:param app: FastAPI app instance
:return: async context handler
"""
app.state.fusor = await start_fusor()
app.state.genes = get_gene_services()
app.state.domains = get_domain_services()
yield
await app.state.fusor.cool_seq_tool.uta_db._connection_pool.close() # noqa: SLF001


fastapi_app = FastAPI(
title="Fusion Curation API",
description="Provide data functions to support [VICC Fusion Curation interface](fusion-builder.cancervariants.org/).",
Expand All @@ -41,6 +56,7 @@
swagger_ui_parameters={"tryItOutEnabled": True},
docs_url="/docs",
openapi_url="/openapi.json",
lifespan=lifespan,
)

fastapi_app.include_router(utilities.router)
Expand Down Expand Up @@ -125,17 +141,3 @@ def get_domain_services() -> DomainService:
domain_service = DomainService()
domain_service.load_mapping()
return domain_service


@asynccontextmanager
async def lifespan(app: FastAPI) -> AsyncGenerator:
"""Configure FastAPI instance lifespan.
:param app: FastAPI app instance
:return: async context handler
"""
app.state.fusor = await start_fusor()
app.state.genes = get_gene_services()
app.state.domains = get_domain_services()
yield
await app.state.fusor.cool_seq_tool.uta_db._connection_pool.close() # noqa: SLF001

0 comments on commit ce5138b

Please sign in to comment.