hapi-schema 0.9.16__tar.gz → 0.9.18__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 (114) hide show
  1. hapi_schema-0.9.18/.github/workflows/publish.yaml +28 -0
  2. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/.github/workflows/run-python-tests.yaml +24 -26
  3. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/.gitignore +12 -5
  4. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/.pre-commit-config.yaml +9 -9
  5. hapi_schema-0.9.18/CLAUDE.md +61 -0
  6. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/PKG-INFO +24 -12
  7. hapi_schema-0.9.18/README.md +23 -0
  8. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/changelog.md +17 -0
  9. hapi_schema-0.9.18/pyproject.toml +137 -0
  10. hapi_schema-0.9.18/src/hapi_schema/_version.py +24 -0
  11. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_funding.py +1 -1
  12. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_resource.py +0 -2
  13. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_views_as_tables.py +1 -2
  14. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/utils/enums.py +5 -0
  15. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_resource.py +0 -3
  16. hapi_schema-0.9.18/uv.lock +716 -0
  17. hapi_schema-0.9.16/.github/workflows/publish.yaml +0 -35
  18. hapi_schema-0.9.16/README.md +0 -2
  19. hapi_schema-0.9.16/hatch.toml +0 -37
  20. hapi_schema-0.9.16/pyproject.toml +0 -47
  21. hapi_schema-0.9.16/pytest.ini +0 -4
  22. hapi_schema-0.9.16/requirements.txt +0 -52
  23. hapi_schema-0.9.16/ruff.toml +0 -16
  24. hapi_schema-0.9.16/src/hapi_schema/_version.py +0 -34
  25. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/.coveragerc +0 -0
  26. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/LICENSE +0 -0
  27. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/contributing.md +0 -0
  28. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/docker/docker-compose.yml +0 -0
  29. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/initialize_test_db.sh +0 -0
  30. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/__init__.py +0 -0
  31. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_admin1.py +0 -0
  32. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_admin2.py +0 -0
  33. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_conflict_event.py +0 -0
  34. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_currency.py +0 -0
  35. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_dataset.py +0 -0
  36. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_food_price.py +0 -0
  37. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_food_security.py +0 -0
  38. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_humanitarian_needs.py +0 -0
  39. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_idps.py +0 -0
  40. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_location.py +0 -0
  41. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_national_risk.py +0 -0
  42. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_operational_presence.py +0 -0
  43. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_org.py +0 -0
  44. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_org_type.py +0 -0
  45. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_patch.py +0 -0
  46. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_population.py +0 -0
  47. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_poverty_rate.py +0 -0
  48. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_rainfall.py +0 -0
  49. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_refugees.py +0 -0
  50. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_returnees.py +0 -0
  51. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_sector.py +0 -0
  52. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_wfp_commodity.py +0 -0
  53. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/db_wfp_market.py +0 -0
  54. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/utils/__init__.py +0 -0
  55. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/utils/base.py +0 -0
  56. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/utils/constraints.py +0 -0
  57. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/utils/endpoint_constants.py +0 -0
  58. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/utils/hapi_views_code_generator.py +0 -0
  59. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/utils/view_as_table_code_generator.py +0 -0
  60. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/utils/view_as_table_definitions.toml +0 -0
  61. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/utils/view_params.py +0 -0
  62. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/src/hapi_schema/views.py +0 -0
  63. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/conftest.py +0 -0
  64. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/__init__.py +0 -0
  65. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_admin1.py +0 -0
  66. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_admin2.py +0 -0
  67. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_conflict_event.py +0 -0
  68. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_currency.py +0 -0
  69. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_dataset.py +0 -0
  70. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_food_price.py +0 -0
  71. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_food_security.py +0 -0
  72. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_funding.py +0 -0
  73. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_humanitarian_needs.py +0 -0
  74. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_idps.py +0 -0
  75. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_location.py +0 -0
  76. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_national_risk.py +0 -0
  77. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_operational_presence.py +0 -0
  78. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_org.py +0 -0
  79. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_org_type.py +0 -0
  80. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_patch.py +0 -0
  81. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_population.py +0 -0
  82. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_poverty_rate.py +0 -0
  83. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_rainfall.py +0 -0
  84. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_refugees.py +0 -0
  85. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_returnees.py +0 -0
  86. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_sector.py +0 -0
  87. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_wfp_commodity.py +0 -0
  88. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/sample_data/data_wfp_market.py +0 -0
  89. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_admin1.py +0 -0
  90. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_admin2.py +0 -0
  91. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_conflict_event.py +0 -0
  92. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_currency.py +0 -0
  93. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_dataset.py +0 -0
  94. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_food_price.py +0 -0
  95. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_food_security.py +0 -0
  96. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_funding.py +0 -0
  97. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_humanitarian_needs.py +0 -0
  98. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_idps.py +0 -0
  99. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_location.py +0 -0
  100. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_national_risk.py +0 -0
  101. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_operational_presence.py +0 -0
  102. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_org.py +0 -0
  103. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_org_type.py +0 -0
  104. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_patch.py +0 -0
  105. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_population.py +0 -0
  106. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_poverty_rate.py +0 -0
  107. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_rainfall.py +0 -0
  108. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_refugees.py +0 -0
  109. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_resource.py +0 -0
  110. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_returnees.py +0 -0
  111. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_sector.py +0 -0
  112. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_views_as_tables.py +0 -0
  113. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_wfp_commodity.py +0 -0
  114. {hapi_schema-0.9.16 → hapi_schema-0.9.18}/tests/test_wfp_market.py +0 -0
@@ -0,0 +1,28 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ release:
6
+ types: [published]
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v6
14
+ with:
15
+ fetch-depth: 0
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v7
19
+ with:
20
+ enable-cache: true
21
+
22
+ - name: Build
23
+ run: uv build
24
+
25
+ - name: Publish
26
+ env:
27
+ UV_PUBLISH_TOKEN: ${{ secrets.HATCH_INDEX_AUTH }}
28
+ run: uv publish
@@ -1,21 +1,19 @@
1
- # This workflow will install Python dependencies, lint and run tests
2
- # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3
-
4
1
  name: Run tests
5
2
 
6
3
  on:
7
- workflow_dispatch: # add run button in github
4
+ workflow_dispatch:
8
5
  push:
9
- branches-ignore:
10
- - gh-pages
11
- - 'dependabot/**'
6
+ branches-ignore: [gh-pages, "dependabot/**"]
12
7
  pull_request:
13
- branches-ignore:
14
- - gh-pages
8
+ branches-ignore: [gh-pages]
15
9
 
16
10
  jobs:
17
11
  build:
18
12
  runs-on: ubuntu-latest
13
+ permissions:
14
+ contents: read
15
+ checks: write
16
+ pull-requests: write
19
17
 
20
18
  services:
21
19
  postgres:
@@ -34,33 +32,33 @@ jobs:
34
32
  --name postgres-container
35
33
 
36
34
  steps:
37
- - uses: actions/checkout@v4
38
- - name: Set up Python
39
- uses: actions/setup-python@v5
35
+ - uses: actions/checkout@v6
36
+
37
+ - name: Install uv
38
+ uses: astral-sh/setup-uv@v7
40
39
  with:
41
- python-version: '3.x'
40
+ enable-cache: true
41
+
42
42
  - name: Install dependencies
43
- run: |
44
- python -m pip install --upgrade pip
45
- - name: Install Hatch
46
- uses: pypa/hatch@install
47
- - name: Test with hatch/pytest
48
- run: |
49
- hatch test
43
+ run: uv sync --frozen --all-groups
44
+
50
45
  - name: Check styling
51
- if: always()
52
46
  run: |
53
- hatch fmt --check
47
+ uv run ruff format --check
48
+ uv run ruff check
49
+
50
+ - name: Test with pytest
51
+ run: uv run pytest
52
+
54
53
  - name: Publish Unit Test Results
55
54
  uses: EnricoMi/publish-unit-test-result-action@v2
56
55
  if: always()
57
56
  with:
58
- github_token: ${{ secrets.GITHUB_TOKEN }}
59
- junit_files: test-results.xml
57
+ files: test-results.xml
58
+
60
59
  - name: Publish in Coveralls
61
60
  uses: coverallsapp/github-action@v2
61
+ if: always()
62
62
  with:
63
- github-token: ${{ secrets.GITHUB_TOKEN }}
64
63
  flag-name: tests
65
64
  format: lcov
66
- fail-on-error: false
@@ -24,7 +24,6 @@ share/python-wheels/
24
24
  *.egg-info/
25
25
  .installed.cfg
26
26
  *.egg
27
- *.pypirc
28
27
  MANIFEST
29
28
 
30
29
  # PyInstaller
@@ -38,6 +37,7 @@ pip-log.txt
38
37
  pip-delete-this-directory.txt
39
38
 
40
39
  # Unit test / coverage reports
40
+ test-results.xml
41
41
  htmlcov/
42
42
  .tox/
43
43
  .nox/
@@ -48,7 +48,9 @@ nosetests.xml
48
48
  coverage.xml
49
49
  *.cover
50
50
  *.py,cover
51
+ coverage.lcov
51
52
  .hypothesis/
53
+ tests/*.log
52
54
  .pytest_cache/
53
55
  cover/
54
56
 
@@ -107,8 +109,10 @@ ipython_config.py
107
109
  #pdm.lock
108
110
  # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
109
111
  # in version control.
110
- # https://pdm.fming.dev/#use-with-ide
112
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
111
113
  .pdm.toml
114
+ .pdm-python
115
+ .pdm-build/
112
116
 
113
117
  # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
114
118
  __pypackages__/
@@ -160,10 +164,13 @@ cython_debug/
160
164
  # option (not recommended) you can uncomment the following to ignore the entire idea folder.
161
165
  .idea/
162
166
 
167
+ # VS Code
168
+ .vscode/settings.json
169
+
163
170
  ## Project
164
171
 
165
172
  # Version file
166
- src/hapi_schema/_version.py
173
+ **/_version.py
167
174
 
168
- # OS Files
169
- *DS_Store
175
+ # Mac files
176
+ .DS_Store
@@ -1,25 +1,25 @@
1
1
  default_language_version:
2
- python: python3.13
2
+ python: python3
3
+
3
4
  repos:
4
5
  - repo: https://github.com/pre-commit/pre-commit-hooks
5
- rev: v5.0.0
6
+ rev: v6.0.0
6
7
  hooks:
7
8
  - id: trailing-whitespace
8
9
  - id: end-of-file-fixer
9
10
  - id: check-ast
11
+
10
12
  - repo: https://github.com/astral-sh/ruff-pre-commit
11
- rev: v0.12.0
13
+ rev: v0.14.14
12
14
  hooks:
13
15
  # Run the linter.
14
16
  - id: ruff-check
15
17
  args: [ --fix ]
16
18
  # Run the formatter.
17
19
  - id: ruff-format
20
+
18
21
  - repo: https://github.com/astral-sh/uv-pre-commit
19
- rev: 0.7.14
22
+ rev: 0.9.25
20
23
  hooks:
21
- # Run the pip compile
22
- - id: pip-compile
23
- name: pip-compile requirements.txt
24
- files: pyproject.toml
25
- args: [ pyproject.toml, --resolver=backtracking, --all-extras, --upgrade, -q, -o, requirements.txt ]
24
+ # Ensure the lockfile is up-to-date with pyproject.toml
25
+ - id: uv-lock
@@ -0,0 +1,61 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ **hapi-sqlalchemy-schema** defines the HAPI (Humanitarian API) database schema using SQLAlchemy ORM models. It is a library published to PyPI that other projects (such as `hapi-pipelines`) import to create and interact with the HAPI PostgreSQL database.
8
+
9
+ ## Commands
10
+
11
+ Install dependencies:
12
+ ```bash
13
+ uv sync
14
+ ```
15
+
16
+ Install with test dependencies:
17
+ ```bash
18
+ uv sync --group test
19
+ ```
20
+
21
+ Run tests:
22
+ ```bash
23
+ uv run pytest
24
+ ```
25
+
26
+ Run a single test:
27
+ ```bash
28
+ uv run pytest tests/test_location.py
29
+ ```
30
+
31
+ Lint check:
32
+ ```bash
33
+ pre-commit run --all-files
34
+ ```
35
+
36
+ ## Architecture
37
+
38
+ The library lives under `src/hapi_schema/` and contains:
39
+
40
+ - **`db_*.py`** — SQLAlchemy ORM table definitions (one file per HAPI data category, e.g. `db_location.py`, `db_funding.py`)
41
+ - **`views.py`** — SQLAlchemy view definitions that mirror the tables
42
+ - **`utils/`** — shared utilities (e.g. `base.py` with the declarative `Base`)
43
+
44
+ Tests require a live PostgreSQL instance (`postgresql+psycopg://postgres:postgres@localhost:5432/hapitest`). The `tests/sample_data/` directory holds fixture data used by `conftest.py` to populate the database before tests run.
45
+
46
+ ## Environment
47
+
48
+ Tests require a running PostgreSQL 14 instance. Use the `docker/docker-compose.yml` to start one locally:
49
+ ```bash
50
+ docker compose -f docker/docker-compose.yml up -d
51
+ ```
52
+
53
+ ## Collaboration Style
54
+
55
+ - Be objective, not agreeable. Act as a partner, not a sycophant. Push back when you disagree, flag tradeoffs honestly, and don't sugarcoat problems.
56
+ - Keep explanations brief and to the point.
57
+ - Don't rely on recalled knowledge for facts that could be stale (API behaviour, library versions, external systems). Search or read the actual source first.
58
+
59
+ ## Scope of Changes
60
+
61
+ When fixing a bug or addressing PR feedback, change only what is necessary to resolve the specific issue. Do not refactor surrounding code, rename variables, adjust formatting, or make improvements in the same commit unless they are directly required by the fix.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: hapi-schema
3
- Version: 0.9.16
3
+ Version: 0.9.18
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>
@@ -17,24 +17,36 @@ Classifier: Operating System :: Unix
17
17
  Classifier: Programming Language :: Python
18
18
  Classifier: Programming Language :: Python :: 3
19
19
  Classifier: Programming Language :: Python :: 3 :: Only
20
- Classifier: Programming Language :: Python :: 3.8
21
- Classifier: Programming Language :: Python :: 3.9
22
20
  Classifier: Programming Language :: Python :: 3.10
23
21
  Classifier: Programming Language :: Python :: 3.11
24
22
  Classifier: Programming Language :: Python :: 3.12
25
23
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
26
- Requires-Python: >=3.8
24
+ Requires-Python: >=3.10
27
25
  Requires-Dist: sqlalchemy
28
26
  Provides-Extra: database
29
27
  Requires-Dist: hdx-python-database>=1.3.7; extra == 'database'
30
- Provides-Extra: dev
31
- Requires-Dist: pre-commit; extra == 'dev'
32
- Provides-Extra: test
33
- Requires-Dist: hdx-python-database>=1.3.7; extra == 'test'
34
- Requires-Dist: psycopg[binary]; extra == 'test'
35
- Requires-Dist: pytest; extra == 'test'
36
- Requires-Dist: pytest-cov; extra == 'test'
37
28
  Description-Content-Type: text/markdown
38
29
 
39
30
  # hapi-sqlalchemy-schema
31
+
40
32
  Schema for HAPI database in SQLAlchemy
33
+
34
+ ## Installation
35
+
36
+ ```bash
37
+ pip install hapi-schema
38
+ ```
39
+
40
+ With database utilities:
41
+ ```bash
42
+ pip install hapi-schema[database]
43
+ ```
44
+
45
+ ## Development
46
+
47
+ Install [uv](https://docs.astral.sh/uv/), then:
48
+
49
+ ```bash
50
+ uv sync --all-groups
51
+ uv run pytest
52
+ ```
@@ -0,0 +1,23 @@
1
+ # hapi-sqlalchemy-schema
2
+
3
+ Schema for HAPI database in SQLAlchemy
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install hapi-schema
9
+ ```
10
+
11
+ With database utilities:
12
+ ```bash
13
+ pip install hapi-schema[database]
14
+ ```
15
+
16
+ ## Development
17
+
18
+ Install [uv](https://docs.astral.sh/uv/), then:
19
+
20
+ ```bash
21
+ uv sync --all-groups
22
+ uv run pytest
23
+ ```
@@ -5,6 +5,23 @@ 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.18
9
+
10
+ ### Added
11
+
12
+ - Add SRV, FMS, FMC, FMSc, REG to IOM assessment type enum
13
+
14
+ ### Changed
15
+
16
+ - Remove is_hxl from DBResource and elsewhere
17
+ - Upgrade to uv
18
+
19
+ ## 0.9.17
20
+
21
+ ### Changed
22
+
23
+ - Update funding schema appeal_code to 64 chars
24
+
8
25
  ## 0.9.16
9
26
 
10
27
  ### Added
@@ -0,0 +1,137 @@
1
+ #########################
2
+ # Project Configuration #
3
+ #########################
4
+
5
+ [build-system]
6
+ requires = ["hatchling", "hatch-vcs"]
7
+ build-backend = "hatchling.build"
8
+
9
+ [project]
10
+ name = "hapi-schema"
11
+ description = "HAPI database schema specified in SQLAlchemy"
12
+ authors = [{name = "Simon Johnson", email = "simon.johnson@un.org"}]
13
+ license = {text = "MIT"}
14
+ keywords = ["HDX", "hapi", "schema"]
15
+ classifiers = [
16
+ "Topic :: Software Development :: Libraries :: Python Modules",
17
+ "Programming Language :: Python",
18
+ "Programming Language :: Python :: 3",
19
+ "Programming Language :: Python :: 3 :: Only",
20
+ "Programming Language :: Python :: 3.10",
21
+ "Programming Language :: Python :: 3.11",
22
+ "Programming Language :: Python :: 3.12",
23
+ "Intended Audience :: Developers",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Natural Language :: English",
26
+ "Operating System :: POSIX :: Linux",
27
+ "Operating System :: Unix",
28
+ "Operating System :: MacOS",
29
+ "Operating System :: Microsoft :: Windows",
30
+ ]
31
+ requires-python = ">=3.10"
32
+ dependencies = ["sqlalchemy"]
33
+ dynamic = ["version"]
34
+
35
+ [project.readme]
36
+ file = "README.md"
37
+ content-type = "text/markdown"
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/OCHA-DAP/hapi-schemas"
41
+
42
+ [project.optional-dependencies]
43
+ database = ["hdx-python-database>=1.3.7"]
44
+
45
+ [dependency-groups]
46
+ dev = [
47
+ "pre-commit",
48
+ "ruff==0.14.14",
49
+ ]
50
+ test = [
51
+ "hdx-python-database>=1.3.7",
52
+ "psycopg[binary]",
53
+ "pytest",
54
+ "pytest-cov",
55
+ ]
56
+
57
+ # ----------------------------------------------------------------------------
58
+ # Hatchling (Build & Versioning)
59
+ # ----------------------------------------------------------------------------
60
+
61
+ [tool.hatch.version]
62
+ source = "vcs"
63
+
64
+ [tool.hatch.version.raw-options]
65
+ local_scheme = "no-local-version"
66
+ version_scheme = "python-simplified-semver"
67
+
68
+ [tool.hatch.build.hooks.vcs]
69
+ version-file = "src/hapi_schema/_version.py"
70
+
71
+ [tool.hatch.build.targets.wheel]
72
+ packages = ["src/hapi_schema"]
73
+
74
+ [tool.hatch.metadata]
75
+ allow-direct-references = true
76
+
77
+ # ----------------------------------------------------------------------------
78
+ # Ruff (Linting & Formatting)
79
+ # ----------------------------------------------------------------------------
80
+
81
+ [tool.ruff]
82
+ target-version = "py310"
83
+ src = ["src"]
84
+ exclude = ["_version.py"]
85
+
86
+ [tool.ruff.lint]
87
+ select = [
88
+ "E", # pycodestyle
89
+ "F", # pyflakes
90
+ "I", # isort
91
+ ]
92
+ ignore = [
93
+ "E501", # Line too long
94
+ ]
95
+
96
+ [tool.ruff.lint.isort]
97
+ known-local-folder = ["hapi_schema", "sample_data"]
98
+ known-third-party = ["hdx.database"]
99
+
100
+ # ----------------------------------------------------------------------------
101
+ # Pytest (Testing)
102
+ # ----------------------------------------------------------------------------
103
+
104
+ [tool.pytest.ini_options]
105
+ pythonpath = ["src", "tests"]
106
+ log_cli = true
107
+ addopts = """
108
+ --color=yes
109
+ --rootdir=.
110
+ --junitxml=test-results.xml
111
+ --cov
112
+ --no-cov-on-fail
113
+ --cov-report=lcov
114
+ --cov-report=term-missing
115
+ """
116
+
117
+ # ----------------------------------------------------------------------------
118
+ # Coverage (Reporting)
119
+ # ----------------------------------------------------------------------------
120
+
121
+ [tool.coverage.run]
122
+ source = ["src"]
123
+ omit = ["*/_version.py"]
124
+
125
+ [tool.coverage.report]
126
+ exclude_also = [
127
+ "from ._version",
128
+ "def __repr__",
129
+ "if self.debug:",
130
+ "if settings.DEBUG",
131
+ "raise AssertionError",
132
+ "raise NotImplementedError",
133
+ "if 0:",
134
+ "if __name__ == .__main__.:",
135
+ "if TYPE_CHECKING:",
136
+ "@(abc\\.)?abstractmethod",
137
+ ]
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.9.18'
22
+ __version_tuple__ = version_tuple = (0, 9, 18)
23
+
24
+ __commit_id__ = commit_id = None
@@ -44,7 +44,7 @@ class DBFunding(Base):
44
44
  )
45
45
 
46
46
  appeal_code: Mapped[str] = mapped_column(
47
- String(32),
47
+ String(64),
48
48
  primary_key=True,
49
49
  )
50
50
 
@@ -3,7 +3,6 @@
3
3
  from datetime import datetime
4
4
 
5
5
  from sqlalchemy import (
6
- Boolean,
7
6
  ForeignKey,
8
7
  String,
9
8
  select,
@@ -26,7 +25,6 @@ class DBResource(Base):
26
25
  name: Mapped[str] = mapped_column(String(256), nullable=False)
27
26
  format: Mapped[str] = mapped_column(String(32), nullable=False)
28
27
  update_date: Mapped[datetime] = mapped_column(nullable=False)
29
- is_hxl: Mapped[bool] = mapped_column(Boolean, nullable=False)
30
28
  download_url: Mapped[str] = mapped_column(String(1024), nullable=False, unique=True)
31
29
  hapi_updated_date: Mapped[datetime] = mapped_column(nullable=False)
32
30
  dataset = relationship("DBDataset")
@@ -203,7 +203,7 @@ class DBFoodSecurityVAT(Base):
203
203
  class DBFundingVAT(Base):
204
204
  __tablename__ = "funding_vat"
205
205
  resource_hdx_id: Mapped[str] = mapped_column(String(36))
206
- appeal_code: Mapped[str] = mapped_column(String(32), primary_key=True)
206
+ appeal_code: Mapped[str] = mapped_column(String(64), primary_key=True)
207
207
  location_ref: Mapped[int] = mapped_column(Integer, primary_key=True)
208
208
  appeal_name: Mapped[str] = mapped_column(String(256))
209
209
  appeal_type: Mapped[str] = mapped_column(String(64), nullable=True)
@@ -487,7 +487,6 @@ class DBResourceVAT(Base):
487
487
  name: Mapped[str] = mapped_column(String(256))
488
488
  format: Mapped[str] = mapped_column(String(32))
489
489
  update_date: Mapped[datetime] = mapped_column(DateTime)
490
- is_hxl: Mapped[bool] = mapped_column(Boolean)
491
490
  download_url: Mapped[str] = mapped_column(String(1024))
492
491
  hapi_updated_date: Mapped[datetime] = mapped_column(DateTime)
493
492
  dataset_hdx_stub: Mapped[str] = mapped_column(String(128), index=True)
@@ -27,6 +27,11 @@ class DTMAssessmentType(str, PythonEnum):
27
27
  BASELINE = "BA"
28
28
  EVENT_TRACK = "ETT"
29
29
  SITE = "SA"
30
+ SURVEY = "SRV"
31
+ FLOW_MON_SURVEY = "FMS"
32
+ FLOW_MON_COUNTER = "FMC"
33
+ FLOW_MON_SCREENER = "FMSc"
34
+ REGISTRATION = "REG"
30
35
 
31
36
 
32
37
  class EventType(str, PythonEnum):
@@ -8,7 +8,6 @@ data_resource = [
8
8
  format="csv",
9
9
  update_date=datetime(2023, 6, 1),
10
10
  download_url="https://data.humdata.org/dataset/c3f001fa-b45b-464c-9460-1ca79fd39b40/resource/90deb235-1bf5-4bae-b231-3393222c2d01/download/resource-01.csv",
11
- is_hxl=True,
12
11
  hapi_updated_date=datetime(2023, 6, 1),
13
12
  hapi_replaced_date=None,
14
13
  ),
@@ -19,7 +18,6 @@ data_resource = [
19
18
  format="xlsx",
20
19
  update_date=datetime(2023, 7, 1),
21
20
  download_url="https://fdw.fews.net/api/tradeflowquantityvaluefacts/?dataset=1845&country=TZ&fields=simple&format=xlsx",
22
- is_hxl=True,
23
21
  hapi_updated_date=datetime(2023, 7, 1),
24
22
  hapi_replaced_date=None,
25
23
  ),
@@ -30,7 +28,6 @@ data_resource = [
30
28
  format="csv",
31
29
  update_date=datetime(2023, 8, 1),
32
30
  download_url="https://data.humdata.org/dataset/7cf3cec8-dbbc-4c96-9762-1464cd0bff75/resource/62ad6e55-5f5d-4494-854c-4110687e9e25/download/resource-03.csv",
33
- is_hxl=True,
34
31
  hapi_updated_date=datetime(2023, 8, 1),
35
32
  hapi_replaced_date=None,
36
33
  ),