Skip to content

Commit

Permalink
Add back in synth client
Browse files Browse the repository at this point in the history
  • Loading branch information
munrojm committed Jun 14, 2021
1 parent 6893679 commit 2b5663a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
24 changes: 22 additions & 2 deletions src/mp_api/routes/synthesis/client.py
@@ -1,8 +1,28 @@
from mp_api.core.client import BaseRester
from mp_api.routes.synthesis.models import SynthesisRecipe
from mp_api.routes.synthesis.models import SynthesisSearchResultModel
from typing import List


class SynthesisRester(BaseRester):

suffix = "synthesis"
document_model = SynthesisRecipe
document_model = SynthesisSearchResultModel # type: ignore

def search_synthesis_text(self, keywords: List[str]):
"""
Search synthesis recipe text.
Arguments:
keywords (List[str]): List of search keywords
Returns:
synthesis_docs ([SynthesisDoc]): List of synthesis documents
"""

keyword_string = ",".join(keywords)

synthesis_docs = self._query_resource(
criteria={"keywords": keyword_string},
suburl="text_search",
use_document_model=True,
)

return synthesis_docs
13 changes: 9 additions & 4 deletions src/mp_api/routes/synthesis/client.pyi
@@ -1,8 +1,13 @@
from typing import List
from mp_api.routes.synthesis.models import SynthesisRecipe
from typing import List, Optional
from mp_api.routes.synthesis.models import SynthesisSearchResultModel


class SynthesisRester:

def query_text(self, keywords: List[str]) -> SynthesisRecipe:
...
def get_document_by_id(
self,
document_id: str,
fields: Optional[List[str]] = None,
monty_decode: bool = True,
version: Optional[str] = None,
) -> SynthesisSearchResultModel: ...

0 comments on commit 2b5663a

Please sign in to comment.