Skip to content

Commit

Permalink
Merge pull request #210 from stanfordnmbl/update-duration-always
Browse files Browse the repository at this point in the history
update duration in database also when a trial fails to process
  • Loading branch information
carmichaelong authored Oct 29, 2024
2 parents c3a5aa8 + c25011d commit 8f7c2ee
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,16 +147,13 @@
# trigger reset of timer for last processed trial
processTrial(trial["session"], trial["id"], trial_type=trial_type, isDocker=isDocker)

# End process duration timer and post duration to database
process_end_time = datetime.now()
postProcessedDuration(trial_url, process_end_time - process_start_time)

# note a result needs to be posted for the API to know we finished, but we are posting them
# automatically thru procesTrial now
r = requests.patch(trial_url, data={"status": "done"},
headers = {"Authorization": "Token {}".format(API_TOKEN)})
logging.info('0.5s pause if need to restart.')
time.sleep(0.5)

except Exception as e:
r = requests.patch(trial_url, data={"status": "error"},
headers = {"Authorization": "Token {}".format(API_TOKEN)})
Expand All @@ -172,6 +169,12 @@
# message = "A backend OpenCap machine timed out during pose detection. It has been stopped."
# sendStatusEmail(message=message)
# raise Exception('Worker failed. Stopped.')

finally:
# End process duration timer and post duration to database
process_end_time = datetime.now()
postProcessedDuration(trial_url, process_end_time - process_start_time)

justProcessed = True

# Clean data directory
Expand Down

0 comments on commit 8f7c2ee

Please sign in to comment.