Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ncbi tests #86

Merged
merged 22 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions semantic_search/ncbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
from pathlib import Path
from typing import Any, Dict, List, Generator
import logging
import json
import time

import requests
from Bio import Medline
from dotenv import load_dotenv
from pydantic import BaseSettings
from fastapi import HTTPException

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -99,8 +99,7 @@ def _medline_to_docs(records: List[Dict[str, str]]) -> List[Dict[str, str]]:
docs = []
for record in records:
if "PMID" not in record:
logging.warn(f"No PMID for {json.dumps(record)}")
continue
raise HTTPException(status_code=422, detail=record["id:"][-1])
pmid = record["PMID"]
abstract = record["AB"] if "AB" in record else ""
title = record["TI"] if "TI" in record else ""
Expand Down
54 changes: 54 additions & 0 deletions tests/test_ncbi.py

Large diffs are not rendered by default.