Skip to content

Commit e1365d0

Browse files
committed
robustify
1 parent 4fac997 commit e1365d0

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

paperscraper/citations/entity/researcher.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import asyncio
22
import os
33
from typing import Any, List, Literal, Optional, Tuple
4+
from time import sleep
45

56
from semanticscholar import SemanticScholar
67

@@ -90,6 +91,8 @@ async def _self_references_async(
9091
self, verbose: bool = False
9192
) -> List[ReferenceResult]:
9293
"""Async version of self_references."""
94+
if self.ssid == '-1':
95+
return []
9396
self.ssids = await get_papers_for_author(self.ssid)
9497

9598
results: List[ReferenceResult] = await self_references_paper(

paperscraper/citations/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ async def get_title_and_id_from_doi(doi: str) -> Dict[str, str] | None:
111111

112112

113113
@optional_async
114-
async def author_name_to_ssaid(author_name: str) -> Optional[Tuple[str, str]]:
114+
@retry_with_exponential_backoff(max_retries=10, base_delay=1.0)
115+
async def author_name_to_ssaid(author_name: str) -> Tuple[str, str]:
115116
"""
116117
Given an author name, returns the Semantic Scholar author ID.
117118
@@ -138,6 +139,7 @@ async def author_name_to_ssaid(author_name: str) -> Optional[Tuple[str, str]]:
138139
logger.error(
139140
f"Error in retrieving name from SS Author ID: {response.status_code} - {response.text}"
140141
)
142+
return ('-1', 'N.A.')
141143

142144

143145
def determine_paper_input_type(input: str) -> Literal["ssid", "doi", "title"]:

0 commit comments

Comments
 (0)