-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from hotosm/enhance/queue-name
Enhance : Queue name and workers name
- Loading branch information
Showing
10 changed files
with
320 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,7 @@ | |
# 1100 13th Street NW Suite 800 Washington, D.C. 20005 | ||
# <[email protected]> | ||
"""Page contains Main core logic of app""" | ||
# Standard library imports | ||
import concurrent.futures | ||
import json | ||
import os | ||
|
@@ -32,6 +33,7 @@ | |
from json import dumps | ||
from json import loads as json_loads | ||
|
||
# Third party imports | ||
import boto3 | ||
import humanize | ||
import orjson | ||
|
@@ -44,6 +46,7 @@ | |
from psycopg2.extras import DictCursor | ||
from slugify import slugify | ||
|
||
# Reader imports | ||
from src.config import ( | ||
AWS_ACCESS_KEY_ID, | ||
AWS_SECRET_ACCESS_KEY, | ||
|
@@ -89,27 +92,35 @@ | |
from src.validation.models import EXPORT_TYPE_MAPPING, RawDataOutputType | ||
|
||
if ENABLE_SOZIP: | ||
# Third party imports | ||
import sozipfile.sozipfile as zipfile | ||
else: | ||
# Standard library imports | ||
import zipfile | ||
|
||
# import instance for pooling | ||
if use_connection_pooling: | ||
# Reader imports | ||
from src.db_session import database_instance | ||
else: | ||
database_instance = None | ||
# Standard library imports | ||
import logging as log | ||
|
||
if ENABLE_CUSTOM_EXPORTS: | ||
if USE_DUCK_DB_FOR_CUSTOM_EXPORTS is True: | ||
# Third party imports | ||
import duckdb | ||
|
||
# Reader imports | ||
from src.config import DUCK_DB_MEMORY_LIMIT, DUCK_DB_THREAD_LIMIT | ||
|
||
if ENABLE_HDX_EXPORTS: | ||
# Third party imports | ||
from hdx.data.dataset import Dataset | ||
from hdx.data.resource import Resource | ||
|
||
# Reader imports | ||
from src.config import HDX_MAINTAINER, HDX_OWNER_ORG, HDX_URL_PREFIX | ||
|
||
|
||
|
@@ -1451,7 +1462,7 @@ def process_export_format(export_format): | |
and PARALLEL_PROCESSING_CATEGORIES is True | ||
): | ||
logging.info( | ||
"Using Parallel Processing for %s Export formats", category_name.lower() | ||
"Using Parallel Processing for %s Export formats with total %s workers", category_name.lower(), os.cpu_count() | ||
) | ||
with concurrent.futures.ThreadPoolExecutor( | ||
max_workers=os.cpu_count() | ||
|
@@ -1925,7 +1936,7 @@ def create_hdx(self, hdx_data): | |
hdx_data.get("iso3", None), | ||
hdx_data.get("hdx_upload", True), | ||
json.dumps(hdx_data.get("dataset")), | ||
hdx_data.get("queue", "raw_daemon"), | ||
hdx_data.get("queue", "raw_ondemand"), | ||
hdx_data.get("meta", False), | ||
json.dumps(hdx_data.get("categories", {})), | ||
json.dumps(hdx_data.get("geometry")), | ||
|
@@ -2055,7 +2066,7 @@ def update_hdx(self, hdx_id: int, hdx_data): | |
hdx_data.get("iso3", None), | ||
hdx_data.get("hdx_upload", True), | ||
json.dumps(hdx_data.get("dataset")), | ||
hdx_data.get("queue", "raw_daemon"), | ||
hdx_data.get("queue", "raw_ondemand"), | ||
hdx_data.get("meta", False), | ||
json.dumps(hdx_data.get("categories", {})), | ||
json.dumps(hdx_data.get("geometry")), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,12 +19,13 @@ | |
# 1100 13th Street NW Suite 800 Washington, D.C. 20005 | ||
# <[email protected]> | ||
|
||
import errno | ||
# Standard library imports | ||
import logging | ||
import os | ||
from configparser import ConfigParser | ||
from distutils.util import strtobool | ||
|
||
# Third party imports | ||
from slowapi import Limiter | ||
from slowapi.util import get_remote_address | ||
|
||
|
@@ -198,10 +199,10 @@ def not_raises(func, *args, **kwargs): | |
# Queue | ||
|
||
DEFAULT_QUEUE_NAME = os.environ.get("DEFAULT_QUEUE_NAME") or config.get( | ||
"API_CONFIG", "DEFAULT_QUEUE_NAME", fallback="raw_ondemand" | ||
"API_CONFIG", "DEFAULT_QUEUE_NAME", fallback="raw_daemon" | ||
) | ||
DAEMON_QUEUE_NAME = os.environ.get("DAEMON_QUEUE_NAME") or config.get( | ||
"API_CONFIG", "DAEMON_QUEUE_NAME", fallback="raw_daemon" | ||
ONDEMAND_QUEUE_NAME = os.environ.get("ONDEMAND_QUEUE_NAME") or config.get( | ||
"API_CONFIG", "ONDEMAND_QUEUE_NAME", fallback="raw_ondemand" | ||
) | ||
|
||
# Polygon statistics which will deliver the stats of approx buildings/ roads in the area | ||
|
@@ -296,6 +297,7 @@ def not_raises(func, *args, **kwargs): | |
) | ||
|
||
else: | ||
# Standard library imports | ||
import json | ||
|
||
hdx_credentials_json = json.loads(hdx_credentials) | ||
|
@@ -307,8 +309,8 @@ def not_raises(func, *args, **kwargs): | |
|
||
if None in (HDX_SITE, HDX_API_KEY, HDX_OWNER_ORG, HDX_MAINTAINER): | ||
raise ValueError("HDX Remote Credentials Malformed") | ||
logging.error("HDX Remote Credentials Malformed") | ||
|
||
# Third party imports | ||
from hdx.api.configuration import Configuration | ||
|
||
try: | ||
|
@@ -325,6 +327,7 @@ def not_raises(func, *args, **kwargs): | |
ENABLE_HDX_EXPORTS = False | ||
|
||
if ENABLE_HDX_EXPORTS: | ||
# Third party imports | ||
from hdx.data.dataset import Dataset | ||
from hdx.data.vocabulary import Vocabulary | ||
|
||
|
@@ -377,6 +380,7 @@ def get_db_connection_params() -> dict: | |
) | ||
|
||
else: | ||
# Standard library imports | ||
import json | ||
|
||
connection_params = json.loads(db_credentials) | ||
|
@@ -442,6 +446,7 @@ def get_oauth_credentials() -> tuple: | |
) | ||
|
||
else: | ||
# Standard library imports | ||
import json | ||
|
||
oauth2_credentials_json = json.loads(oauth2_credentials) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,16 +17,19 @@ | |
# 1100 13th Street NW Suite 800 Washington, D.C. 20005 | ||
# <[email protected]> | ||
"""Page contains validation models for application""" | ||
# Standard library imports | ||
import json | ||
from enum import Enum | ||
from typing import Dict, List, Optional, Union | ||
|
||
# Third party imports | ||
from geojson_pydantic import Feature, FeatureCollection, MultiPolygon, Polygon | ||
from geojson_pydantic.types import BBox | ||
from pydantic import BaseModel as PydanticModel | ||
from pydantic import Field, validator | ||
from typing_extensions import TypedDict | ||
|
||
# Reader imports | ||
from src.config import ( | ||
ALLOW_BIND_ZIP_FILTER, | ||
ENABLE_HDX_EXPORTS, | ||
|
@@ -35,6 +38,7 @@ | |
) | ||
|
||
if ENABLE_HDX_EXPORTS: | ||
# Reader imports | ||
from src.config import ALLOWED_HDX_TAGS, ALLOWED_HDX_UPDATE_FREQUENCIES | ||
|
||
|
||
|
@@ -296,22 +300,22 @@ class StatsRequestParams(BaseModel, GeometryValidatorMixin): | |
max_length=3, | ||
example="NPL", | ||
) | ||
geometry: Optional[ | ||
Union[Polygon, MultiPolygon, Feature, FeatureCollection] | ||
] = Field( | ||
default=None, | ||
example={ | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[83.96919250488281, 28.194446860487773], | ||
[83.99751663208006, 28.194446860487773], | ||
[83.99751663208006, 28.214869548073377], | ||
[83.96919250488281, 28.214869548073377], | ||
[83.96919250488281, 28.194446860487773], | ||
] | ||
], | ||
}, | ||
geometry: Optional[Union[Polygon, MultiPolygon, Feature, FeatureCollection]] = ( | ||
Field( | ||
default=None, | ||
example={ | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[83.96919250488281, 28.194446860487773], | ||
[83.99751663208006, 28.194446860487773], | ||
[83.99751663208006, 28.214869548073377], | ||
[83.96919250488281, 28.214869548073377], | ||
[83.96919250488281, 28.194446860487773], | ||
] | ||
], | ||
}, | ||
) | ||
) | ||
|
||
@validator("geometry", pre=True, always=True) | ||
|
@@ -583,7 +587,7 @@ class DynamicCategoriesModel(BaseModel, GeometryValidatorMixin): | |
default=None, description="Dataset Configurations for HDX Upload" | ||
) | ||
queue: Optional[str] = Field( | ||
default="raw_daemon", | ||
default="raw_ondemand", | ||
description="Lets you decide which queue you wanna place your task, Requires admin access", | ||
) | ||
meta: bool = Field( | ||
|
@@ -608,22 +612,22 @@ class DynamicCategoriesModel(BaseModel, GeometryValidatorMixin): | |
} | ||
], | ||
) | ||
geometry: Optional[ | ||
Union[Polygon, MultiPolygon, Feature, FeatureCollection] | ||
] = Field( | ||
default=None, | ||
example={ | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[83.96919250488281, 28.194446860487773], | ||
[83.99751663208006, 28.194446860487773], | ||
[83.99751663208006, 28.214869548073377], | ||
[83.96919250488281, 28.214869548073377], | ||
[83.96919250488281, 28.194446860487773], | ||
] | ||
], | ||
}, | ||
geometry: Optional[Union[Polygon, MultiPolygon, Feature, FeatureCollection]] = ( | ||
Field( | ||
default=None, | ||
example={ | ||
"type": "Polygon", | ||
"coordinates": [ | ||
[ | ||
[83.96919250488281, 28.194446860487773], | ||
[83.99751663208006, 28.194446860487773], | ||
[83.99751663208006, 28.214869548073377], | ||
[83.96919250488281, 28.214869548073377], | ||
[83.96919250488281, 28.194446860487773], | ||
] | ||
], | ||
}, | ||
) | ||
) | ||
|
||
@validator("geometry", pre=True, always=True) | ||
|