Skip to content

Commit 1da5dfa

Browse files
committed
fix linting errors
1 parent f7e8b19 commit 1da5dfa

3 files changed

Lines changed: 35 additions & 24 deletions

File tree

src/webapp/databricks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,4 +552,4 @@ def create_custom_schema_extension(
552552
existing_extension=extension_schema, # may be None
553553
)
554554

555-
return updated_extension
555+
return updated_extension

src/webapp/gcsutil.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,6 @@ def delete_batch_files(
272272
bucket_name: str,
273273
batch_files: list[str],
274274
) -> Any:
275-
276275
prefix = "validated/"
277276

278277
now_iso = datetime.datetime.now()
@@ -282,7 +281,13 @@ def delete_batch_files(
282281

283282
for fname in batch_files:
284283
if not isinstance(fname, str) or not fname.strip():
285-
errors.append({"file": str(fname), "path": f"{prefix}{fname}", "error": "invalid filename"})
284+
errors.append(
285+
{
286+
"file": str(fname),
287+
"path": f"{prefix}{fname}",
288+
"error": "invalid filename",
289+
}
290+
)
286291
continue
287292

288293
blob_path = f"{prefix}{fname}"
@@ -291,20 +296,26 @@ def delete_batch_files(
291296
# One-liner delete; raises NotFound if missing
292297
self.delete_file(bucket_name=bucket_name, file_name=blob_path)
293298
logger.info("Delete successful: gs://%s/%s", bucket_name, blob_path)
294-
deleted.append({"file": fname, "path": blob_path, "deleted_at": now_iso()})
299+
deleted.append(
300+
{"file": fname, "path": blob_path, "deleted_at": now_iso()}
301+
)
295302
except ValueError:
296-
logger.warning("Blob or bucket not found: gs://%s/%s", bucket_name, blob_path)
303+
logger.warning(
304+
"Blob or bucket not found: gs://%s/%s", bucket_name, blob_path
305+
)
297306
not_found.append(fname)
298307
except Exception as e: # network/other unexpected errors
299-
logger.exception("Unexpected error deleting gs://%s/%s", bucket_name, blob_path)
308+
logger.exception(
309+
"Unexpected error deleting gs://%s/%s", bucket_name, blob_path
310+
)
300311
errors.append({"file": fname, "path": blob_path, "error": str(e)})
301312

302313
return {
303314
"deleted": deleted,
304315
"not_found": not_found,
305316
"errors": errors,
306317
}
307-
318+
308319
def validate_file(
309320
self,
310321
bucket_name: str,

src/webapp/routers/data.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ def update_batch(
683683
"updated_at": query_result[0][0].updated_at,
684684
}
685685

686+
686687
@router.patch("/{inst_id}/delete-batch/{batch_id}", response_model=BatchInfo)
687688
def delete_batch(
688689
inst_id: str,
@@ -697,26 +698,25 @@ def delete_batch(
697698
local_session.set(sql_session)
698699
sess = local_session.get()
699700

700-
batch = (
701-
sess.execute(
702-
select(BatchTable).where(
703-
BatchTable.id == str_to_uuid(batch_id),
704-
BatchTable.inst_id == str_to_uuid(inst_id),
705-
)
701+
batch = sess.execute(
702+
select(BatchTable).where(
703+
BatchTable.id == str_to_uuid(batch_id),
704+
BatchTable.inst_id == str_to_uuid(inst_id),
706705
)
707-
.scalar_one_or_none()
708-
)
706+
).scalar_one_or_none()
709707
if batch is None:
710-
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Batch not found.")
708+
raise HTTPException(
709+
status_code=status.HTTP_404_NOT_FOUND, detail="Batch not found."
710+
)
711711

712712
# 2) Gather filenames to delete
713713
batch_files: list[str] = (
714714
sess.execute(
715715
select(FileTable.name).where(
716-
FileTable.id == str_to_uuid(batch_id),
717-
FileTable.inst_id == str_to_uuid(inst_id),
718-
)
716+
FileTable.id == str_to_uuid(batch_id),
717+
FileTable.inst_id == str_to_uuid(inst_id),
719718
)
719+
)
720720
.scalars()
721721
.all()
722722
)
@@ -736,16 +736,15 @@ def delete_batch(
736736
}
737737

738738
gcs_result = storage_control.delete_batch_files(
739-
bucket_name= get_external_bucket_name(inst_id),
740-
batch_files= batch_files
739+
bucket_name=get_external_bucket_name(inst_id), batch_files=batch_files
741740
)
742741

743742
if gcs_result.get("errors"):
744743
raise HTTPException(
745744
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
746745
detail=f"Unable to delete files {gcs_result['errors']}.",
747746
)
748-
747+
749748
# 4) Delete DB rows only for blobs that were actually deleted
750749
deleted_names = {d["file"] for d in gcs_result.get("deleted", [])}
751750
not_found_names = set(gcs_result.get("not_found", []))
@@ -781,17 +780,18 @@ def delete_batch(
781780
raise HTTPException(
782781
status_code=500, detail=f"DB batch delete failed after file cleanup: {e}"
783782
)
784-
783+
785784
return {
786785
"inst_id": inst_id,
787786
"batch_id": batch_id,
788-
"deleted": gcs_result.get("deleted", []), # [{file, path, deleted_at}, ...]
787+
"deleted": gcs_result.get("deleted", []), # [{file, path, deleted_at}, ...]
789788
"not_found": sorted(not_found_names),
790789
"errors": gcs_result.get("errors", []),
791790
"db_deleted_rows": db_deleted_rows,
792791
"batch_deleted": True,
793792
}
794793

794+
795795
@router.get("/{inst_id}/file-id/{file_id}", response_model=DataInfo)
796796
def read_file_id_info(
797797
inst_id: str,

0 commit comments

Comments
 (0)