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

Bugfix for jobs running on multiple nodes. #1

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
4 changes: 2 additions & 2 deletions cloud_interface.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ then
# Check if last_execution_time file exists
if [ -f last_update ]; then
# Read the last execution time from the file
last_update=$(cat .last_update)
last_update=$(cat last_update)
else
# If the file doesn't exist, initialize the last execution time to 0
last_update=0
Expand Down Expand Up @@ -202,4 +202,4 @@ else
else
printf "HTTP/1.1 503 Service Unavailable\r\nContent-Type: text/html; charset=UTF-8\r\nDate: $(date -R)\r\nServer: KISSKI\r\n\r\nConnection to model broke\r\n"
fi
fi
fi
26 changes: 18 additions & 8 deletions scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
def get_squeue_status():
squeue_output = subprocess.run(
[squeue_path, '--me', '-h', '--name=service-backend',
'--format="{\"JOBID\": \"%.18i\", \"STATE\": \"%.2t\", \"TIME\": \"%.10M\", \"TIME_LIMIT\": \"%.9l\", \"NODELIST\": \"%N\"}"'],
'--format="{\"JOBID\": \"%.18i\", \"STATE\": \"%.2t\", \"TIME\": \"%.10M\", \"TIME_LIMIT\": \"%.9l\", \"BATCHHOST\": \"%B\"}"'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE).stdout.decode('utf-8')
lines = squeue_output.split("\n")
lines = [" ".join(line.split()).strip("\"") for line in lines]
Expand All @@ -57,12 +57,22 @@ def generate_random_port_number(excluded: set) -> int:


def squeue_time_to_timedelta(time_str):
try:
minutes, seconds = map(int, time_str.split(':'))
except:
hours, minutes, seconds = map(int, time_str.split(':'))
return timedelta(hours=hours, minutes=minutes, seconds=seconds)
return timedelta(minutes=minutes, seconds=seconds)
if '-' in time_str:
days_part, time_part = time_str.split('-')
days = int(days_part)
# Process the rest as hours:minutes:seconds
hours, minutes, seconds = map(int, time_part.split(':'))
else:
days = 0
time_parts = time_str.split(':')
if len(time_parts) == 2: # MM:SS
hours = 0
minutes, seconds = map(int, time_parts)
elif len(time_parts) == 3: # HH:MM:SS
hours, minutes, seconds = map(int, time_parts)
else:
raise ValueError("Invalid time format: {time_str}")
return timedelta(days=days, hours=hours, minutes=minutes, seconds=seconds)


def test_readiness(host, port):
Expand Down Expand Up @@ -112,7 +122,7 @@ def from_squeue(self, squeue_line):
self.status = squeue_json["STATE"].strip()
self.time = squeue_json["TIME"].strip()
self.time_limit = squeue_json["TIME_LIMIT"].strip()
self.host = squeue_json["NODELIST"].strip()
self.host = squeue_json["BATCHHOST"].strip()

def is_about_to_expire(self):
#time = squeue_time_to_timedelta(self.time)
Expand Down