Skip to content

Commit

Permalink
Merge pull request #2 from colin-combe/python3
Browse files Browse the repository at this point in the history
speedup json encoding (?) using orjson lib
  • Loading branch information
sureshhewabi authored Feb 8, 2024
2 parents d1681be + 11cf435 commit 47820f8
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 9 deletions.
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ psycopg2-binary = "*"
sqlalchemy = "2.0.21"
sqlalchemy-utils = "*"
obonet = "*"
orjson = "*"
#Security modules
python-multipart = "*"
python-jose = "*"
Expand Down
66 changes: 61 additions & 5 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions app/routes/pdbdev.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import json

import psycopg2
from fastapi import APIRouter, Depends, Path
from fastapi import APIRouter, Depends, Path, Response
import orjson
from fastapi import APIRouter, Depends
from psycopg2.extras import RealDictCursor
import logging
from sqlalchemy import text
Expand Down Expand Up @@ -165,7 +167,7 @@ async def get_psm_level_residue_pairs(project_id: Annotated[str, Path(...,
if conn is not None:
conn.close()
print('Database connection closed.')
return data
return Response(orjson.dumps(data), media_type='application/json')

#
# @pdb_dev_router.get('/projects/{project_id}/residue-pairs/reported')
Expand Down
5 changes: 3 additions & 2 deletions app/routes/xiview.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

import fastapi
import psycopg2
from fastapi import APIRouter, Depends, Request
from fastapi import APIRouter, Depends, Request, Response
import orjson
from psycopg2 import sql
from psycopg2.extras import RealDictCursor
from sqlalchemy.orm import session, Session
Expand Down Expand Up @@ -117,7 +118,7 @@ async def get_data_object(ids, pxid):
logger.debug('Database connection closed.')
if error is not None:
raise error
return data
return Response(orjson.dumps(data), media_type='application/json')


async def get_pride_api_info(cur, pxid):
Expand Down

0 comments on commit 47820f8

Please sign in to comment.