-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathupload.py
45 lines (36 loc) · 1.79 KB
/
upload.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import biothings.hub.dataload.uploader
import os
import biothings
import config
import requests
biothings.config_for_app(config)
MAP_URL = "https://raw.githubusercontent.com/SuLab/outbreak.info-resources/master/outbreak_resources_es_mapping.json"
MAP_VARS = ["@type", "abstract", "alternateName", "armGroup", "author", "curatedBy", "date", "dateCreated", "dateModified", "datePublished", "description", "eligibilityCriteria", "hasResults", "healthCondition", "identifier", "identifierSource", "interventions", "interventionText", "isBasedOn", "keywords", "name", "outcome", "relatedTo", "funding", "studyDesign", "studyEvent", "studyLocation", "studyStatus", "url", "topicCategory"]
# when code is exported, import becomes relative
try:
from covid_who_clinical_trials.parser import load_annotations as parser_func
except ImportError:
from .parser import load_annotations as parser_func
logger = config.logger
class ClinicalTrialUploaderWHO(biothings.hub.dataload.uploader.BaseSourceUploader):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
logger.warning("trial upload before crash")
main_source = "covid_who_clinical_trials"
name = "clinicaltrialswho"
__metadata__ = {"src_meta": {
"license_url": "https://www.who.int/about/who-we-are/publishing-policies/copyright",
"url": "https://www.who.int/ictrp/en/"
}}
idconverter = None
def load_data(self, data_folder):
if data_folder:
self.logger.info("Load data from directory: '%s'", data_folder)
return parser_func()
@classmethod
def get_mapping(klass):
r = requests.get(MAP_URL)
if(r.status_code == 200):
mapping = r.json()
mapping_dict = { key: mapping[key] for key in MAP_VARS }
return mapping_dict