Skip to content

Commit

Permalink
Added destination in CallbackResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
Sara Veldhoen committed Aug 6, 2024
1 parent 70ee76d commit 15fb689
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions main_data_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,16 @@ def run(
# there must be an input file
if not input_file_path:
logger.error("input file empty")
return {"state": 403, "message": "Error, no input file"}, []
return {"state": 403, "message": "Error, no input file", "destination": ""}, []

# check if the file system is setup properly
if not validate_data_dirs():
logger.info("ERROR: data dirs not configured properly")
return {"state": 500, "message": "Input & output dirs not ok"}, []
return {
"state": 500,
"message": "Input & output dirs not ok",
"destination": "",
}, []

# create the top-level provenance
top_level_provenance = generate_initial_provenance(
Expand All @@ -74,6 +78,7 @@ def run(
return {
"state": 500,
"message": f"Could not download {input_file_path}",
"destination": "",
}, []
else:
download_provenance = to_download_provenance(
Expand Down Expand Up @@ -189,7 +194,11 @@ def apply_desired_io_on_output(
) -> CallbackResponse:
media_file = proc_result.media_file
if not media_file:
return {"state": 404, "message": "No media file in processing result"}
return {
"state": 404,
"message": "No media file in processing result",
"destination": "",
}
# step 4: raise exception on failure
if proc_result.state != 200:
logger.error(f"Could not process the input properly: {proc_result.message}")
Expand All @@ -198,7 +207,11 @@ def apply_desired_io_on_output(
)
logger.info(f"Deleted input file of failed process: {input_deleted}")
# something went wrong inside the VisXP work processor, return that response here
return {"state": proc_result.state, "message": proc_result.message}
return {
"state": proc_result.state,
"message": proc_result.message,
"destination": "",
}

# step 5: process returned successfully, generate the output
visxp_output_dir = get_base_output_dir(media_file.source_id)
Expand All @@ -216,6 +229,7 @@ def apply_desired_io_on_output(
return {
"state": 500,
"message": "Failed to transfer output to S3",
"destination": "",
}

# step 7: clear the output files (if configured so)
Expand Down

0 comments on commit 15fb689

Please sign in to comment.