@@ -88,25 +88,28 @@ class JournalQuery(ClientQuery):
8888
8989
9090class MetadataProvider (ABC , Generic [ClientQueryType ]):
91- """Provide metadata from a query by any means necessary."""
91+ """Provide metadata from a query by any means necessary.
92+
93+ An example is going from a DOI to full paper metadata using Semantic Scholar.
94+ """
9295
9396 async def query (self , query : dict ) -> DocDetails | None :
94- return await self ._query (self .query_transformer (query ))
97+ return await self ._query (self .query_factory (query ))
9598
9699 @abstractmethod
97100 async def _query (self , query : ClientQueryType ) -> DocDetails | None :
98- pass
101+ """Run a query against the provider."""
99102
100103 @abstractmethod
101- def query_transformer (self , query : dict ) -> ClientQueryType :
102- pass
104+ def query_factory (self , query : dict ) -> ClientQueryType :
105+ """Create a query object from unstructured query data."""
103106
104107
105108class DOIOrTitleBasedProvider (MetadataProvider [DOIQuery | TitleAuthorQuery ]):
106109
107110 async def query (self , query : dict ) -> DocDetails | None :
108111 try :
109- client_query = self .query_transformer (query )
112+ client_query = self .query_factory (query )
110113 return await self ._query (client_query )
111114 # We allow graceful failures, i.e. return "None" for both DOI errors and timeout errors
112115 # DOINotFoundError means the paper doesn't exist in the source, the timeout is to prevent
@@ -150,7 +153,7 @@ async def _query(self, query: DOIQuery | TitleAuthorQuery) -> DocDetails | None:
150153 TimeoutError: When the request takes too long on the client side
151154 """
152155
153- def query_transformer (self , query : dict ) -> DOIQuery | TitleAuthorQuery :
156+ def query_factory (self , query : dict ) -> DOIQuery | TitleAuthorQuery :
154157 try :
155158 if "doi" in query :
156159 return DOIQuery (** query )
@@ -169,7 +172,6 @@ class MetadataPostProcessor(ABC, Generic[ClientQueryType]):
169172
170173 MetadataPostProcessor should be idempotent and not order-dependent, i.e.
171174 all MetadataPostProcessor instances should be able to run in parallel.
172-
173175 """
174176
175177 async def process (self , doc_details : DocDetails , ** kwargs ) -> DocDetails :
0 commit comments