Skip to content

Commit

Permalink
perf!: reduce limit paramater to cut latency and avoid timeout
Browse files Browse the repository at this point in the history
BREAKING CHANGE: reduce limit parameter from 1000 to 100
  • Loading branch information
danielnsilva committed Dec 10, 2023
1 parent e5aa367 commit 846e824
Show file tree
Hide file tree
Showing 10 changed files with 56,887 additions and 258,921 deletions.
10 changes: 5 additions & 5 deletions semanticscholar/AsyncSemanticScholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async def get_paper_authors(
self,
paper_id: str,
fields: list = None,
limit: int = 1000
limit: int = 100
) -> PaginatedResults:
'''Get details about a paper's authors
Expand Down Expand Up @@ -211,7 +211,7 @@ async def get_paper_citations(
self,
paper_id: str,
fields: list = None,
limit: int = 1000
limit: int = 100
) -> PaginatedResults:
'''Get details about a paper's citations
Expand Down Expand Up @@ -257,7 +257,7 @@ async def get_paper_references(
self,
paper_id: str,
fields: list = None,
limit: int = 1000
limit: int = 100
) -> PaginatedResults:
'''Get details about a paper's references
Expand Down Expand Up @@ -460,7 +460,7 @@ async def get_author_papers(
self,
author_id: str,
fields: list = None,
limit: int = 1000
limit: int = 100
) -> PaginatedResults:
'''Get details about a author's papers
Expand Down Expand Up @@ -506,7 +506,7 @@ async def search_author(
self,
query: str,
fields: list = None,
limit: int = 1000
limit: int = 100
) -> PaginatedResults:
'''Search for authors by name
Expand Down
10 changes: 5 additions & 5 deletions semanticscholar/SemanticScholar.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def get_paper_authors(
self,
paper_id: str,
fields: list = None,
limit: int = 1000
limit: int = 100
) -> PaginatedResults:
'''Get details about a paper's authors
Expand Down Expand Up @@ -178,7 +178,7 @@ def get_paper_citations(
self,
paper_id: str,
fields: list = None,
limit: int = 1000
limit: int = 100
) -> PaginatedResults:
'''Get details about a paper's citations
Expand Down Expand Up @@ -215,7 +215,7 @@ def get_paper_references(
self,
paper_id: str,
fields: list = None,
limit: int = 1000
limit: int = 100
) -> PaginatedResults:
'''Get details about a paper's references
Expand Down Expand Up @@ -363,7 +363,7 @@ def get_author_papers(
self,
author_id: str,
fields: list = None,
limit: int = 1000
limit: int = 100
) -> PaginatedResults:
'''Get details about a author's papers
Expand Down Expand Up @@ -400,7 +400,7 @@ def search_author(
self,
query: str,
fields: list = None,
limit: int = 1000
limit: int = 100
) -> PaginatedResults:
'''Search for authors by name
Expand Down
24 changes: 12 additions & 12 deletions tests/data/test_get_paper_authors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ interactions:
host:
- api.semanticscholar.org
user-agent:
- python-httpx/0.25.1
- python-httpx/0.25.2
method: GET
uri: https://api.semanticscholar.org/graph/v1/paper/10.2139/ssrn.2250500/authors?fields=affiliations,authorId,citationCount,externalIds,hIndex,homepage,name,paperCount,url&offset=0&limit=1000
uri: https://api.semanticscholar.org/graph/v1/paper/10.2139/ssrn.2250500/authors?fields=affiliations,authorId,citationCount,externalIds,hIndex,homepage,name,paperCount,url&offset=0&limit=100
response:
content: '{"offset": 0, "data": [{"authorId": "2259683", "externalIds": {"DBLP":
["Esther Duflo"]}, "url": "https://www.semanticscholar.org/author/2259683",
"name": "E. Duflo", "affiliations": [], "homepage": null, "paperCount": 292,
"citationCount": 57000, "hIndex": 90}, {"authorId": "2237651454", "externalIds":
"citationCount": 57054, "hIndex": 90}, {"authorId": "2237651454", "externalIds":
{"DBLP": ["Abhijit Banerjee 0001"]}, "url": "https://www.semanticscholar.org/author/2237651454",
"name": "A. Banerjee", "affiliations": [], "homepage": null, "paperCount": 353,
"citationCount": 46347, "hIndex": 90}, {"authorId": "4249203", "externalIds":
"citationCount": 46369, "hIndex": 90}, {"authorId": "4249203", "externalIds":
{}, "url": "https://www.semanticscholar.org/author/4249203", "name": "R. Glennerster",
"affiliations": [], "homepage": null, "paperCount": 112, "citationCount": 8317,
"affiliations": [], "homepage": null, "paperCount": 112, "citationCount": 8322,
"hIndex": 30}, {"authorId": "31549526", "externalIds": {}, "url": "https://www.semanticscholar.org/author/31549526",
"name": "Cynthia Kinnan", "affiliations": [], "homepage": null, "paperCount":
33, "citationCount": 2937, "hIndex": 12}]}
33, "citationCount": 2938, "hIndex": 12}]}
'
headers:
Expand All @@ -39,27 +39,27 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 01 Dec 2023 18:35:40 GMT
- Sun, 10 Dec 2023 21:01:26 GMT
Via:
- 1.1 b32b674425bc91de1120f0cc3dff96dc.cloudfront.net (CloudFront)
- 1.1 8364ca155003e291b521198d3285c5d6.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- LNiqG8Y5WJklxhM_k8Cq36ntPKCj-qQnwXlg5_dFdn00RLrXkyosqw==
- yD5iMtMi0BXZhhsa6PH7Qx5XF-6AcJiCvTkLnm-AAvE2SyIolEgvqA==
X-Amz-Cf-Pop:
- GRU3-P4
X-Cache:
- Miss from cloudfront
x-amz-apigw-id:
- PRsbfHlYvHcEoIA=
- PvsOCFmCvHcEv-w=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '965'
x-amzn-Remapped-Date:
- Fri, 01 Dec 2023 18:35:40 GMT
- Sun, 10 Dec 2023 21:01:26 GMT
x-amzn-Remapped-Server:
- gunicorn
x-amzn-RequestId:
- da49e047-e03c-48db-9b18-4338c178ea6b
- abf6429a-9057-435a-b8ba-d3804b7864fc
http_version: HTTP/1.1
status_code: 200
version: 1
24 changes: 12 additions & 12 deletions tests/data/test_get_paper_authors_async.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ interactions:
host:
- api.semanticscholar.org
user-agent:
- python-httpx/0.25.1
- python-httpx/0.25.2
method: GET
uri: https://api.semanticscholar.org/graph/v1/paper/10.2139/ssrn.2250500/authors?fields=affiliations,authorId,citationCount,externalIds,hIndex,homepage,name,paperCount,url&offset=0&limit=1000
uri: https://api.semanticscholar.org/graph/v1/paper/10.2139/ssrn.2250500/authors?fields=affiliations,authorId,citationCount,externalIds,hIndex,homepage,name,paperCount,url&offset=0&limit=100
response:
content: '{"offset": 0, "data": [{"authorId": "2259683", "externalIds": {"DBLP":
["Esther Duflo"]}, "url": "https://www.semanticscholar.org/author/2259683",
"name": "E. Duflo", "affiliations": [], "homepage": null, "paperCount": 292,
"citationCount": 57000, "hIndex": 90}, {"authorId": "2237651454", "externalIds":
"citationCount": 57054, "hIndex": 90}, {"authorId": "2237651454", "externalIds":
{"DBLP": ["Abhijit Banerjee 0001"]}, "url": "https://www.semanticscholar.org/author/2237651454",
"name": "A. Banerjee", "affiliations": [], "homepage": null, "paperCount": 353,
"citationCount": 46347, "hIndex": 90}, {"authorId": "4249203", "externalIds":
"citationCount": 46369, "hIndex": 90}, {"authorId": "4249203", "externalIds":
{}, "url": "https://www.semanticscholar.org/author/4249203", "name": "R. Glennerster",
"affiliations": [], "homepage": null, "paperCount": 112, "citationCount": 8317,
"affiliations": [], "homepage": null, "paperCount": 112, "citationCount": 8322,
"hIndex": 30}, {"authorId": "31549526", "externalIds": {}, "url": "https://www.semanticscholar.org/author/31549526",
"name": "Cynthia Kinnan", "affiliations": [], "homepage": null, "paperCount":
33, "citationCount": 2937, "hIndex": 12}]}
33, "citationCount": 2938, "hIndex": 12}]}
'
headers:
Expand All @@ -39,27 +39,27 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 01 Dec 2023 18:35:28 GMT
- Sun, 10 Dec 2023 21:28:16 GMT
Via:
- 1.1 bfa23c0b5661b8c601e9ec8121a9d6ca.cloudfront.net (CloudFront)
- 1.1 7d4cada96f0b733f4f539a3bab2e2d16.cloudfront.net (CloudFront)
X-Amz-Cf-Id:
- nLddkyLgdFp59gLnGfeXqlzeCPgY2ZMxGnHDIUzaRfRi7XqRg0aqPQ==
- V2aqwULTjc_jZjBZO4NlBsactfRxOfGY_ptr4esxn948E86PBtcpIQ==
X-Amz-Cf-Pop:
- GRU3-P4
X-Cache:
- Miss from cloudfront
x-amz-apigw-id:
- PRsZmEhvPHcEnYA=
- PvwJpE51vHcEnSw=
x-amzn-Remapped-Connection:
- keep-alive
x-amzn-Remapped-Content-Length:
- '965'
x-amzn-Remapped-Date:
- Fri, 01 Dec 2023 18:35:28 GMT
- Sun, 10 Dec 2023 21:28:16 GMT
x-amzn-Remapped-Server:
- gunicorn
x-amzn-RequestId:
- c37a52b0-e915-4a4b-8770-f8d4e3759689
- ef155fe2-0751-4d05-9d83-a5734d8b8de6
http_version: HTTP/1.1
status_code: 200
version: 1
Loading

0 comments on commit 846e824

Please sign in to comment.