Skip to content

Commit

Permalink
Dump model and reload again for serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
kshitijrajsharma committed Dec 21, 2023
1 parent 49a406e commit 73f4280
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
9 changes: 8 additions & 1 deletion API/api_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@
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 DatasetConfig, RawDataOutputType
from src.validation.models import (
DatasetConfig,
DynamicCategoriesModel,
RawDataCurrentParams,
RawDataOutputType,
)

celery = Celery("Raw Data API")
celery.conf.broker_url = celery_broker_uri
Expand All @@ -32,6 +37,7 @@

@celery.task(bind=True, name="process_raw_data")
def process_raw_data(self, params):
params = RawDataCurrentParams(**params)
try:
start_time = dt.now()
bind_zip = params.bind_zip if ALLOW_BIND_ZIP_FILTER else True
Expand Down Expand Up @@ -188,6 +194,7 @@ def process_raw_data(self, params):

@celery.task(bind=True, name="process_hdx_request")
def process_hdx_request(self, params):
params = DynamicCategoriesModel(**params)
if not params.dataset:
params.dataset = DatasetConfig()
hdx_object = HDX(params)
Expand Down
2 changes: 1 addition & 1 deletion API/hdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,6 @@ async def process_hdx_requests(
"""
queue_name = "raw_special"
task = process_hdx_request.apply_async(
args=(params,), queue=queue_name, track_started=True
args=(params.model_dump(),), queue=queue_name, track_started=True
)
return JSONResponse({"task_id": task.id, "track_link": f"/tasks/status/{task.id}/"})
2 changes: 1 addition & 1 deletion API/raw_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def get_osm_current_snapshot_as_file(
# queue_name = "raw_special" if not params.uuid else "raw_default"
queue_name = "raw_default" # Everything directs to default now
task = process_raw_data.apply_async(
args=(params,), queue=queue_name, track_started=True
args=(params.model_dump(),), queue=queue_name, track_started=True
)
return JSONResponse({"task_id": task.id, "track_link": f"/tasks/status/{task.id}/"})

Expand Down

0 comments on commit 73f4280

Please sign in to comment.