Skip to content

Commit

Permalink
Fixed error in upload registration and test_settings.py
Browse files Browse the repository at this point in the history
  • Loading branch information
crisingulani committed Jul 9, 2024
1 parent cdb4c5f commit 75ea5d4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/core/product_handle.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, filepath: PathLike):
match self.extension:
case ".csv":
self.handle = CsvHandle(fp)
case ".fits" | ".fit" | ".hf5" | ".hdf5" | ".h5" | ".pq":
case ".fits" | ".fit" | ".hf5" | ".hdf5" | ".h5" | ".pq" | ".parquet":
self.handle = TableIOHandle(fp)
case ".zip" | ".tar" | ".gz":
self.handle = CompressedHandle(fp)
Expand Down
12 changes: 8 additions & 4 deletions backend/core/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,13 @@ def check_processes_finish():
proc.status = proc_orchest_status
proc = update_dates(proc, proc_orchest)
proc.save()
register_outputs(proc.pk)
logger.info(f"-> Process {str(proc)} updated.")
procs_updated.append(proc_orches_id)

return procs_updated


def update_dates(process, data):
started_at = data.get('started_at', str(process.created_at))
ended_at = data.get('ended_at', str(timezone.now()))
Expand Down Expand Up @@ -84,6 +86,7 @@ def register_outputs(process_id):

try:
for output in outputs:
logger.debug('-> output: %s', output)
filepath = output.get('path')
rolename = output.get('role')
role_id = file_roles.get(rolename, file_roles.get('description'))
Expand All @@ -93,16 +96,17 @@ def register_outputs(process_id):

reg_product.registry()
process.upload.status = 1 # Published status
except Exception as error:
process.save()
except Exception as _:
process.upload.status = 9 # Failed status
logger.error("--> Failed to upload register <--")
logger.error(error)
process.save()
logger.exception("Failed to upload register!")

process.upload.save()

def copy_upload(filepath, upload_dir):
filepath = pathlib.Path(filepath)
new_filepath = pathlib.Path(settings.MEDIA_ROOT, upload_dir, filepath.name)
logger.debug('new_filepath -> %s', str(new_filepath))
shutil.copyfile(str(filepath), str(new_filepath))
return str(new_filepath)

Expand Down
7 changes: 7 additions & 0 deletions backend/pzserver/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,13 @@
# https://docs.djangoproject.com/en/4.1/ref/settings/#csrf-cookie-name
CSRF_COOKIE_NAME = "pzserver.csrftoken"

# Orchestration
ORCHEST_URL = os.getenv("ORCHEST_URL", None)

if ORCHEST_URL:
ORCHEST_CLIENT_ID = os.getenv("ORCHEST_CLIENT_ID")
ORCHEST_CLIENT_SECRET = os.getenv("ORCHEST_CLIENT_SECRET")

REST_FRAMEWORK = {
"DEFAULT_SCHEMA_CLASS": "drf_spectacular.openapi.AutoSchema",
"DEFAULT_AUTHENTICATION_CLASSES": (
Expand Down

0 comments on commit 75ea5d4

Please sign in to comment.