Skip to content

Commit

Permalink
temporarily upload_task is off
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenHosper committed Dec 18, 2024
1 parent b97edbe commit fe7c90f
Showing 1 changed file with 16 additions and 24 deletions.
40 changes: 16 additions & 24 deletions api/bro_upload/gld_bulk_upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def process(self) -> None:
self.bulk_upload_instance.save()

# Step 2: Prepare data for uploadtask per row
uploadtask_metadata = {
uploadtask_metadata = { # noqa: F841
"qualityRegime": self.bulk_upload_instance.metadata["qualityRegime"],
"requestReference": self.bulk_upload_instance.metadata["requestReference"],
}
Expand Down Expand Up @@ -136,40 +136,32 @@ def process(self) -> None:
measurement_tvps, self.bulk_upload_instance.sourcedocument_data
)

upload_task = api_models.UploadTask.objects.create(
data_owner=self.bulk_upload_instance.data_owner,
bro_domain="GLD",
project_number=self.bulk_upload_instance.project_number,
registration_type="GLD_Addition",
request_type="registration",
metadata=uploadtask_metadata,
sourcedocument_data=uploadtask_sourcedocument_dict,
)
self.bulk_upload_instance.sourcedocument_data = uploadtask_sourcedocument_dict

self.bulk_upload_instance.progress = 50.00
self.bulk_upload_instance.save()

# Wait while the GLD_Addition is being processed
time.sleep(10)
upload_task.refresh_from_db()
# upload_task.refresh_from_db()

if upload_task.status in ["COMPLETED", "FAILED"]:
self.bulk_upload_instance.progress = 100.00
# if upload_task.status in ["COMPLETED", "FAILED"]:
# self.bulk_upload_instance.progress = 100.00

if upload_task.status == "COMPLETED":
self.bulk_upload_instance.status = "FINISHED"
# if upload_task.status == "COMPLETED":
# self.bulk_upload_instance.status = "FINISHED"

elif upload_task.status == "FAILED":
self.bulk_upload_instance.status = "FAILED"
self.bulk_upload_instance.log += f"Upload logging: {upload_task.log}."
# elif upload_task.status == "FAILED":
# self.bulk_upload_instance.status = "FAILED"
# self.bulk_upload_instance.log += f"Upload logging: {upload_task.log}."

else:
self.bulk_upload_instance.status = "UNFINISHED"
self.bulk_upload_instance.log += (
"After 10 seconds the upload is not yet finished."
)
# else:
# self.bulk_upload_instance.status = "UNFINISHED"
# self.bulk_upload_instance.log += (
# "After 10 seconds the upload is not yet finished."
# )

self.bulk_upload_instance.save()
# self.bulk_upload_instance.save()


def csv_or_excel_to_df(file_instance: T) -> pl.DataFrame:
Expand Down

0 comments on commit fe7c90f

Please sign in to comment.