Skip to content

Commit

Permalink
Merge pull request #140 from Clinical-Genomics/deprecate_on_event
Browse files Browse the repository at this point in the history
Deprecate on event and replace it with app lifespan
  • Loading branch information
northwestwitch authored Nov 21, 2024
2 parents 798a288 + 3d1a7b6 commit b06e142
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Removed the example of an old json submission (before 2022-11-21)
- Updated actions using the latest base images and to run using Python 3.9
- Docker image uses Python 3.11 instead of 3.8
- Replaced deprecated app "on event" with app lifespan
### Fixed
- Updated issue templates
- Updated a number of libraries to address all current security advisories
Expand Down
11 changes: 7 additions & 4 deletions preClinVar/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import json
import logging
import re
from contextlib import asynccontextmanager
from typing import List

import requests
Expand All @@ -16,16 +17,18 @@

LOG = logging.getLogger("uvicorn.access")

app = FastAPI()


@app.on_event("startup")
async def startup_event():
@asynccontextmanager
async def lifespan(app_: FastAPI):
LOG = logging.getLogger("uvicorn.access")
console_formatter = uvicorn.logging.ColourizedFormatter(
"{levelprefix} {asctime} : {message}", style="{", use_colors=True
)
LOG.handlers[0].setFormatter(console_formatter)
yield


app = FastAPI(lifespan=lifespan)


@app.get("/")
Expand Down

0 comments on commit b06e142

Please sign in to comment.