Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ae29fde
refactor(field_update): add h3 indexes update in the field update for…
kshitijrajsharma Jun 7, 2025
03785f4
refactor: remove country column and related indexes, add h3 column an…
kshitijrajsharma Jun 14, 2025
b0d71a3
feat(country_h3): add country_h3_flat table and populate with H3 inde…
kshitijrajsharma Jun 14, 2025
5cf7353
feat(country_h3): create country_h3_flat table and populate with H3 i…
kshitijrajsharma Jun 17, 2025
1eeb4b4
feat(country_h3): add indexes on h3_index and country_id in country_h…
kshitijrajsharma Jun 19, 2025
be9c4ac
init : uv
kshitijrajsharma Oct 1, 2025
8cd0578
chore : backend cleanup
kshitijrajsharma Oct 4, 2025
24a2d8d
chore : cleanup , remove unnecessary login files and docs
kshitijrajsharma Oct 4, 2025
180cf50
docs: update README for clarity and additional data sources
kshitijrajsharma Oct 4, 2025
46d8f46
feat(importer): add database setup and extension management functions
kshitijrajsharma Oct 4, 2025
165d727
fix : psycopg2, added binary for now !
kshitijrajsharma Oct 4, 2025
cd72123
chore : get rid of psycopg2-binary dev lib
kshitijrajsharma Oct 4, 2025
ebe3154
fix : userroles assignment !
kshitijrajsharma Oct 4, 2025
b5d7f78
feat: add user role management with new user_roles table and user column
kshitijrajsharma Oct 4, 2025
cbcd553
fix: update userroles to user_roles for consistency in README and imp…
kshitijrajsharma Oct 4, 2025
b8005c7
feat : add tables using alembic
kshitijrajsharma Oct 5, 2025
5a134cc
cleanup : remove db connection pooling
kshitijrajsharma Oct 5, 2025
d30fc3e
cleanup : polygon stats and cid references
kshitijrajsharma Oct 5, 2025
fd942e3
refact : remove cid from the reference and iso3 as coutnries are goin…
kshitijrajsharma Oct 6, 2025
3293a39
Merge branch 'develop' into feature/h3-index
kshitijrajsharma Dec 24, 2025
f1f20ac
chore : add escape sql string , standarize the select function on bui…
kshitijrajsharma Dec 24, 2025
ce4e4a9
fix : add quick start and added dockerfile build using uv
kshitijrajsharma Dec 25, 2025
e83f0dd
fix : black formatter
kshitijrajsharma Dec 25, 2025
4fbe946
fix : ci issues on builds
kshitijrajsharma Dec 25, 2025
b847020
ci : fix build on backend insert
kshitijrajsharma Dec 25, 2025
d74a705
fix : build ci
kshitijrajsharma Dec 25, 2025
8899be6
ci : fix build cases
kshitijrajsharma Dec 25, 2025
bc12724
ci : added alembic
kshitijrajsharma Dec 25, 2025
11ae048
ci : add unit tests
kshitijrajsharma Dec 25, 2025
4a4e790
fix: update PostgreSQL H3 extension installation process
kshitijrajsharma Dec 25, 2025
86ca67c
ci : update postgresql 14
kshitijrajsharma Dec 25, 2025
61dcf4f
ci : add psql 16 h3
kshitijrajsharma Dec 25, 2025
799c8cd
ci: update workflows and Dockerfile for PostgreSQL H3 integration
kshitijrajsharma Dec 25, 2025
1eeb99d
feat : add stage branch
kshitijrajsharma Dec 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@
infra
docs
tests
.env
.env.*
*.pyc
__pycache__
.pytest_cache
*.log
exports/
.vscode
.idea
44 changes: 26 additions & 18 deletions .github/workflows/Unit-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ jobs:
runs-on: ubuntu-latest
services:
postgres:
image: postgis/postgis:14-3.3
image: ghcr.io/hotosm/postgis-h3:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
POSTGRES_PASSWORD: admin
POSTGRES_DB: raw
Expand Down Expand Up @@ -46,18 +49,29 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v1
with:
python-version: 3.11
python-version: 3.12
- name: Install uv
run: pip install uv

- name: Insert sample db data
- name: Create H3 extensions
run: |
export PGPASSWORD='admin';
psql -U postgres -h localhost -p 5434 raw < tests/fixtures/pokhara.sql
psql -U postgres -h localhost -p 5434 raw < backend/sql/countries.sql
psql -U postgres -h localhost -p 5434 raw < API/data/tables.sql
psql -U postgres -h localhost -p 5434 raw < API/data/cron.sql
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS postgis;"
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS h3;"
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS h3_postgis;"

- name: Install osm2pgsql for data loading
run: sudo apt-get install -y osm2pgsql

- name: Run Alembic migrations
run: |
uv sync --group backend
uv run alembic upgrade head

- name: Insert sample test data
run: uv run raw-backend --insert --fq m

- name: Install gdal
run: sudo apt-get update && sudo apt-get -y install gdal-bin python3-gdal && sudo apt-get -y autoremove && sudo apt-get clean
Expand All @@ -71,20 +85,14 @@ jobs:
sudo apt-get install redis
redis-cli ping

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python setup.py install

- name: Launch ondemand Worker
run: |
celery --app API.api_worker worker --loglevel=INFO --queues='raw_ondemand' &
uv run celery --app API.api_worker worker --loglevel=INFO --queues='raw_ondemand' &

- name: Launch daemon Worker
run: |
celery --app API.api_worker worker --loglevel=INFO --queues='raw_daemon' &
uv run celery --app API.api_worker worker --loglevel=INFO --queues='raw_daemon' &

- name: Run Tests
run: |
python -m pytest -v -s
uv run pytest -v -s
2 changes: 1 addition & 1 deletion .github/workflows/black-for-PR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
paths-ignore:
- 'infra/**'
branches:
- master
- stage
- develop
jobs:
linter_name:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/black-formatter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
paths-ignore:
- 'infra/**'
branches:
- master
- stage
- develop
jobs:
linter_name:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/build-postgres-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Build PostgreSQL with H3 Image

on:
push:
branches:
- develop
- stage
paths:
- 'Dockerfile.postgish3'
workflow_dispatch:

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.postgish3
push: true
tags: ghcr.io/hotosm/postgis-h3:latest
25 changes: 16 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ jobs:

services:
postgres:
image: postgis/postgis:14-3.3
image: ghcr.io/hotosm/postgis-h3:latest
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
POSTGRES_PASSWORD: admin
POSTGRES_DB: raw
Expand All @@ -33,20 +36,27 @@ jobs:
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 2
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.11
- name: Set up Python 3.12
uses: actions/setup-python@v1
with:
python-version: 3.11
python-version: 3.12
- name: Install uv
run: pip install uv
- name: Install necessary dependecies for rawdata loading
run: sudo apt-get update && sudo apt-get install osm2pgsql
- name: check version
run: osm2pgsql --version

- name: Create H3 extensions
run: |
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS h3;"
psql -U postgres -h localhost -p 5434 -d raw -c "CREATE EXTENSION IF NOT EXISTS h3_postgis;"

- name: Install python requirements for load
run: pip install -r backend/requirements.txt
run: uv sync --group backend

- name: Start Loading
run: python backend/raw_backend --insert --fq m
run: uv run raw-backend --insert --fq m

- name: Install gdal
run: |
Expand All @@ -62,10 +72,7 @@ jobs:
redis-cli ping

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install -e .
run: uv sync

- name: Run uvicorn server
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ on:
paths-ignore:
- "infra/**"
branches:
- master
- stage
- develop
pull_request:
branches:
- master
- stage
- develop
workflow_dispatch:
jobs:
Expand All @@ -23,8 +23,8 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8
pip install flake8-docstrings
pip install uv
uv pip install flake8 flake8-docstrings
- name: Lint with flake8 for src
run: |
flake8 src --count --select=E9,F63,F7,F82,D102 --docstring-convention numpy --show-source --statistics --ignore=E501,C901
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/docker-image-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ name: Docker Image CI
on:
push:
branches:
- master
- stage
- develop

pull_request:
branches:
- master
- stage
- develop
jobs:
build:
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/publish_mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches:
- develop
- master
- stage
paths:
# Only rebuild documentation when docs have changed
- "docs/**"
Expand All @@ -22,13 +22,14 @@ jobs:
publish_branch: gh-pages
- name: Install Dependencies
run: |
pip install -r requirements.txt
pip install mkdocs-material==8.5.11 mkdocs-jupyter==0.22.0 neoteroi-mkdocs==0.1.2 pdocs==1.0.1 lxml_html_clean==0.1.1
python setup.py install
pip install uv
uv sync
uv pip install mkdocs-material==8.5.11 mkdocs-jupyter==0.22.0 neoteroi-mkdocs==0.1.2 pdocs==1.0.1 lxml_html_clean==0.1.1
uv run python setup.py install
mv config.txt.sample config.txt

- name: Update API docs
run: |
pdocs as_markdown -o docs/src/api --exclude_source --overwrite src API
uv run pdocs as_markdown -o docs/src/api --exclude_source --overwrite src API
- name: Deploy Documentation
run: python -m mkdocs gh-deploy --force -f docs/mkdocs.yml
run: uv run python -m mkdocs gh-deploy --force -f docs/mkdocs.yml
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
27 changes: 14 additions & 13 deletions API/api_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
from celery import Celery

# Reader imports
from src.app import CustomExport, PolygonStats, RawData, S3FileTransfer
from src.config import ALLOW_BIND_ZIP_FILTER, CELERY_BROKER_HEARTBEAT
from src.config import CELERY_BROKER_URL as celery_broker_uri
from src.config import CELERY_RESULT_BACKEND as celery_backend
from src.app import CustomExport, RawData, S3FileTransfer
from src.config import (
ALLOW_BIND_ZIP_FILTER,
CELERY_BROKER_HEARTBEAT,
CELERY_WORKER_LOST_WAIT,
DEFAULT_HARD_TASK_LIMIT,
DEFAULT_README_TEXT,
Expand All @@ -29,9 +28,11 @@
EXPORT_PATH,
HDX_HARD_TASK_LIMIT,
HDX_SOFT_TASK_LIMIT,
WORKER_PREFETCH_MULTIPLIER,
)
from src.config import CELERY_BROKER_URL as celery_broker_uri
from src.config import CELERY_RESULT_BACKEND as celery_backend
from src.config import USE_S3_TO_UPLOAD as use_s3_to_upload
from src.config import WORKER_PREFETCH_MULTIPLIER
from src.config import logger as logging
from src.query_builder.builder import format_file_name_str
from src.validation.models import (
Expand Down Expand Up @@ -231,14 +232,14 @@ def process_raw_data(self, params, user=None):
).extract_current_data(file_parts)
inside_file_size = 0
polygon_stats = None
if "include_stats" in params.dict():
if params.include_stats:
feature = {
"type": "Feature",
"geometry": json.loads(params.geometry.model_dump_json()),
"properties": {},
}
polygon_stats = PolygonStats(feature).get_summary_stats()
# if "include_stats" in params.dict():
# if params.include_stats:
# feature = {
# "type": "Feature",
# "geometry": json.loads(params.geometry.model_dump_json()),
# "properties": {},
# }
# # polygon_stats = PolygonStats(feature).get_summary_stats()
if bind_zip:
upload_file_path, inside_file_size = zip_binding(
working_dir=working_dir,
Expand Down
Loading
Loading