Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specify IP in email + remove timeout stops #176

Merged
merged 4 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,17 @@
r = requests.patch(trial_url, data={"status": "error"},
headers = {"Authorization": "Token {}".format(API_TOKEN)})
traceback.print_exc()
args_as_strings = [str(arg) for arg in e.args]
if len(args_as_strings) > 1 and 'pose detection timed out' in args_as_strings[1].lower():
logging.info("Worker failed. Stopping machine.")
message = "A backend OpenCap machine timed out during pose detection. It has been stopped."
sendStatusEmail(message=message)
raise Exception('Worker failed. Stopped.')

# Antoine: Removing this, it is too often causing the machines to stop. Not because
# the machines are failing, but because for instance the video is very long with a lot
# of people in it. We should not stop the machine for that. Originally the check was
# to catch a bug where the machine would hang, I have not seen this bug in a long time.
# args_as_strings = [str(arg) for arg in e.args]
# if len(args_as_strings) > 1 and 'pose detection timed out' in args_as_strings[1].lower():
# logging.info("Worker failed. Stopping machine.")
# message = "A backend OpenCap machine timed out during pose detection. It has been stopped."
# sendStatusEmail(message=message)
# raise Exception('Worker failed. Stopped.')
justProcessed = True

# Clean data directory
Expand Down
10 changes: 6 additions & 4 deletions utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,10 @@ def sendStatusEmail(message=None,subject=None):
emailInfo = getStatusEmails()
if emailInfo is None:
return('No email info or wrong email info in env file.')

if 'ip' in emailInfo:
ip = emailInfo['ip']
message = message + ' IP: ' + ip

if message is None:
message = "A backend server is down and has been stopped."
Expand Down Expand Up @@ -1533,8 +1537,7 @@ def checkResourceUsage(stop_machine_and_email=True):

if stop_machine_and_email and resourceUsage['disk_perc'] > 95:

message = "Disc is full on an OpenCap machine backend machine: " \
+ socket.gethostname() + ". It has been stopped. Data: " \
message = "Disc is full on an OpenCap backend machine. It has been stopped. Data: " \
+ json.dumps(resourceUsage)
sendStatusEmail(message=message)

Expand All @@ -1551,8 +1554,7 @@ def checkCudaTF():
for gpu in gpus:
print(f"GPU: {gpu.name}")
else:
message = "Cuda check failed on an OpenCap machine backend machine: " \
+ socket.gethostname() + ". It has been stopped."
message = "Cuda check failed on an OpenCap backend machine. It has been stopped."
sendStatusEmail(message=message)
raise Exception("No GPU detected. Exiting.")

Expand Down
4 changes: 4 additions & 0 deletions utilsAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ def getStatusEmails():
emailInfo['toEmails'] = json.loads(config("STATUS_EMAIL_TO"))
except:
emailInfo = None
try:
emailInfo['ip'] = config("STATUS_EMAIL_IP")
except:
pass

return emailInfo

Expand Down
3 changes: 1 addition & 2 deletions utilsServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import requests
import json
import logging
import socket

from main import main
from utils import getDataDirectory
Expand Down Expand Up @@ -469,7 +468,7 @@ def runTestSession(pose='all',isDocker=True):
except:
logging.info("test trial failed. stopping machine.")
# send email
message = "A backend OpenCap machine failed the status check: " + socket.gethostname() + ". It has been stopped."
message = "A backend OpenCap machine failed the status check. It has been stopped."
sendStatusEmail(message=message)
raise Exception('Failed status check. Stopped.')

Expand Down
Loading