Skip to content

Commit

Permalink
Revert "Merge branch 'age_range_yaml' into main"
Browse files Browse the repository at this point in the history
This reverts commit 5a6aa11, reversing
changes made to 008ba0d.
  • Loading branch information
Mike committed Dec 14, 2023
1 parent 5a6aa11 commit c862da9
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 33 deletions.
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ greenlet==3.0.2
# via sqlalchemy
gspread==5.12.2
# via hdx-python-scraper
hapi-schema @ git+ssh://[email protected]/OCHA-DAP/hapi-sqlalchemy-schema@hno_table
hapi-schema==0.4.0
# via hapi-pipelines (pyproject.toml)
hdx-python-api==6.1.4
# via hdx-python-scraper
Expand Down
4 changes: 1 addition & 3 deletions src/hapi/pipelines/app/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,7 @@ def __init__(
session=session,
gender_descriptions=configuration["gender_descriptions"],
)
self.age_range = AgeRange(
session=session, age_range_codes=configuration["age_range_codes"]
)
self.age_range = AgeRange(session=session)

self.ipc_phase = IpcPhase(
session=session,
Expand Down
19 changes: 0 additions & 19 deletions src/hapi/pipelines/configs/core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,6 @@ gender_descriptions:
m: "male"
x: "non-binary"

age_range_codes:
- "0-4"
- "10-14"
- "15-19"
- "20-24"
- "25-29"
- "30-34"
- "35-39"
- "40-44"
- "45-49"
- "5-9"
- "50-54"
- "55-59"
- "60-64"
- "65-69"
- "70-74"
- "75-79"
- "80+"

sector:
dataset: "global-coordination-groups-beta"
resource: "Global Coordination Groups (Beta) CSV"
Expand Down
9 changes: 2 additions & 7 deletions src/hapi/pipelines/database/age_range.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import logging
from typing import List

from hapi_schema.db_age_range import DBAgeRange
from sqlalchemy.orm import Session
Expand All @@ -10,16 +9,12 @@


class AgeRange(BaseUploader):
def __init__(self, session: Session, age_range_codes: List[str]):
def __init__(self, session: Session):
super().__init__(session)
self._age_range_codes = age_range_codes
self.data = []

def populate(self):
logger.info("Populating age ranges table")
for age_range_code in self._age_range_codes:
self.populate_single(age_range_code)
self._session.commit()
raise NotImplementedError()

def populate_single(self, age_range_code: str):
logger.info(f"Adding age range code {age_range_code}")
Expand Down
2 changes: 1 addition & 1 deletion src/hapi/pipelines/database/operational_presence.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def populate(self):
rows.append(row)
operational_presence_row = DBOperationalPresence(
resource_ref=resource_ref,
admin2_ref=admin2_ref,
org_ref=org_ref,
sector_code=sector_code,
admin2_ref=admin2_ref,
reference_period_start=reference_period_start,
reference_period_end=reference_period_end,
# TODO: Add to scraper (HAPI-199)
Expand Down
4 changes: 2 additions & 2 deletions src/hapi/pipelines/database/population.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ def populate(self):
age_range_code is not None
and age_range_code not in self._age_range.data
):
raise ValueError(
f"Age range code {age_range_code} not in table"
self._age_range.populate_single(
age_range_code=age_range_code
)
for admin_code, value in values.items():
admin2_code = admins.get_admin2_code_based_on_level(
Expand Down

0 comments on commit c862da9

Please sign in to comment.