-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
55 lines (46 loc) · 1.81 KB
/
run.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
46
47
48
49
50
51
52
53
54
55
import logging
from os.path import join
from hdx.api.configuration import Configuration
from hdx.data.dataset import Dataset
from hdx.facades.keyword_arguments import facade
from hdx.utilities.downloader import Download
from hdx.utilities.easy_logging import setup_logging
from hdx.utilities.path import temp_dir
from hdx.utilities.retriever import Retrieve
from check_location import get_global_pcodes, process_resource
setup_logging()
logger = logging.getLogger(__name__)
def main(**ignore):
configuration = Configuration.read()
with temp_dir(folder="TempPCodeDetector") as temp_folder:
with Download(rate_limit={"calls": 1, "period": 0.1}) as downloader:
retriever = Retrieve(
downloader, temp_folder, "saved_data", temp_folder, save=False, use_saved=False
)
global_pcodes, global_miscodes = get_global_pcodes(
configuration["global_pcodes"],
retriever,
)
datasets = Dataset.get_all_datasets(rows=100)
for dataset in datasets:
resources = dataset.get_resources()
for resource in resources:
pcoded, mis_pcoded = process_resource(
resource,
dataset,
global_pcodes,
global_miscodes,
retriever,
configuration,
update=False,
)
logger.info(f"{resource['name']}: {pcoded}, {mis_pcoded}")
if __name__ == "__main__":
facade(
main,
hdx_site="feature",
user_agent="LocationExploration",
hdx_read_only=False,
preprefix="HDXINTERNAL",
project_config_yaml=join("config", "project_configuration.yml"),
)