This commit is contained in:
2025-01-05 17:43:06 +08:00
parent f214f51e12
commit 5380ee5f9e
4 changed files with 169 additions and 64 deletions

View File

@@ -11,7 +11,7 @@ import logging
from mp_api.client import MPRester
from multiprocessing import Process, Manager
from typing import Dict, Any, List
from constant import MP_API_KEY, TIME_OUT, TOPK_RESULT
from constant import MP_ENDPOINT, MP_API_KEY, TIME_OUT, TOPK_RESULT
router = APIRouter(prefix="/mp", tags=["Material Project"])
@@ -156,7 +156,7 @@ async def execute_search(search_args: Dict[str, Any], timeout: int = TIME_OUT) -
def _search_worker(queue, api_key, **kwargs):
"""搜索工作线程"""
try:
mpr = MPRester(api_key)
mpr = MPRester(api_key, endpoint=MP_ENDPOINT)
result = mpr.materials.summary.search(**kwargs)
queue.put([doc.model_dump() for doc in result])
except Exception as e: