Skip to content

Commit

Permalink
HDXDSYS-1027 Summarise HAPI pipelines food security country handling (#…
Browse files Browse the repository at this point in the history
…161)

* Output country status for food security

* Fix test

* Update changelog
  • Loading branch information
mcarans authored Sep 16, 2024
1 parent d2487db commit de183c2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ 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.9.57] - 2024-09-17

### Added

- Info on IPC country processing

## [0.9.56] - 2024-09-17

### Fixed
Expand Down
19 changes: 19 additions & 0 deletions src/hapi/pipelines/database/food_security.py
Original file line number Diff line number Diff line change
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}")

0 comments on commit de183c2

Please sign in to comment.