-
Notifications
You must be signed in to change notification settings - Fork 29
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
Dispatch jobs of different architectures onto matching machines. #119
Open
tdaede
wants to merge
1
commit into
master
Choose a base branch
from
split
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,10 +103,7 @@ def run(self): | |
run.rundir = config['runs'] + '/' + run_id | ||
run.log = log_file | ||
run.set = info['task'] | ||
if 'arch' in info: | ||
run.arch = info['arch'] | ||
else: | ||
run.arch = 'x86_64' | ||
run.arch = info.get('arch', 'x86_64') | ||
run.bindir = run.rundir + '/' + run.arch + '/' | ||
run.prefix = run.rundir + '/' + run.set | ||
try: | ||
|
@@ -209,6 +206,8 @@ def main(): | |
global machines | ||
global slots | ||
global args | ||
global arches | ||
arches = set() | ||
parser = argparse.ArgumentParser(description='Run AWCY scheduler daemon.') | ||
parser.add_argument('-machineconf') | ||
parser.add_argument('-port',default=4000) | ||
|
@@ -218,7 +217,10 @@ def main(): | |
if args.machineconf: | ||
machineconf = json.load(open(args.machineconf, 'r')) | ||
for m in machineconf: | ||
machines.append(sshslot.Machine(m['host'],m['user'],m['cores'],m['work_root'],str(m['port']),m['media_path'])) | ||
if 'arch' not in m: | ||
m['arch'] = 'x86_64' | ||
machines.append(sshslot.Machine(m['host'],m['user'],m['cores'],m['work_root'],str(m['port']),m['media_path'],m['arch'])) | ||
arches.add(m['arch']) | ||
for machine in machines: | ||
slots.extend(machine.get_slots()) | ||
free_slots.extend(reversed(slots)) | ||
|
@@ -249,6 +251,7 @@ def machine_allocator_tick(): | |
global machines | ||
global work_list | ||
global run_list | ||
global arches | ||
# start all machines if we don't have any but have work queued | ||
if len(work_list) and not len(machines): | ||
rd_print(None, "Starting machines.") | ||
|
@@ -338,21 +341,25 @@ def scheduler_tick(): | |
slot.clear_work() | ||
free_slots.append(slot) | ||
# fill empty slots with new work | ||
if len(work_list) != 0: | ||
if len(free_slots) != 0: | ||
slot = free_slots.pop() | ||
work = work_list[0] | ||
# search for image work if there is only one slot available | ||
# allows prioritizing image runs without making scheduler the bottleneck | ||
if len(free_slots) == 0: | ||
try: | ||
work = find_image_work(work_list, work) | ||
except Exception as e: | ||
rd_print(None, e) | ||
rd_print(None, 'Finding image work failed.') | ||
work_list.remove(work) | ||
rd_print(work.log,'Encoding',work.get_name(),'on',slot.machine.host) | ||
slot.start_work(work) | ||
for arch in arches: | ||
free_slots_filtered = [slot for slot in free_slots if slot.arch == arch] | ||
work_list_filtered = [work for work in work_list if work.arch == arch] | ||
if len(work_list_filtered) != 0: | ||
if len(free_slots_filtered) != 0: | ||
slot = free_slots_filtered.pop() | ||
free_slots.remove(slot) | ||
work = work_list_filtered[0] | ||
# search for image work if there is only one slot available | ||
# allows prioritizing image runs without making scheduler the bottleneck | ||
if len(free_slots_filtered) == 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
try: | ||
work = find_image_work(work_list_filtered, work) | ||
except Exception as e: | ||
rd_print(None, e) | ||
rd_print(None, 'Finding image work failed.') | ||
work_list.remove(work) | ||
rd_print(work.log,'Encoding',work.get_name(),'on',slot.machine.host) | ||
slot.start_work(work) | ||
# find runs where all work has been completed | ||
for run in run_list: | ||
done = True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: PEP-8 says you should just do: