Skip to content

Commit

Permalink
reac: refactor process_assets_from_odm function to reduce redundancy
Browse files Browse the repository at this point in the history
  • Loading branch information
Pradip-p committed Dec 13, 2024
1 parent f298f1e commit d4f0f35
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/backend/app/projects/image_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,11 @@ async def process_assets_from_odm(
log.info(f"Downloading results for task {dtm_project_id} to {output_file_path}")

assets_path = task.download_zip(output_file_path)
s3_path = f"dtm-data/projects/{dtm_project_id}/{dtm_task_id if dtm_task_id else ''}/assets.zip".strip(
"/"
)

s3_path = f"dtm-data/projects/{dtm_project_id}/assets.zip"

s3_path = f"dtm-data/projects/{dtm_project_id}/assets.zip"
log.info(f"Uploading {assets_path} to S3 path: {s3_path}")
Expand All @@ -396,15 +401,18 @@ async def process_assets_from_odm(
raise FileNotFoundError("Orthophoto file is missing")

reproject_to_web_mercator(orthophoto_path, orthophoto_path)

s3_ortho_path = (
f"dtm-data/projects/{dtm_project_id}/orthophoto/odm_orthophoto.tif"
s3_ortho_path = f"dtm-data/projects/{dtm_project_id}/{dtm_task_id if dtm_task_id else ''}/orthophoto/odm_orthophoto.tif".strip(
"/"
)

log.info(f"Uploading reprojected orthophoto to S3 path: {s3_ortho_path}")
add_file_to_bucket(settings.S3_BUCKET_NAME, orthophoto_path, s3_ortho_path)

images_json_path = os.path.join(output_file_path, "images.json")
s3_images_json_path = f"dtm-data/projects/{dtm_project_id}/images.json"
s3_images_json_path = f"dtm-data/projects/{dtm_project_id}/{dtm_task_id if dtm_task_id else ''}/images.json".strip(
"/"
)

log.info(f"Uploading images.json to S3 path: {s3_images_json_path}")
add_file_to_bucket(
settings.S3_BUCKET_NAME, images_json_path, s3_images_json_path
Expand Down

0 comments on commit d4f0f35

Please sign in to comment.