hapi-schema 0.8.5__tar.gz → 0.8.7__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.
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/PKG-INFO +1 -1
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/changelog.md +13 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/docker/docker-compose.yml +0 -1
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/_version.py +2 -2
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_food_price.py +1 -1
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_views_as_tables.py +129 -17
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/utils/hapi_views_code_generator.py +3 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/utils/view_as_table_code_generator.py +3 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/utils/view_as_table_definitions.toml +71 -1
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_views_as_tables.py +139 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/.config/coveragerc +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/.config/pre-commit-config.yaml +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/.config/pytest.ini +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/.config/ruff.toml +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/.github/workflows/publish.yaml +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/.github/workflows/run-python-tests.yaml +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/.gitignore +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/LICENSE +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/README.md +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/contributing.md +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/initialize_test_db.sh +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/pyproject.toml +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/requirements.txt +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/__init__.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_admin1.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_admin2.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_conflict_event.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_currency.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_dataset.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_food_security.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_funding.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_humanitarian_needs.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_location.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_national_risk.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_operational_presence.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_org.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_org_type.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_patch.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_population.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_poverty_rate.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_refugees.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_resource.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_sector.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_wfp_commodity.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/db_wfp_market.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/utils/__init__.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/utils/base.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/utils/constraints.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/utils/enums.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/utils/view_params.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/views.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/conftest.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/__init__.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_admin1.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_admin2.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_conflict_event.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_currency.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_dataset.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_food_price.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_food_security.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_funding.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_humanitarian_needs.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_location.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_national_risk.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_operational_presence.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_org.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_org_type.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_patch.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_population.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_poverty_rate.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_refugees.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_resource.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_sector.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_wfp_commodity.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/sample_data/data_wfp_market.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_admin1.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_admin2.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_conflict_event.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_currency.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_dataset.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_food_price.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_food_security.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_funding.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_humanitarian_needs.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_location.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_national_risk.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_operational_presence.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_org.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_org_type.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_patch.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_population.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_poverty_rate.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_refugees.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_resource.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_sector.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_wfp_commodity.py +0 -0
- {hapi_schema-0.8.5 → hapi_schema-0.8.7}/tests/test_wfp_market.py +0 -0
|
@@ -5,6 +5,19 @@ 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.8.7
|
|
9
|
+
|
|
10
|
+
## Changes
|
|
11
|
+
- Add unit to food\_price table primary key
|
|
12
|
+
|
|
13
|
+
## 0.8.6
|
|
14
|
+
|
|
15
|
+
## Changes
|
|
16
|
+
- Added food\_price view as tables by updating the toml parameter file
|
|
17
|
+
- Updated poverty\_rate view as table
|
|
18
|
+
- Updated operational\_presence view as table by updating the toml parameter file
|
|
19
|
+
- Made a few adhoc changes to the view as table generator code to accommodate Decimal columns
|
|
20
|
+
|
|
8
21
|
## 0.8.5
|
|
9
22
|
|
|
10
23
|
## Changes
|
|
@@ -50,7 +50,7 @@ class DBFoodPrice(Base):
|
|
|
50
50
|
nullable=False,
|
|
51
51
|
index=True,
|
|
52
52
|
)
|
|
53
|
-
unit: Mapped[str] = mapped_column(String(32),
|
|
53
|
+
unit: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
54
54
|
price_flag: Mapped[PriceFlag] = mapped_column(
|
|
55
55
|
Enum(PriceFlag), primary_key=True
|
|
56
56
|
)
|
|
@@ -52,6 +52,37 @@ class DBAdmin2VAT(Base):
|
|
|
52
52
|
location_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
53
53
|
|
|
54
54
|
|
|
55
|
+
class DBConflictEventVAT(Base):
|
|
56
|
+
__tablename__ = "conflict_event_vat"
|
|
57
|
+
resource_hdx_id: Mapped[str] = mapped_column(String(36))
|
|
58
|
+
admin2_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
59
|
+
event_type: Mapped[str] = mapped_column(String(18), primary_key=True)
|
|
60
|
+
events: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
|
|
61
|
+
fatalities: Mapped[int] = mapped_column(Integer, nullable=True, index=True)
|
|
62
|
+
reference_period_start: Mapped[datetime] = mapped_column(
|
|
63
|
+
DateTime, primary_key=True
|
|
64
|
+
)
|
|
65
|
+
reference_period_end: Mapped[datetime] = mapped_column(
|
|
66
|
+
DateTime, index=True
|
|
67
|
+
)
|
|
68
|
+
location_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
69
|
+
location_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
70
|
+
admin1_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
71
|
+
admin1_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
72
|
+
admin1_is_unspecified: Mapped[bool] = mapped_column(Boolean)
|
|
73
|
+
location_ref: Mapped[int] = mapped_column(Integer)
|
|
74
|
+
admin2_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
75
|
+
admin2_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
76
|
+
admin2_is_unspecified: Mapped[bool] = mapped_column(Boolean)
|
|
77
|
+
admin1_ref: Mapped[int] = mapped_column(Integer)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class DBCurrencyVAT(Base):
|
|
81
|
+
__tablename__ = "currency_vat"
|
|
82
|
+
code: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
83
|
+
name: Mapped[str] = mapped_column(String(512), index=True)
|
|
84
|
+
|
|
85
|
+
|
|
55
86
|
class DBDatasetVAT(Base):
|
|
56
87
|
__tablename__ = "dataset_vat"
|
|
57
88
|
hdx_id: Mapped[str] = mapped_column(String(36), primary_key=True)
|
|
@@ -61,6 +92,42 @@ class DBDatasetVAT(Base):
|
|
|
61
92
|
hdx_provider_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
62
93
|
|
|
63
94
|
|
|
95
|
+
class DBFoodPriceVAT(Base):
|
|
96
|
+
__tablename__ = "food_price_vat"
|
|
97
|
+
resource_hdx_id: Mapped[str] = mapped_column(String(36))
|
|
98
|
+
market_code: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
99
|
+
commodity_code: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
100
|
+
currency_code: Mapped[str] = mapped_column(String(32), index=True)
|
|
101
|
+
unit: Mapped[str] = mapped_column(String(32))
|
|
102
|
+
price_flag: Mapped[str] = mapped_column(String(16), primary_key=True)
|
|
103
|
+
price_type: Mapped[str] = mapped_column(String(9), primary_key=True)
|
|
104
|
+
price: Mapped[Decimal] = mapped_column()
|
|
105
|
+
reference_period_start: Mapped[datetime] = mapped_column(
|
|
106
|
+
DateTime, primary_key=True
|
|
107
|
+
)
|
|
108
|
+
reference_period_end: Mapped[datetime] = mapped_column(
|
|
109
|
+
DateTime, index=True
|
|
110
|
+
)
|
|
111
|
+
admin2_ref: Mapped[int] = mapped_column(Integer)
|
|
112
|
+
market_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
113
|
+
lat: Mapped[float] = mapped_column(Float, index=True)
|
|
114
|
+
lon: Mapped[float] = mapped_column(Float, index=True)
|
|
115
|
+
commodity_category: Mapped[str] = mapped_column(
|
|
116
|
+
String(18), primary_key=True
|
|
117
|
+
)
|
|
118
|
+
commodity_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
119
|
+
location_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
120
|
+
location_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
121
|
+
location_ref: Mapped[int] = mapped_column(Integer)
|
|
122
|
+
admin1_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
123
|
+
admin1_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
124
|
+
admin1_is_unspecified: Mapped[bool] = mapped_column(Boolean)
|
|
125
|
+
admin1_ref: Mapped[int] = mapped_column(Integer)
|
|
126
|
+
admin2_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
127
|
+
admin2_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
128
|
+
admin2_is_unspecified: Mapped[bool] = mapped_column(Boolean)
|
|
129
|
+
|
|
130
|
+
|
|
64
131
|
class DBFoodSecurityVAT(Base):
|
|
65
132
|
__tablename__ = "food_security_vat"
|
|
66
133
|
resource_hdx_id: Mapped[str] = mapped_column(String(36))
|
|
@@ -68,9 +135,7 @@ class DBFoodSecurityVAT(Base):
|
|
|
68
135
|
ipc_phase: Mapped[str] = mapped_column(String(12), primary_key=True)
|
|
69
136
|
ipc_type: Mapped[str] = mapped_column(String(17), primary_key=True)
|
|
70
137
|
population_in_phase: Mapped[int] = mapped_column(Integer, index=True)
|
|
71
|
-
population_fraction_in_phase: Mapped[Decimal] = mapped_column(
|
|
72
|
-
Float, index=True
|
|
73
|
-
)
|
|
138
|
+
population_fraction_in_phase: Mapped[Decimal] = mapped_column(index=True)
|
|
74
139
|
reference_period_start: Mapped[datetime] = mapped_column(
|
|
75
140
|
DateTime, primary_key=True
|
|
76
141
|
)
|
|
@@ -96,9 +161,9 @@ class DBFundingVAT(Base):
|
|
|
96
161
|
location_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
97
162
|
appeal_name: Mapped[str] = mapped_column(String(256))
|
|
98
163
|
appeal_type: Mapped[str] = mapped_column(String(32))
|
|
99
|
-
requirements_usd: Mapped[Decimal] = mapped_column(
|
|
100
|
-
funding_usd: Mapped[Decimal] = mapped_column(
|
|
101
|
-
funding_pct: Mapped[Decimal] = mapped_column(
|
|
164
|
+
requirements_usd: Mapped[Decimal] = mapped_column(index=True)
|
|
165
|
+
funding_usd: Mapped[Decimal] = mapped_column(index=True)
|
|
166
|
+
funding_pct: Mapped[Decimal] = mapped_column(index=True)
|
|
102
167
|
reference_period_start: Mapped[datetime] = mapped_column(
|
|
103
168
|
DateTime, index=True
|
|
104
169
|
)
|
|
@@ -163,16 +228,12 @@ class DBNationalRiskVAT(Base):
|
|
|
163
228
|
location_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
164
229
|
risk_class: Mapped[str] = mapped_column(String(9))
|
|
165
230
|
global_rank: Mapped[int] = mapped_column(Integer)
|
|
166
|
-
overall_risk: Mapped[Decimal] = mapped_column(
|
|
167
|
-
hazard_exposure_risk: Mapped[Decimal] = mapped_column(
|
|
168
|
-
vulnerability_risk: Mapped[Decimal] = mapped_column(
|
|
169
|
-
coping_capacity_risk: Mapped[Decimal] = mapped_column(
|
|
170
|
-
meta_missing_indicators_pct: Mapped[Decimal] = mapped_column(
|
|
171
|
-
|
|
172
|
-
)
|
|
173
|
-
meta_avg_recentness_years: Mapped[Decimal] = mapped_column(
|
|
174
|
-
Float, nullable=True
|
|
175
|
-
)
|
|
231
|
+
overall_risk: Mapped[Decimal] = mapped_column()
|
|
232
|
+
hazard_exposure_risk: Mapped[Decimal] = mapped_column()
|
|
233
|
+
vulnerability_risk: Mapped[Decimal] = mapped_column()
|
|
234
|
+
coping_capacity_risk: Mapped[Decimal] = mapped_column()
|
|
235
|
+
meta_missing_indicators_pct: Mapped[Decimal] = mapped_column(nullable=True)
|
|
236
|
+
meta_avg_recentness_years: Mapped[Decimal] = mapped_column(nullable=True)
|
|
176
237
|
reference_period_start: Mapped[datetime] = mapped_column(
|
|
177
238
|
DateTime, primary_key=True
|
|
178
239
|
)
|
|
@@ -197,7 +258,7 @@ class DBOperationalPresenceVAT(Base):
|
|
|
197
258
|
DateTime, index=True
|
|
198
259
|
)
|
|
199
260
|
org_type_code: Mapped[str] = mapped_column(String(32))
|
|
200
|
-
org_type_description: Mapped[str] = mapped_column(String(512))
|
|
261
|
+
org_type_description: Mapped[str] = mapped_column(String(512), index=True)
|
|
201
262
|
sector_name: Mapped[str] = mapped_column(String(512))
|
|
202
263
|
location_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
203
264
|
location_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
@@ -254,6 +315,31 @@ class DBPopulationVAT(Base):
|
|
|
254
315
|
admin1_ref: Mapped[int] = mapped_column(Integer)
|
|
255
316
|
|
|
256
317
|
|
|
318
|
+
class DBPovertyRateVAT(Base):
|
|
319
|
+
__tablename__ = "poverty_rate_vat"
|
|
320
|
+
resource_hdx_id: Mapped[str] = mapped_column(String(36))
|
|
321
|
+
admin1_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
|
|
322
|
+
admin1_name: Mapped[str] = mapped_column(
|
|
323
|
+
String(512), primary_key=True, index=True
|
|
324
|
+
)
|
|
325
|
+
mpi: Mapped[float] = mapped_column(Float)
|
|
326
|
+
headcount_ratio: Mapped[float] = mapped_column(Float)
|
|
327
|
+
intensity_of_deprivation: Mapped[float] = mapped_column(Float)
|
|
328
|
+
vulnerable_to_poverty: Mapped[float] = mapped_column(Float)
|
|
329
|
+
in_severe_poverty: Mapped[float] = mapped_column(Float)
|
|
330
|
+
reference_period_start: Mapped[datetime] = mapped_column(
|
|
331
|
+
DateTime, primary_key=True
|
|
332
|
+
)
|
|
333
|
+
reference_period_end: Mapped[datetime] = mapped_column(
|
|
334
|
+
DateTime, index=True
|
|
335
|
+
)
|
|
336
|
+
location_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
337
|
+
location_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
338
|
+
admin1_code: Mapped[str] = mapped_column(String(128))
|
|
339
|
+
admin1_is_unspecified: Mapped[bool] = mapped_column(Boolean)
|
|
340
|
+
location_ref: Mapped[int] = mapped_column(Integer, index=True)
|
|
341
|
+
|
|
342
|
+
|
|
257
343
|
class DBRefugeesVAT(Base):
|
|
258
344
|
__tablename__ = "refugees_vat"
|
|
259
345
|
resource_hdx_id: Mapped[str] = mapped_column(String(36))
|
|
@@ -301,3 +387,29 @@ class DBSectorVAT(Base):
|
|
|
301
387
|
__tablename__ = "sector_vat"
|
|
302
388
|
code: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
303
389
|
name: Mapped[str] = mapped_column(String(512), index=True)
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
class DBWfpCommodityVAT(Base):
|
|
393
|
+
__tablename__ = "wfp_commodity_vat"
|
|
394
|
+
code: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
395
|
+
category: Mapped[str] = mapped_column(String(18), index=True)
|
|
396
|
+
name: Mapped[str] = mapped_column(String(512), index=True)
|
|
397
|
+
|
|
398
|
+
|
|
399
|
+
class DBWfpMarketVAT(Base):
|
|
400
|
+
__tablename__ = "wfp_market_vat"
|
|
401
|
+
code: Mapped[str] = mapped_column(String(32), primary_key=True)
|
|
402
|
+
admin2_ref: Mapped[int] = mapped_column(Integer)
|
|
403
|
+
name: Mapped[str] = mapped_column(String(512), index=True)
|
|
404
|
+
lat: Mapped[float] = mapped_column(Float, index=True)
|
|
405
|
+
lon: Mapped[float] = mapped_column(Float, index=True)
|
|
406
|
+
location_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
407
|
+
location_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
408
|
+
admin1_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
409
|
+
admin1_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
410
|
+
admin1_is_unspecified: Mapped[bool] = mapped_column(Boolean)
|
|
411
|
+
location_ref: Mapped[int] = mapped_column(Integer)
|
|
412
|
+
admin2_code: Mapped[str] = mapped_column(String(128), index=True)
|
|
413
|
+
admin2_name: Mapped[str] = mapped_column(String(512), index=True)
|
|
414
|
+
admin2_is_unspecified: Mapped[bool] = mapped_column(Boolean)
|
|
415
|
+
admin1_ref: Mapped[int] = mapped_column(Integer)
|
|
@@ -54,6 +54,7 @@ def parse_toml():
|
|
|
54
54
|
complete_code.append('"""')
|
|
55
55
|
|
|
56
56
|
# Make imports
|
|
57
|
+
complete_code.append("from decimal import Decimal")
|
|
57
58
|
complete_code.append("from sqlalchemy import DateTime")
|
|
58
59
|
complete_code.append("from sqlalchemy.orm import column_property, Mapped")
|
|
59
60
|
|
|
@@ -180,6 +181,8 @@ def make_table_template_from_view(
|
|
|
180
181
|
mapped_type_1 = "float"
|
|
181
182
|
elif column_type == "TEXT":
|
|
182
183
|
mapped_type_1 = "str"
|
|
184
|
+
elif column_type == "NUMERIC":
|
|
185
|
+
mapped_type_1 = "Decimal"
|
|
183
186
|
table_code.append(
|
|
184
187
|
f" {column.name}: Mapped[{mapped_type_1}] = column_property({source_view}.c.{column.name})"
|
|
185
188
|
)
|
{hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/utils/view_as_table_code_generator.py
RENAMED
|
@@ -159,6 +159,9 @@ def make_table_template_from_view(
|
|
|
159
159
|
elif column_type in ["FLOAT", "DOUBLE PRECISION"]:
|
|
160
160
|
mapped_type_1 = "float"
|
|
161
161
|
mapped_type_2 = "Float"
|
|
162
|
+
elif column_type in ["NUMERIC"]:
|
|
163
|
+
mapped_type_1 = "Decimal"
|
|
164
|
+
mapped_type_2 = "Float"
|
|
162
165
|
elif column_type == "TEXT":
|
|
163
166
|
mapped_type_1 = "str"
|
|
164
167
|
mapped_type_2 = "Text"
|
{hapi_schema-0.8.5 → hapi_schema-0.8.7}/src/hapi_schema/utils/view_as_table_definitions.toml
RENAMED
|
@@ -16,6 +16,29 @@ expected_indexes = ["code", "name",
|
|
|
16
16
|
"location_code", "location_name"]
|
|
17
17
|
expected_nullables = ["reference_period_start", "reference_period_end"]
|
|
18
18
|
|
|
19
|
+
[[tables]]
|
|
20
|
+
db_module = "db_conflict_event"
|
|
21
|
+
target_view = "conflict_event_view"
|
|
22
|
+
view_params_name="view_params_conflict_event"
|
|
23
|
+
expected_primary_keys = [
|
|
24
|
+
"admin2_ref",
|
|
25
|
+
"event_type",
|
|
26
|
+
"reference_period_start"
|
|
27
|
+
]
|
|
28
|
+
expected_indexes = ["events", "fatalities", "reference_period_end", "location_code",
|
|
29
|
+
"location_name", "admin1_code", "admin1_name", "admin2_code", "admin2_name"]
|
|
30
|
+
expected_nullables = ["events", "fatalities"]
|
|
31
|
+
|
|
32
|
+
[[tables]]
|
|
33
|
+
db_module = "db_currency"
|
|
34
|
+
target_view = "currency_view"
|
|
35
|
+
view_params_name = "view_params_currency"
|
|
36
|
+
expected_primary_keys = [
|
|
37
|
+
"code"
|
|
38
|
+
]
|
|
39
|
+
expected_indexes = ["name"]
|
|
40
|
+
expected_nullables = []
|
|
41
|
+
|
|
19
42
|
[[tables]]
|
|
20
43
|
db_module = "db_dataset"
|
|
21
44
|
target_view = "dataset_view"
|
|
@@ -24,6 +47,17 @@ expected_primary_keys = ["hdx_id"]
|
|
|
24
47
|
expected_indexes = ["hdx_stub", "hdx_provider_stub", "hdx_provider_name"]
|
|
25
48
|
expected_nullables = []
|
|
26
49
|
|
|
50
|
+
[[tables]]
|
|
51
|
+
db_module = "db_food_price"
|
|
52
|
+
target_view = "food_price_view"
|
|
53
|
+
view_params_name = "view_params_food_price"
|
|
54
|
+
expected_primary_keys = ["market_code", "commodity_code", "commodity_category", "price_flag", "price_type",
|
|
55
|
+
"reference_period_start"]
|
|
56
|
+
expected_indexes = ["currency_code", "commodity_name", "market_name", "lat", "lon", "reference_period_end",
|
|
57
|
+
"location_code", "location_name",
|
|
58
|
+
"admin1_code", "admin1_name", "admin2_code", "admin2_name"]
|
|
59
|
+
expected_nullables = []
|
|
60
|
+
|
|
27
61
|
[[tables]]
|
|
28
62
|
db_module = "db_food_security"
|
|
29
63
|
target_view = "food_security_view"
|
|
@@ -81,7 +115,8 @@ expected_primary_keys = [
|
|
|
81
115
|
"sector_code",
|
|
82
116
|
"reference_period_start"
|
|
83
117
|
]
|
|
84
|
-
expected_indexes = ["
|
|
118
|
+
expected_indexes = ["org_type_description","reference_period_end", "location_code",
|
|
119
|
+
"location_name", "admin1_code", "admin1_name", "admin2_code", "admin2_name"]
|
|
85
120
|
expected_nullables = []
|
|
86
121
|
|
|
87
122
|
[[tables]]
|
|
@@ -116,6 +151,19 @@ expected_indexes = ["min_age", "max_age", "population", "reference_period_start"
|
|
|
116
151
|
"admin1_code", "admin1_name", "admin2_code", "admin2_name"]
|
|
117
152
|
expected_nullables = ["min_age", "max_age"]
|
|
118
153
|
|
|
154
|
+
[[tables]]
|
|
155
|
+
db_module = "db_poverty_rate"
|
|
156
|
+
target_view = "poverty_rate_view"
|
|
157
|
+
view_params_name="view_params_poverty_rate"
|
|
158
|
+
expected_primary_keys = [
|
|
159
|
+
"admin1_ref",
|
|
160
|
+
"admin1_name",
|
|
161
|
+
"reference_period_start"
|
|
162
|
+
]
|
|
163
|
+
expected_indexes = ["reference_period_end", "location_ref", "location_code",
|
|
164
|
+
"location_name", "admin1_name"]
|
|
165
|
+
expected_nullables = ["rate"]
|
|
166
|
+
|
|
119
167
|
[[tables]]
|
|
120
168
|
db_module = "db_refugees"
|
|
121
169
|
target_view = "refugees_view"
|
|
@@ -150,6 +198,28 @@ expected_primary_keys = [
|
|
|
150
198
|
expected_indexes = ["name"]
|
|
151
199
|
expected_nullables = []
|
|
152
200
|
|
|
201
|
+
[[tables]]
|
|
202
|
+
db_module = "db_wfp_commodity"
|
|
203
|
+
target_view = "wfp_commodity_view"
|
|
204
|
+
view_params_name = "view_params_wfp_commodity"
|
|
205
|
+
expected_primary_keys = [
|
|
206
|
+
"code"
|
|
207
|
+
]
|
|
208
|
+
expected_indexes = ["category","name"]
|
|
209
|
+
expected_nullables = []
|
|
210
|
+
|
|
211
|
+
[[tables]]
|
|
212
|
+
db_module = "db_wfp_market"
|
|
213
|
+
target_view = "wfp_market_view"
|
|
214
|
+
view_params_name = "view_params_wfp_market"
|
|
215
|
+
expected_primary_keys = [
|
|
216
|
+
"code"
|
|
217
|
+
]
|
|
218
|
+
expected_indexes = ["name","lat", "lon", "lat", "lon",
|
|
219
|
+
"location_code", "location_name",
|
|
220
|
+
"admin1_code", "admin1_name", "admin2_code", "admin2_name"]
|
|
221
|
+
expected_nullables = []
|
|
222
|
+
|
|
153
223
|
[[tables]]
|
|
154
224
|
db_module = "db_patch"
|
|
155
225
|
target_view = "patch_view"
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
from hapi_schema.db_admin1 import view_params_admin1
|
|
2
2
|
from hapi_schema.db_admin2 import view_params_admin2
|
|
3
|
+
from hapi_schema.db_conflict_event import view_params_conflict_event
|
|
4
|
+
from hapi_schema.db_currency import view_params_currency
|
|
3
5
|
from hapi_schema.db_dataset import view_params_dataset
|
|
6
|
+
from hapi_schema.db_food_price import view_params_food_price
|
|
4
7
|
from hapi_schema.db_food_security import view_params_food_security
|
|
5
8
|
from hapi_schema.db_funding import view_params_funding
|
|
6
9
|
from hapi_schema.db_humanitarian_needs import view_params_humanitarian_needs
|
|
@@ -13,9 +16,12 @@ from hapi_schema.db_org import view_params_org
|
|
|
13
16
|
from hapi_schema.db_org_type import view_params_org_type
|
|
14
17
|
from hapi_schema.db_patch import view_params_patch
|
|
15
18
|
from hapi_schema.db_population import view_params_population
|
|
19
|
+
from hapi_schema.db_poverty_rate import view_params_poverty_rate
|
|
16
20
|
from hapi_schema.db_refugees import view_params_refugees
|
|
17
21
|
from hapi_schema.db_resource import view_params_resource
|
|
18
22
|
from hapi_schema.db_sector import view_params_sector
|
|
23
|
+
from hapi_schema.db_wfp_commodity import view_params_wfp_commodity
|
|
24
|
+
from hapi_schema.db_wfp_market import view_params_wfp_market
|
|
19
25
|
|
|
20
26
|
|
|
21
27
|
def test_admin1_vat(run_indexes_test, run_columns_test, run_primary_keys_test):
|
|
@@ -50,6 +56,44 @@ def test_admin2_vat(run_indexes_test, run_columns_test, run_primary_keys_test):
|
|
|
50
56
|
run_primary_keys_test("admin2_vat", expected_primary_keys)
|
|
51
57
|
|
|
52
58
|
|
|
59
|
+
def test_conflict_event_vat(
|
|
60
|
+
run_indexes_test, run_columns_test, run_primary_keys_test
|
|
61
|
+
):
|
|
62
|
+
"""Check that conflict_event_vat is correct - columns match, expected indexes present"""
|
|
63
|
+
expected_primary_keys = [
|
|
64
|
+
"admin2_ref",
|
|
65
|
+
"event_type",
|
|
66
|
+
"reference_period_start",
|
|
67
|
+
]
|
|
68
|
+
expected_indexes = [
|
|
69
|
+
"events",
|
|
70
|
+
"fatalities",
|
|
71
|
+
"reference_period_end",
|
|
72
|
+
"location_code",
|
|
73
|
+
"location_name",
|
|
74
|
+
"admin1_code",
|
|
75
|
+
"admin1_name",
|
|
76
|
+
"admin2_code",
|
|
77
|
+
"admin2_name",
|
|
78
|
+
]
|
|
79
|
+
run_columns_test(
|
|
80
|
+
"conflict_event_vat", "conflict_event_view", view_params_conflict_event
|
|
81
|
+
)
|
|
82
|
+
run_indexes_test("conflict_event_vat", expected_indexes)
|
|
83
|
+
run_primary_keys_test("conflict_event_vat", expected_primary_keys)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def test_currency_vat(
|
|
87
|
+
run_indexes_test, run_columns_test, run_primary_keys_test
|
|
88
|
+
):
|
|
89
|
+
"""Check that currency_vat is correct - columns match, expected indexes present"""
|
|
90
|
+
expected_primary_keys = ["code"]
|
|
91
|
+
expected_indexes = ["name"]
|
|
92
|
+
run_columns_test("currency_vat", "currency_view", view_params_currency)
|
|
93
|
+
run_indexes_test("currency_vat", expected_indexes)
|
|
94
|
+
run_primary_keys_test("currency_vat", expected_primary_keys)
|
|
95
|
+
|
|
96
|
+
|
|
53
97
|
def test_dataset_vat(
|
|
54
98
|
run_indexes_test, run_columns_test, run_primary_keys_test
|
|
55
99
|
):
|
|
@@ -61,6 +105,39 @@ def test_dataset_vat(
|
|
|
61
105
|
run_primary_keys_test("dataset_vat", expected_primary_keys)
|
|
62
106
|
|
|
63
107
|
|
|
108
|
+
def test_food_price_vat(
|
|
109
|
+
run_indexes_test, run_columns_test, run_primary_keys_test
|
|
110
|
+
):
|
|
111
|
+
"""Check that food_price_vat is correct - columns match, expected indexes present"""
|
|
112
|
+
expected_primary_keys = [
|
|
113
|
+
"market_code",
|
|
114
|
+
"commodity_code",
|
|
115
|
+
"commodity_category",
|
|
116
|
+
"price_flag",
|
|
117
|
+
"price_type",
|
|
118
|
+
"reference_period_start",
|
|
119
|
+
]
|
|
120
|
+
expected_indexes = [
|
|
121
|
+
"currency_code",
|
|
122
|
+
"commodity_name",
|
|
123
|
+
"market_name",
|
|
124
|
+
"lat",
|
|
125
|
+
"lon",
|
|
126
|
+
"reference_period_end",
|
|
127
|
+
"location_code",
|
|
128
|
+
"location_name",
|
|
129
|
+
"admin1_code",
|
|
130
|
+
"admin1_name",
|
|
131
|
+
"admin2_code",
|
|
132
|
+
"admin2_name",
|
|
133
|
+
]
|
|
134
|
+
run_columns_test(
|
|
135
|
+
"food_price_vat", "food_price_view", view_params_food_price
|
|
136
|
+
)
|
|
137
|
+
run_indexes_test("food_price_vat", expected_indexes)
|
|
138
|
+
run_primary_keys_test("food_price_vat", expected_primary_keys)
|
|
139
|
+
|
|
140
|
+
|
|
64
141
|
def test_food_security_vat(
|
|
65
142
|
run_indexes_test, run_columns_test, run_primary_keys_test
|
|
66
143
|
):
|
|
@@ -186,6 +263,7 @@ def test_operational_presence_vat(
|
|
|
186
263
|
"reference_period_start",
|
|
187
264
|
]
|
|
188
265
|
expected_indexes = [
|
|
266
|
+
"org_type_description",
|
|
189
267
|
"reference_period_end",
|
|
190
268
|
"location_code",
|
|
191
269
|
"location_name",
|
|
@@ -262,6 +340,29 @@ def test_population_vat(
|
|
|
262
340
|
run_primary_keys_test("population_vat", expected_primary_keys)
|
|
263
341
|
|
|
264
342
|
|
|
343
|
+
def test_poverty_rate_vat(
|
|
344
|
+
run_indexes_test, run_columns_test, run_primary_keys_test
|
|
345
|
+
):
|
|
346
|
+
"""Check that poverty_rate_vat is correct - columns match, expected indexes present"""
|
|
347
|
+
expected_primary_keys = [
|
|
348
|
+
"admin1_ref",
|
|
349
|
+
"admin1_name",
|
|
350
|
+
"reference_period_start",
|
|
351
|
+
]
|
|
352
|
+
expected_indexes = [
|
|
353
|
+
"reference_period_end",
|
|
354
|
+
"location_ref",
|
|
355
|
+
"location_code",
|
|
356
|
+
"location_name",
|
|
357
|
+
"admin1_name",
|
|
358
|
+
]
|
|
359
|
+
run_columns_test(
|
|
360
|
+
"poverty_rate_vat", "poverty_rate_view", view_params_poverty_rate
|
|
361
|
+
)
|
|
362
|
+
run_indexes_test("poverty_rate_vat", expected_indexes)
|
|
363
|
+
run_primary_keys_test("poverty_rate_vat", expected_primary_keys)
|
|
364
|
+
|
|
365
|
+
|
|
265
366
|
def test_refugees_vat(
|
|
266
367
|
run_indexes_test, run_columns_test, run_primary_keys_test
|
|
267
368
|
):
|
|
@@ -310,3 +411,41 @@ def test_sector_vat(run_indexes_test, run_columns_test, run_primary_keys_test):
|
|
|
310
411
|
run_columns_test("sector_vat", "sector_view", view_params_sector)
|
|
311
412
|
run_indexes_test("sector_vat", expected_indexes)
|
|
312
413
|
run_primary_keys_test("sector_vat", expected_primary_keys)
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def test_wfp_commodity_vat(
|
|
417
|
+
run_indexes_test, run_columns_test, run_primary_keys_test
|
|
418
|
+
):
|
|
419
|
+
"""Check that wfp_commodity_vat is correct - columns match, expected indexes present"""
|
|
420
|
+
expected_primary_keys = ["code"]
|
|
421
|
+
expected_indexes = ["category", "name"]
|
|
422
|
+
run_columns_test(
|
|
423
|
+
"wfp_commodity_vat", "wfp_commodity_view", view_params_wfp_commodity
|
|
424
|
+
)
|
|
425
|
+
run_indexes_test("wfp_commodity_vat", expected_indexes)
|
|
426
|
+
run_primary_keys_test("wfp_commodity_vat", expected_primary_keys)
|
|
427
|
+
|
|
428
|
+
|
|
429
|
+
def test_wfp_market_vat(
|
|
430
|
+
run_indexes_test, run_columns_test, run_primary_keys_test
|
|
431
|
+
):
|
|
432
|
+
"""Check that wfp_market_vat is correct - columns match, expected indexes present"""
|
|
433
|
+
expected_primary_keys = ["code"]
|
|
434
|
+
expected_indexes = [
|
|
435
|
+
"name",
|
|
436
|
+
"lat",
|
|
437
|
+
"lon",
|
|
438
|
+
"lat",
|
|
439
|
+
"lon",
|
|
440
|
+
"location_code",
|
|
441
|
+
"location_name",
|
|
442
|
+
"admin1_code",
|
|
443
|
+
"admin1_name",
|
|
444
|
+
"admin2_code",
|
|
445
|
+
"admin2_name",
|
|
446
|
+
]
|
|
447
|
+
run_columns_test(
|
|
448
|
+
"wfp_market_vat", "wfp_market_view", view_params_wfp_market
|
|
449
|
+
)
|
|
450
|
+
run_indexes_test("wfp_market_vat", expected_indexes)
|
|
451
|
+
run_primary_keys_test("wfp_market_vat", expected_primary_keys)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|