Skip to content

Commit

Permalink
Merge branch 'main' into HDXDSYS-843-add-dtm
Browse files Browse the repository at this point in the history
  • Loading branch information
turnerm committed Sep 19, 2024
2 parents 8d147f1 + 8dd2e14 commit 155a9aa
Show file tree
Hide file tree
Showing 22 changed files with 98 additions and 171 deletions.
26 changes: 25 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,36 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [0.10.0] - 2024-09-12
## [0.10.0] - 2024-09-19

### Added

- IDP scraper

## [0.9.58] - 2024-09-18

### Fixed

- Fix for TCD population dataset change (again)

## [0.9.57] - 2024-09-17

### Added

- Info on IPC country processing

## [0.9.56] - 2024-09-17

### Fixed

- Fix for TCD population dataset change

## [0.9.55] - 2024-09-17

### Fixed

- Changes in HDX Python Scraper package names

## [0.9.54] - 2024-09-12

### Fixed
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ requires-python = ">=3.8"

dependencies = [
"hapi-schema>=0.8.17",
"hdx-python-api>= 6.3.2",
"hdx-python-country>= 3.7.7",
"hdx-python-api>= 6.3.4",
"hdx-python-country>= 3.7.8",
"hdx-python-database[postgresql]>= 1.3.1",
"hdx-python-scraper>= 2.4.1",
"hdx-python-scraper>= 2.5.0",
"hdx-python-utilities>= 3.7.3",
"libhxl",
"sqlalchemy"
Expand Down
4 changes: 2 additions & 2 deletions src/hapi/pipelines/app/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
get_params_from_connection_uri,
)
from hdx.facades.keyword_arguments import facade
from hdx.scraper.utilities import string_params_to_dict
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities import string_params_to_dict
from hdx.scraper.framework.utilities.reader import Read
from hdx.utilities.dateparse import now_utc
from hdx.utilities.dictandlist import args_to_dict
from hdx.utilities.easy_logging import setup_logging
Expand Down
4 changes: 2 additions & 2 deletions src/hapi/pipelines/app/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

from hdx.api.configuration import Configuration
from hdx.location.adminlevel import AdminLevel
from hdx.scraper.runner import Runner
from hdx.scraper.utilities.sources import Sources
from hdx.scraper.framework.runner import Runner
from hdx.scraper.framework.utilities.sources import Sources
from hdx.utilities.errors_onexit import ErrorsOnExit
from hdx.utilities.typehint import ListTuple
from sqlalchemy.orm import Session
Expand Down
43 changes: 12 additions & 31 deletions src/hapi/pipelines/configs/population.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -945,14 +945,15 @@ population_national:

population_tcd:
dataset: "cod-ps-tcd"
resource: "tcd_admpop_adm0_2021.csv"
format: "csv"
resource: "tcd_admpop_2023.xlsx"
format: "xlsx"
sheet: "tcd_admpop_adm0_2023"
use_hxl: False
admin_single: "TCD"
input:
- "F_80PLUS"
- "M_80PLUS"
- "T_80PLUS"
- "F_80Plus"
- "M_80Plus"
- "T_80Plus"
output:
- "F_80plus"
- "M_80plus"
Expand Down Expand Up @@ -1913,16 +1914,17 @@ population_adminone:

population_tcd:
dataset: "cod-ps-tcd"
resource: "tcd_admpop_adm1_2021.csv"
format: "csv"
resource: "tcd_admpop_2023.xlsx"
format: "xlsx"
sheet: "tcd_admpop_adm1_2023"
use_hxl: False
admin:
- ~
- "ADM1_PCODE"
input:
- "F_80PLUS"
- "M_80PLUS"
- "T_80PLUS"
- "F_80Plus"
- "M_80Plus"
- "T_80Plus"
output:
- "F_80plus"
- "M_80plus"
Expand Down Expand Up @@ -2798,27 +2800,6 @@ population_admintwo:
- "#population+m+age_61_plus"
- "#population+age_61_plus+total"

population_tcd:
dataset: "cod-ps-tcd"
resource: "tcd_admpop_adm2_2021.csv"
format: "csv"
use_hxl: False
admin:
- ~
- "ADM2_PCODE"
input:
- "F_80PLUS"
- "M_80PLUS"
- "T_80PLUS"
output:
- "F_80plus"
- "M_80plus"
- "T_80plus"
output_hxl:
- "#population+f+age_80_plus"
- "#population+m+age_80_plus"
- "#population+age_80_plus+total"

population_ven:
dataset: "cod-ps-ven"
resource: "ven_admpop_adm2_2011_v3.csv"
Expand Down
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/currency.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from hapi_schema.db_currency import DBCurrency
from hdx.api.configuration import Configuration
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities.reader import Read
from sqlalchemy.orm import Session

from .base_uploader import BaseUploader
Expand Down
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/food_price.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from dateutil.relativedelta import relativedelta
from hapi_schema.db_food_price import DBFoodPrice
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities.reader import Read
from hdx.utilities.dateparse import parse_date
from sqlalchemy.orm import Session

Expand Down
21 changes: 20 additions & 1 deletion src/hapi/pipelines/database/food_security.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from hapi_schema.db_food_security import DBFoodSecurity
from hdx.api.configuration import Configuration
from hdx.location.adminlevel import AdminLevel
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities.reader import Read
from hdx.utilities.dateparse import parse_date
from hdx.utilities.typehint import ListTuple
from sqlalchemy.orm import Session
Expand Down Expand Up @@ -45,6 +45,7 @@ def __init__(
self._adminone = adminone
self._admintwo = admintwo
self._configuration = configuration
self._country_status = {}

@staticmethod
def get_admin_level_from_resource_name(
Expand Down Expand Up @@ -220,6 +221,9 @@ def process_subnational(
if admin_level == "adminone":
return None
adminoneinfo = AdminInfo(countryiso3, "NOT GIVEN", "", None, False)
self._country_status[countryiso3] = (
"Level 1: ignored, Area: Admin 2"
)
return self.get_admintwo_admin2_ref(
food_sec_config,
warnings,
Expand Down Expand Up @@ -261,6 +265,9 @@ def process_subnational(
)
if not adminoneinfo:
return None
self._country_status[countryiso3] = (
"Level 1: ignored, Area: Admin 1"
)
return self.get_adminone_admin2_ref(
food_sec_config,
warnings,
Expand All @@ -278,6 +285,14 @@ def process_subnational(
)
if not adminoneinfo:
return None
if countryiso3 in food_sec_config["adm1_only"]:
self._country_status[countryiso3] = (
"Level 1: Admin 1, Area: ignored"
)
else:
self._country_status[countryiso3] = (
"Level 1: Admin 1, Area: Admin 2"
)
if admin_level == "adminone":
return self.get_adminone_admin2_ref(
food_sec_config, warnings, errors, dataset_name, adminoneinfo
Expand Down Expand Up @@ -355,3 +370,7 @@ def populate(self) -> None:
logger.warning(warning)
for error in sorted(errors):
logger.error(error)
logger.info(f"{dataset_name} - Country Status")
for countryiso3 in sorted(self._country_status):
status = self._country_status[countryiso3]
logger.info(f"{countryiso3}: {status}")
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/humanitarian_needs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from hapi_schema.db_humanitarian_needs import DBHumanitarianNeeds
from hdx.api.configuration import Configuration
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities.reader import Read
from hdx.utilities.dictandlist import dict_of_lists_add
from hdx.utilities.text import get_numeric_if_possible
from sqlalchemy.orm import Session
Expand Down
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from hapi_schema.db_location import DBLocation
from hdx.api.configuration import Configuration
from hdx.location.country import Country
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities.reader import Read
from hdx.utilities.dateparse import parse_date
from sqlalchemy.orm import Session

Expand Down
4 changes: 2 additions & 2 deletions src/hapi/pipelines/database/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
from hapi_schema.db_resource import DBResource
from hdx.data.dataset import Dataset
from hdx.data.resource import Resource
from hdx.scraper.runner import Runner
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.runner import Runner
from hdx.scraper.framework.utilities.reader import Read
from sqlalchemy.orm import Session

from .base_uploader import BaseUploader
Expand Down
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import Dict, NamedTuple

from hapi_schema.db_org import DBOrg
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities.reader import Read
from hdx.utilities.dictandlist import write_list_to_csv
from hdx.utilities.text import normalise
from sqlalchemy.orm import Session
Expand Down
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/org_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Dict

from hapi_schema.db_org_type import DBOrgType
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities.reader import Read
from hdx.utilities.text import normalise
from sqlalchemy.orm import Session

Expand Down
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/sector.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import Dict

from hapi_schema.db_sector import DBSector
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities.reader import Read
from hdx.utilities.text import normalise
from sqlalchemy.orm import Session

Expand Down
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/wfp_commodity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from hapi_schema.db_wfp_commodity import DBWFPCommodity
from hapi_schema.utils.enums import CommodityCategory
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities.reader import Read
from sqlalchemy.orm import Session

from .base_uploader import BaseUploader
Expand Down
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/wfp_market.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from hapi_schema.db_wfp_market import DBWFPMarket
from hdx.location.adminlevel import AdminLevel
from hdx.scraper.utilities.reader import Read
from hdx.scraper.framework.utilities.reader import Read
from hdx.utilities.dictandlist import dict_of_dicts_add
from sqlalchemy.orm import Session

Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/input/cod-ps-tcd.json

Large diffs are not rendered by default.

Binary file not shown.
2 changes: 0 additions & 2 deletions tests/fixtures/input/population_tcd_tcd_admpop_adm0_2021.csv

This file was deleted.

24 changes: 0 additions & 24 deletions tests/fixtures/input/population_tcd_tcd_admpop_adm1_2021.csv

This file was deleted.

Loading

0 comments on commit 155a9aa

Please sign in to comment.