Skip to content

Commit 95cd5f6

Browse files
authored
0.2.1
* env tweak for task expiry name
1 parent d388372 commit 95cd5f6

File tree

5 files changed

+24
-10
lines changed

5 files changed

+24
-10
lines changed

.github/workflows/build_dev.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- develop
99

1010
env:
11-
VERSION: 0.2.0
11+
VERSION: 0.2.1
1212
REGISTRY: ghcr.io
1313
IMAGE_NAME: ${{ github.repository }}
1414

.github/workflows/build_prod_and_release.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ on:
88
- master
99

1010
env:
11-
VERSION: 0.2.0
11+
VERSION: 0.2.1
1212
REGISTRY: ghcr.io
1313
IMAGE_NAME: ${{ github.repository }}
1414

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ export AUTOPKG_POSTGRES_PORT= # Used for API Boundaries only (and test natural_e
159159
export AUTOPKG_POSTGRES_DB= # Used for API Boundaries only (and test natural_earth_vector processor in Worker)
160160
export AUTOPKG_CELERY_BROKER= # Used for Worker only
161161
export AUTOPKG_CELERY_BACKEND= # Used in API and Worker
162+
export AUTOPKG_CELERY_CONCURRENCY= # Celery worker concurrency - dataproc only
163+
export AUTOPKG_TASK_LOCK_TIMEOUT=600 # Secs - Duplicate task lock timeout (blocks duplicate processors from executing for this time)
164+
export AUTOPKG_TASK_EXPIRY_SECS=3600 # Secs before tasks expire on Celery - dataproc only
162165
export AUTOPKG_STORAGE_BACKEND= # Storage backend to use for final packages (see additional backend-specific flags below for more info). Used in API and Worker
163166
export AUTOPKG_LOCALFS_STORAGE_BACKEND_ROOT= # Path to root-directory for packages. Used in API and Worker
164167
export AUTOPKG_LOCALFS_PROCESSING_BACKEND_ROOT= # Path to root-directory for local interim processing data. Used by Worker only

config.py

+18-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import sqlalchemy as sa
99
from celery import Celery
1010

11+
1112
def get_db_uri(
1213
dbname: str,
1314
username_env="AUTOPKG_POSTGRES_USER",
@@ -25,6 +26,7 @@ def get_db_uri(
2526
database=dbname,
2627
)
2728

29+
2830
def get_db_uri_ogr(
2931
dbname: str,
3032
username_env="AUTOPKG_POSTGRES_USER",
@@ -52,7 +54,7 @@ def get_db_uri_sync(
5254
password_env="AUTOPKG_POSTGRES_PASSWORD",
5355
host_env="AUTOPKG_POSTGRES_HOST",
5456
port_env="AUTOPKG_POSTGRES_PORT",
55-
) -> sa.engine.URL:
57+
) -> sa.engine.URL:
5658
"""Standard user DBURI - non-async"""
5759
return sa.engine.URL.create(
5860
drivername="postgresql+psycopg2",
@@ -63,6 +65,7 @@ def get_db_uri_sync(
6365
database=dbname,
6466
)
6567

68+
6669
# DATAPROC VARS
6770
REDIS_HOST = getenv("AUTOPKG_REDIS_HOST", "localhost")
6871
TASK_LOCK_TIMEOUT = int(
@@ -79,6 +82,7 @@ def get_db_uri_sync(
7982
# Celery Env
8083
CELERY_BROKER = getenv("AUTOPKG_CELERY_BROKER", "redis://localhost")
8184
CELERY_BACKEND = getenv("AUTOPKG_CELERY_BACKEND", "redis://localhost")
85+
CELERY_CONCURRENCY = int(getenv("AUTOPKG_CELERY_CONCURRENCY", "2"))
8286
REDIS_HOST = getenv("AUTOPKG_REDIS_HOST", "localhost")
8387
TASK_LOCK_TIMEOUT = getenv("AUTOPKG_TASK_LOCK_TIMEOUT", "600")
8488

@@ -98,9 +102,15 @@ def get_db_uri_sync(
98102
if getenv("AUTOPKG_DEPLOYMENT_ENV", "prod") == "test":
99103
# TEST
100104
# The root-level folder when using localfs storage backend
101-
LOCALFS_STORAGE_BACKEND_ROOT = getenv("AUTOPKG_LOCALFS_STORAGE_BACKEND_ROOT_TEST", path.join(path.dirname(path.abspath(__file__)), "tests", "data", "packages"))
105+
LOCALFS_STORAGE_BACKEND_ROOT = getenv(
106+
"AUTOPKG_LOCALFS_STORAGE_BACKEND_ROOT_TEST",
107+
path.join(path.dirname(path.abspath(__file__)), "tests", "data", "packages"),
108+
)
102109
# The root-level folder when using localfs processing backend
103-
LOCALFS_PROCESSING_BACKEND_ROOT = getenv("AUTOPKG_LOCALFS_PROCESSING_BACKEND_ROOT_TEST", path.join(path.dirname(path.abspath(__file__)), "tests", "data", "processing"))
110+
LOCALFS_PROCESSING_BACKEND_ROOT = getenv(
111+
"AUTOPKG_LOCALFS_PROCESSING_BACKEND_ROOT_TEST",
112+
path.join(path.dirname(path.abspath(__file__)), "tests", "data", "processing"),
113+
)
104114
# Integration tests which require access to the GRIOSM Postgres instance will be run if this is set-True (1)
105115
TEST_GRI_OSM = bool(int(getenv("TEST_GRI_OSM", "0")))
106116
else:
@@ -117,10 +127,11 @@ def get_db_uri_sync(
117127
DBURI_API = get_db_uri(API_POSTGRES_DB)
118128
CELERY_APP = Celery(
119129
"AutoPackage",
120-
worker_prefetch_multiplier=1,
130+
worker_prefetch_multiplier=1, # Do not change - long running tasks require this. See: https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-worker_prefetch_multiplier
131+
worker_concurrency=CELERY_CONCURRENCY,
121132
broker_url=CELERY_BROKER,
122-
result_backend=CELERY_BACKEND
123-
) # see: https://docs.celeryq.dev/en/stable/userguide/configuration.html#std-setting-worker_prefetch_multiplier
133+
result_backend=CELERY_BACKEND,
134+
)
124135

125136
# Seconds before submitted tasks expire
126-
TASK_EXPIRY_SECS = int(getenv("TASK_EXPIRY_SECS", "3600"))
137+
TASK_EXPIRY_SECS = int(getenv("AUTOPKG_TASK_EXPIRY_SECS", "3600"))

docker-compose.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ services:
5151
- ./tests/data/tmp:/usr/src/app/tests/data/tmp
5252
env_file:
5353
- envs/.api_and_dataproc.env
54-
command: celery --app dataproc.tasks worker --loglevel=debug --concurrency=4
54+
command: celery --app dataproc.tasks worker
5555

5656
api:
5757
image: ghcr.io/nismod/irv-autopkg:0.2.0-dev

0 commit comments

Comments
 (0)