Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature : HDX Exports #183

Merged
merged 20 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
1e2d025
Added HDX exporter class and converted legacy yaml to json format
kshitijrajsharma Dec 19, 2023
d8acc5e
added hdx python api in requirements
kshitijrajsharma Dec 19, 2023
8d6f61e
Upgrade python and added first version of hdx export
kshitijrajsharma Dec 19, 2023
79ffe07
Adds custom polygon support along with all other fields required for …
kshitijrajsharma Dec 20, 2023
2f5b15a
Remove test py and added hdx supported file formats
kshitijrajsharma Dec 20, 2023
9fa5019
Added multiple format support for hdx
kshitijrajsharma Dec 20, 2023
6c6f2be
updated typo
kshitijrajsharma Dec 20, 2023
60b66be
Added configurations , documentation and moved api logic to queue
kshitijrajsharma Dec 21, 2023
2376428
upgrade python to 3.10 for workflows
kshitijrajsharma Dec 21, 2023
91b06b5
Replace python version to specific version of 3.10
kshitijrajsharma Dec 21, 2023
fc6c4ad
Updated requirements , fixed typo error
kshitijrajsharma Dec 21, 2023
4129e75
Split requirement and fix typo in setup.py
kshitijrajsharma Dec 21, 2023
55b6750
Only import hdx config if it is enabled
kshitijrajsharma Dec 21, 2023
55aacbe
Remove training comma in import
kshitijrajsharma Dec 21, 2023
a72cee4
Install missing lib for unit test
kshitijrajsharma Dec 21, 2023
b3f0004
Only import sentry if config is supplied , Also adds documentation to…
kshitijrajsharma Dec 21, 2023
82bb633
Only import hdx related config if its in config enabled , added docs …
kshitijrajsharma Dec 21, 2023
f33a079
Added missing docstrings and also added default none to optional as p…
kshitijrajsharma Dec 21, 2023
eaacec5
Adds missing docstring in models
kshitijrajsharma Dec 21, 2023
cceba46
Adds authentication on hdx endpoints and modifies tasks endpoint to g…
kshitijrajsharma Dec 21, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/Unit-Test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ 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.8
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.10.13

- name: Insert sample db data
run: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ 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.8
- name: Set up Python 3.10
uses: actions/setup-python@v1
with:
python-version: 3.8
python-version: 3.10.13
- name: Install necessary dependecies for rawdata loading
run: sudo apt-get update && sudo apt-get install osm2pgsql
- name: check version
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/code-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Code Check - Linting using flake8
on:
push:
paths-ignore:
- 'infra/**'
- "infra/**"
branches:
- master
- develop
Expand All @@ -16,10 +16,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.10.13
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish_mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ on:
- master
paths:
# Only rebuild documentation when docs have changed
- 'docs/**'
- '.github/workflows/publish_mkdocs.yml'
- "docs/**"
- ".github/workflows/publish_mkdocs.yml"
permissions:
contents: write
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.8
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: 3.8
python-version: 3.10.13
publish_branch: gh-pages
- name: Install Dependencies
run: |
Expand Down
20 changes: 16 additions & 4 deletions API/api_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
import sozipfile.sozipfile as zipfile
from celery import Celery

from src.app import PolygonStats, RawData, S3FileTransfer
from src.app import HDX, PolygonStats, RawData, S3FileTransfer
from src.config import ALLOW_BIND_ZIP_FILTER
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 ENABLE_TILES
from src.config import USE_S3_TO_UPLOAD as use_s3_to_upload
from src.config import logger as logging
from src.query_builder.builder import format_file_name_str
from src.validation.models import RawDataOutputType
from src.validation.models import DatasetConfig, RawDataOutputType

celery = Celery("Raw Data API")
celery.conf.broker_url = celery_broker_uri
Expand Down Expand Up @@ -105,8 +105,8 @@ def process_raw_data(self, params):
readme_content += "Exported through Raw-data-api (https://github.com/hotosm/raw-data-api) using OpenStreetMap data.\n"
readme_content += "Learn more about OpenStreetMap and its data usage policy : https://www.openstreetmap.org/about \n"
if polygon_stats:
readme_content += f'{polygon_stats["summary"]["building"]}\n'
readme_content += f'{polygon_stats["summary"]["road"]}\n'
readme_content += f'{polygon_stats["summary"]["buildings"]}\n'
readme_content += f'{polygon_stats["summary"]["roads"]}\n'
readme_content += "Read about what this summary means: indicators: https://github.com/hotosm/raw-data-api/tree/develop/docs/src/stats/indicators.md,metrics: https://github.com/hotosm/raw-data-api/tree/develop/docs/src/stats/metrics.md"

zf.writestr("Readme.txt", readme_content)
Expand Down Expand Up @@ -186,6 +186,18 @@ def process_raw_data(self, params):
raise ex


@celery.task(bind=True, name="process_hdx_request")
def process_hdx_request(self, params):
if not params.dataset:
params.dataset = DatasetConfig()
hdx_object = HDX(params)
try:
return hdx_object.process_hdx_tags()
except Exception as ex:
hdx_object.clean_resources()
raise ex


def remove_file(path: str) -> None:
"""Used for removing temp file dir and its all content after zip file is delivered to user"""
try:
Expand Down
Loading
Loading