Skip to content

Commit

Permalink
HDXDSYS-1125 Fix test failures due to admin retriever change (#179)
Browse files Browse the repository at this point in the history
* Fix tests

* Latest HDX Python Country

* Add changelog
  • Loading branch information
mcarans authored Oct 7, 2024
1 parent a19efdd commit 05aab02
Show file tree
Hide file tree
Showing 7 changed files with 32,050 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .config/pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ repos:
- id: end-of-file-fixer
- id: check-ast
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.5
rev: v0.6.9
hooks:
# Run the linter.
- id: ruff
Expand All @@ -17,7 +17,7 @@ repos:
- id: ruff-format
args: [--config, .config/ruff.toml]
- repo: https://github.com/astral-sh/uv-pre-commit
rev: 0.2.31
rev: 0.4.18
hooks:
# Run the pip compile
- id: pip-compile
Expand Down
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.10.4] - 2024-10-07

### Fixed

- Fix broken tests

## [0.10.3] - 2024-09-24

### Changed
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ requires-python = ">=3.8"
dependencies = [
"hapi-schema>=0.8.17",
"hdx-python-api>= 6.3.4",
"hdx-python-country>= 3.7.8",
"hdx-python-country>= 3.8.1",
"hdx-python-database[postgresql]>= 1.3.1",
"hdx-python-scraper>= 2.5.0",
"hdx-python-utilities>= 3.7.3",
"hdx-python-utilities>= 3.7.4",
"libhxl",
"sqlalchemy"
]
Expand Down
26 changes: 13 additions & 13 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ defopt==6.4.0
# via hdx-python-api
distlib==0.3.8
# via virtualenv
dnspython==2.6.1
dnspython==2.7.0
# via email-validator
docopt==0.6.2
# via
Expand All @@ -42,7 +42,7 @@ et-xmlfile==1.1.0
# via openpyxl
filelock==3.16.1
# via virtualenv
frictionless==5.17.1
frictionless==5.18.0
# via hdx-python-utilities
google-auth==2.35.0
# via
Expand All @@ -52,15 +52,15 @@ google-auth-oauthlib==1.2.1
# via gspread
greenlet==3.1.1
# via sqlalchemy
gspread==6.1.2
gspread==6.1.3
# via hdx-python-scraper
hapi-schema==0.8.17
# via hapi-pipelines (pyproject.toml)
hdx-python-api==6.3.4
# via
# hapi-pipelines (pyproject.toml)
# hdx-python-scraper
hdx-python-country==3.7.8
hdx-python-country==3.8.1
# via
# hapi-pipelines (pyproject.toml)
# hdx-python-api
Expand All @@ -69,13 +69,13 @@ hdx-python-database==1.3.3
# via hapi-pipelines (pyproject.toml)
hdx-python-scraper==2.5.0
# via hapi-pipelines (pyproject.toml)
hdx-python-utilities==3.7.3
hdx-python-utilities==3.7.4
# via
# hapi-pipelines (pyproject.toml)
# hdx-python-api
# hdx-python-country
# hdx-python-scraper
humanize==4.10.0
humanize==4.11.0
# via frictionless
identify==2.6.1
# via pre-commit
Expand Down Expand Up @@ -110,7 +110,7 @@ libhxl==5.2.1
# hdx-python-country
loguru==0.7.2
# via hdx-python-utilities
makefun==1.15.4
makefun==1.15.6
# via hdx-python-api
markdown-it-py==3.0.0
# via rich
Expand Down Expand Up @@ -144,11 +144,11 @@ ply==3.11
# libhxl
pockets==0.9.1
# via sphinxcontrib-napoleon
pre-commit==3.8.0
pre-commit==4.0.0
# via hapi-pipelines (pyproject.toml)
psycopg==3.2.2
psycopg==3.2.3
# via hdx-python-database
psycopg-binary==3.2.2
psycopg-binary==3.2.3
# via psycopg
pyasn1==0.6.1
# via
Expand Down Expand Up @@ -216,7 +216,7 @@ requests-oauthlib==2.0.0
# via google-auth-oauthlib
rfc3986==2.0.0
# via frictionless
rich==13.8.1
rich==13.9.2
# via typer
rpds-py==0.20.0
# via
Expand All @@ -232,7 +232,7 @@ setuptools==75.1.0
# via ckanapi
shellingham==1.5.4
# via typer
simpleeval==0.9.13
simpleeval==1.0.0
# via frictionless
simplejson==3.19.3
# via ckanapi
Expand Down Expand Up @@ -283,7 +283,7 @@ urllib3==2.2.3
# requests
validators==0.34.0
# via frictionless
virtualenv==20.26.5
virtualenv==20.26.6
# via pre-commit
wheel==0.44.0
# via libhxl
Expand Down
17 changes: 14 additions & 3 deletions src/hapi/pipelines/app/pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from hdx.api.configuration import Configuration
from hdx.location.adminlevel import AdminLevel
from hdx.scraper.framework.runner import Runner
from hdx.scraper.framework.utilities.reader import Read
from hdx.scraper.framework.utilities.sources import Sources
from hdx.utilities.errors_onexit import ErrorsOnExit
from hdx.utilities.typehint import ListTuple
Expand Down Expand Up @@ -54,7 +55,13 @@ def __init__(
use_live=use_live,
)
self.countries = configuration["HAPI_countries"]
libhxl_dataset = AdminLevel.get_libhxl_dataset().cache()
reader = Read.get_reader("hdx")
libhxl_dataset = AdminLevel.get_libhxl_dataset(
retriever=reader
).cache()
libhxl_format_dataset = AdminLevel.get_libhxl_dataset(
url=AdminLevel.formats_url, retriever=reader
).cache()
self.admins = Admins(
configuration, session, self.locations, libhxl_dataset
)
Expand All @@ -63,9 +70,13 @@ def __init__(
admin2_config = configuration["admin2"]
self.admintwo = AdminLevel(admin_config=admin2_config, admin_level=2)
self.adminone.setup_from_libhxl_dataset(libhxl_dataset, self.countries)
self.adminone.load_pcode_formats()
self.adminone.load_pcode_formats_from_libhxl_dataset(
libhxl_format_dataset
)
self.admintwo.setup_from_libhxl_dataset(libhxl_dataset, self.countries)
self.admintwo.load_pcode_formats()
self.admintwo.load_pcode_formats_from_libhxl_dataset(
libhxl_format_dataset
)
self.admintwo.set_parent_admins_from_adminlevels([self.adminone])
logger.info("Admin one name mappings:")
self.adminone.output_admin_name_mappings()
Expand Down
158 changes: 158 additions & 0 deletions tests/fixtures/input/download-global-pcode-lengths.csv
Original file line number Diff line number Diff line change
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