Skip to content

Commit

Permalink
Merge pull request #172 from hotosm/hotfix/hdx_folder_structure
Browse files Browse the repository at this point in the history
Bug Fix : HDX Folder Structure on S3
  • Loading branch information
kshitijrajsharma authored Nov 20, 2023
2 parents 141f556 + a1121f9 commit 03b1bcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions API/api_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
celery.conf.task_serializer = "pickle"
celery.conf.result_serializer = "pickle"
celery.conf.accept_content = ["application/json", "application/x-python-serialize"]
celery.conf.task_track_started = True


@celery.task(bind=True, name="process_raw_data")
Expand Down Expand Up @@ -83,6 +84,7 @@ def process_raw_data(self, params):
if use_s3_to_upload:
file_transfer_obj = S3FileTransfer()
upload_name = exportname if params.uuid else f"Recurring/{exportname}"
logging.error(exportname)
if exportname.startswith("hotosm_project"): # TM
if not params.uuid:
pattern = r"(hotosm_project_)(\d+)"
Expand All @@ -94,12 +96,13 @@ def process_raw_data(self, params):
upload_name = f"TM/{project_number}/{exportname}"
elif exportname.startswith("hotosm_"): # HDX
if not params.uuid:
pattern = r"hotosm_([A-Z]{3})_(\w+)"
pattern = r"hotosm_([A-Za-z]{3})_(\w+)"
match = re.match(pattern, exportname)

if match:
iso3countrycode = match.group(1)
if iso3countrycode:
upload_name = f"HDX/{iso3countrycode}/{exportname}"
upload_name = f"HDX/{iso3countrycode.upper()}/{exportname}"

download_url = file_transfer_obj.upload(
upload_file_path,
Expand Down
6 changes: 3 additions & 3 deletions API/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ def revoke_task(task_id, user: AuthUser = Depends(staff_required)):
task_id (_type_): task id of raw data task
Returns:
status: status of revoked task
id: id of revoked task
"""
revoked_task = celery.control.revoke(task_id=task_id, terminate=True)
return JSONResponse({"id": task_id, "status": revoked_task})
celery.control.revoke(task_id=task_id, terminate=True)
return JSONResponse({"id": task_id})


@router.get("/inspect/")
Expand Down

0 comments on commit 03b1bcc

Please sign in to comment.