hapi-schema 0.9.8__tar.gz → 0.9.9__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/.config/pre-commit-config.yaml +2 -2
  2. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/PKG-INFO +2 -2
  3. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/changelog.md +8 -0
  4. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/pyproject.toml +2 -2
  5. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/requirements.txt +1 -1
  6. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/_version.py +9 -4
  7. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_funding.py +3 -3
  8. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_poverty_rate.py +1 -1
  9. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_views_as_tables.py +1 -0
  10. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_wfp_market.py +2 -0
  11. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_funding.py +14 -0
  12. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_funding.py +3 -3
  13. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_views_as_tables.py +1 -0
  14. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/.config/coveragerc +0 -0
  15. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/.config/pytest.ini +0 -0
  16. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/.config/ruff.toml +0 -0
  17. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/.github/workflows/publish.yaml +0 -0
  18. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/.github/workflows/run-python-tests.yaml +0 -0
  19. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/.gitignore +0 -0
  20. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/LICENSE +0 -0
  21. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/README.md +0 -0
  22. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/contributing.md +0 -0
  23. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/docker/docker-compose.yml +0 -0
  24. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/initialize_test_db.sh +0 -0
  25. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/__init__.py +0 -0
  26. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_admin1.py +0 -0
  27. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_admin2.py +0 -0
  28. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_conflict_event.py +0 -0
  29. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_currency.py +0 -0
  30. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_dataset.py +0 -0
  31. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_food_price.py +0 -0
  32. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_food_security.py +0 -0
  33. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_humanitarian_needs.py +0 -0
  34. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_idps.py +0 -0
  35. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_location.py +0 -0
  36. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_national_risk.py +0 -0
  37. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_operational_presence.py +0 -0
  38. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_org.py +0 -0
  39. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_org_type.py +0 -0
  40. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_patch.py +0 -0
  41. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_population.py +0 -0
  42. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_refugees.py +0 -0
  43. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_resource.py +0 -0
  44. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_returnees.py +0 -0
  45. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_sector.py +0 -0
  46. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/db_wfp_commodity.py +0 -0
  47. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/utils/__init__.py +0 -0
  48. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/utils/base.py +0 -0
  49. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/utils/constraints.py +0 -0
  50. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/utils/endpoint_constants.py +0 -0
  51. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/utils/enums.py +0 -0
  52. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/utils/hapi_views_code_generator.py +0 -0
  53. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/utils/view_as_table_code_generator.py +0 -0
  54. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/utils/view_as_table_definitions.toml +0 -0
  55. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/utils/view_params.py +0 -0
  56. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/src/hapi_schema/views.py +0 -0
  57. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/conftest.py +0 -0
  58. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/__init__.py +0 -0
  59. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_admin1.py +0 -0
  60. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_admin2.py +0 -0
  61. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_conflict_event.py +0 -0
  62. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_currency.py +0 -0
  63. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_dataset.py +0 -0
  64. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_food_price.py +0 -0
  65. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_food_security.py +0 -0
  66. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_humanitarian_needs.py +0 -0
  67. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_idps.py +0 -0
  68. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_location.py +0 -0
  69. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_national_risk.py +0 -0
  70. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_operational_presence.py +0 -0
  71. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_org.py +0 -0
  72. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_org_type.py +0 -0
  73. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_patch.py +0 -0
  74. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_population.py +0 -0
  75. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_poverty_rate.py +0 -0
  76. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_refugees.py +0 -0
  77. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_resource.py +0 -0
  78. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_returnees.py +0 -0
  79. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_sector.py +0 -0
  80. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_wfp_commodity.py +0 -0
  81. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/sample_data/data_wfp_market.py +0 -0
  82. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_admin1.py +0 -0
  83. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_admin2.py +0 -0
  84. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_conflict_event.py +0 -0
  85. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_currency.py +0 -0
  86. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_dataset.py +0 -0
  87. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_food_price.py +0 -0
  88. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_food_security.py +0 -0
  89. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_humanitarian_needs.py +0 -0
  90. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_idps.py +0 -0
  91. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_location.py +0 -0
  92. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_national_risk.py +0 -0
  93. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_operational_presence.py +0 -0
  94. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_org.py +0 -0
  95. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_org_type.py +0 -0
  96. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_patch.py +0 -0
  97. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_population.py +0 -0
  98. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_poverty_rate.py +0 -0
  99. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_refugees.py +0 -0
  100. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_resource.py +0 -0
  101. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_returnees.py +0 -0
  102. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_sector.py +0 -0
  103. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_wfp_commodity.py +0 -0
  104. {hapi_schema-0.9.8 → hapi_schema-0.9.9}/tests/test_wfp_market.py +0 -0
@@ -8,7 +8,7 @@ repos:
8
8
  - id: end-of-file-fixer
9
9
  - id: check-ast
10
10
  - repo: https://github.com/astral-sh/ruff-pre-commit
11
- rev: v0.9.4
11
+ rev: v0.9.6
12
12
  hooks:
13
13
  # Run the linter.
14
14
  - id: ruff
@@ -17,7 +17,7 @@ repos:
17
17
  - id: ruff-format
18
18
  args: [--config, .config/ruff.toml]
19
19
  - repo: https://github.com/astral-sh/uv-pre-commit
20
- rev: 0.5.28
20
+ rev: 0.6.1
21
21
  hooks:
22
22
  # Run the pip compile
23
23
  - id: pip-compile
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hapi-schema
3
- Version: 0.9.8
3
+ Version: 0.9.9
4
4
  Summary: HAPI database schema specified in SQLAlchemy
5
5
  Project-URL: Homepage, https://github.com/OCHA-DAP/hapi-schemas
6
6
  Author-email: Simon Johnson <simon.johnson@un.org>
@@ -30,7 +30,7 @@ Requires-Dist: hdx-python-database>=1.3.5; extra == 'database'
30
30
  Provides-Extra: dev
31
31
  Requires-Dist: pre-commit; extra == 'dev'
32
32
  Provides-Extra: test
33
- Requires-Dist: hdx-python-database>=1.3.4; extra == 'test'
33
+ Requires-Dist: hdx-python-database>=1.3.5; extra == 'test'
34
34
  Requires-Dist: psycopg[binary]; extra == 'test'
35
35
  Requires-Dist: pytest; extra == 'test'
36
36
  Requires-Dist: pytest-cov; extra == 'test'
@@ -5,6 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## 0.9.9
9
+
10
+ ### Changed
11
+
12
+ - Added admin level to WFP Market table
13
+ - Allow intensity of deprivation in poverty rate to be nullable
14
+ - Allow non-appeal funding in funding table
15
+
8
16
  ## 0.9.8
9
17
 
10
18
  ### Fixed
@@ -44,7 +44,7 @@ Homepage = "https://github.com/OCHA-DAP/hapi-schemas"
44
44
  [project.optional-dependencies]
45
45
  database = ["hdx-python-database>=1.3.5"]
46
46
  dev = ["pre-commit"]
47
- test = ["hdx-python-database>=1.3.4", "psycopg[binary]", "pytest", "pytest-cov"]
47
+ test = ["hdx-python-database>=1.3.5", "psycopg[binary]", "pytest", "pytest-cov"]
48
48
 
49
49
  #########
50
50
  # Hatch #
@@ -86,7 +86,7 @@ run = """
86
86
  """
87
87
 
88
88
  [tool.hatch.envs.hatch-static-analysis]
89
- dependencies = ["ruff==0.9.4"]
89
+ dependencies = ["ruff==0.9.6"]
90
90
 
91
91
  [tool.hatch.envs.hatch-static-analysis.scripts]
92
92
  format-check = ["ruff format --config .config/ruff.toml --check --diff {args:.}",]
@@ -2,7 +2,7 @@
2
2
  # uv pip compile pyproject.toml --resolver=backtracking --all-extras -o requirements.txt
3
3
  cfgv==3.4.0
4
4
  # via pre-commit
5
- coverage==7.6.11
5
+ coverage==7.6.12
6
6
  # via pytest-cov
7
7
  distlib==0.3.9
8
8
  # via virtualenv
@@ -1,8 +1,13 @@
1
- # file generated by setuptools_scm
1
+ # file generated by setuptools-scm
2
2
  # don't change, don't track in version control
3
+
4
+ __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
+
3
6
  TYPE_CHECKING = False
4
7
  if TYPE_CHECKING:
5
- from typing import Tuple, Union
8
+ from typing import Tuple
9
+ from typing import Union
10
+
6
11
  VERSION_TUPLE = Tuple[Union[int, str], ...]
7
12
  else:
8
13
  VERSION_TUPLE = object
@@ -12,5 +17,5 @@ __version__: str
12
17
  __version_tuple__: VERSION_TUPLE
13
18
  version_tuple: VERSION_TUPLE
14
19
 
15
- __version__ = version = '0.9.8'
16
- __version_tuple__ = version_tuple = (0, 9, 8)
20
+ __version__ = version = '0.9.9'
21
+ __version_tuple__ = version_tuple = (0, 9, 9)
@@ -56,15 +56,15 @@ class DBFunding(Base):
56
56
 
57
57
  appeal_name: Mapped[str] = mapped_column(String(256), nullable=False)
58
58
 
59
- appeal_type: Mapped[str] = mapped_column(String(32), nullable=False)
59
+ appeal_type: Mapped[str] = mapped_column(String(32), nullable=True)
60
60
 
61
61
  requirements_usd: Mapped[Decimal] = mapped_column(
62
- nullable=False, index=True
62
+ nullable=True, index=True
63
63
  )
64
64
 
65
65
  funding_usd: Mapped[Decimal] = mapped_column(nullable=False, index=True)
66
66
 
67
- funding_pct: Mapped[Decimal] = mapped_column(nullable=False, index=True)
67
+ funding_pct: Mapped[Decimal] = mapped_column(nullable=True, index=True)
68
68
 
69
69
  reference_period_start: Mapped[datetime] = mapped_column(
70
70
  primary_key=True,
@@ -57,7 +57,7 @@ class DBPovertyRate(Base):
57
57
  Float, nullable=False, index=False
58
58
  )
59
59
  intensity_of_deprivation: Mapped[float] = mapped_column(
60
- Float, nullable=False, index=False
60
+ Float, nullable=True, index=False
61
61
  )
62
62
  vulnerable_to_poverty: Mapped[float] = mapped_column(
63
63
  Float, nullable=False, index=False
@@ -618,6 +618,7 @@ class DBWfpMarketVAT(Base):
618
618
  admin2_name: Mapped[str] = mapped_column(String(512), index=True)
619
619
  admin2_is_unspecified: Mapped[bool] = mapped_column(Boolean)
620
620
  admin1_ref: Mapped[int] = mapped_column(Integer)
621
+ admin_level: Mapped[int] = mapped_column(Integer, index=True)
621
622
 
622
623
 
623
624
  class DBAvailabilityVAT(Base):
@@ -9,6 +9,7 @@ from hapi_schema.db_location import DBLocation
9
9
  from hapi_schema.utils.base import Base
10
10
  from hapi_schema.utils.constraints import latlon_constraint
11
11
  from hapi_schema.utils.view_params import ViewParams
12
+ from hapi_schema.views import get_admin2_case
12
13
 
13
14
 
14
15
  class DBWFPMarket(Base):
@@ -50,6 +51,7 @@ view_params_wfp_market = ViewParams(
50
51
  DBAdmin2.name.label("admin2_name"),
51
52
  DBAdmin2.is_unspecified.label("admin2_is_unspecified"),
52
53
  DBAdmin2.admin1_ref.label("admin1_ref"),
54
+ get_admin2_case(DBWFPMarket),
53
55
  ).select_from(
54
56
  # Join market to admin2 to admin1 to loc
55
57
  DBWFPMarket.__table__.join(
@@ -1,6 +1,7 @@
1
1
  from datetime import datetime
2
2
 
3
3
  data_funding = [
4
+ # appeal funding
4
5
  dict(
5
6
  resource_hdx_id="90deb235-1bf5-4bae-b231-3393222c2d01",
6
7
  appeal_code="HFOO24",
@@ -13,4 +14,17 @@ data_funding = [
13
14
  reference_period_start=datetime(2024, 1, 1),
14
15
  reference_period_end=datetime(2024, 12, 31),
15
16
  ),
17
+ # non-appeal funding
18
+ dict(
19
+ resource_hdx_id="90deb235-1bf5-4bae-b231-3393222c2d01",
20
+ appeal_code="",
21
+ location_ref=1,
22
+ appeal_name="Not specified",
23
+ appeal_type=None,
24
+ requirements_usd=None,
25
+ funding_usd=300000.0,
26
+ funding_pct=None,
27
+ reference_period_start=datetime(2024, 1, 1),
28
+ reference_period_end=datetime(2024, 12, 31),
29
+ ),
16
30
  ]
@@ -10,7 +10,7 @@ from hapi_schema.views import prepare_hapi_views
10
10
 
11
11
 
12
12
  def test_funding_view(run_view_test):
13
- """Check gender view has all columns."""
13
+ """Check funding view has all columns."""
14
14
  view_funding = Database.prepare_view(view_params_funding.__dict__)
15
15
  run_view_test(
16
16
  view=view_funding,
@@ -67,7 +67,7 @@ def test_reference_period_constraint(run_constraints_test):
67
67
 
68
68
 
69
69
  def test_requirements_usd_constraint(run_constraints_test):
70
- """Check that reference_period_end cannot be less than start"""
70
+ """Check that requirements usd cannot be less than zero"""
71
71
  run_constraints_test(
72
72
  new_rows=[
73
73
  DBFunding(
@@ -88,7 +88,7 @@ def test_requirements_usd_constraint(run_constraints_test):
88
88
 
89
89
 
90
90
  def test_funding_usd_constraint(run_constraints_test):
91
- """Check that reference_period_end cannot be less than start"""
91
+ """Check that funding usd cannot be less than zero"""
92
92
  run_constraints_test(
93
93
  new_rows=[
94
94
  DBFunding(
@@ -519,6 +519,7 @@ def test_wfp_market_vat(
519
519
  "admin1_name",
520
520
  "admin2_code",
521
521
  "admin2_name",
522
+ "admin_level",
522
523
  ]
523
524
  run_columns_test(
524
525
  "wfp_market_vat", "wfp_market_view", view_params_wfp_market
File without changes
File without changes
File without changes
File without changes