Commit a09af71f authored by Brewer, Wes's avatar Brewer, Wes
Browse files

Fix a couple of bugs that were introduced in the policy refactoring

parent 8b0bb67a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ parser.add_argument('-p', '--plot', nargs='+', choices=['power', 'loss', 'pue',
choices = ['png', 'svg', 'jpg', 'pdf', 'eps']
parser.add_argument('--imtype', type=str, choices=choices, default=choices[0], help='Plot image type')
parser.add_argument('--system', type=str, default='frontier', help='System config to use')
choices = ['fcfs', 'sjf', 'prq', 'backfill']
choices = ['fcfs', 'sjf', 'priority', 'backfill']
parser.add_argument('-s', '--schedule', type=str, choices=choices, default=choices[0], help='Schedule policy to use')
choices = ['random', 'benchmark', 'peak', 'idle']
parser.add_argument('-w', '--workload', type=str, choices=choices, default=choices[0], help='Type of synthetic workload')
+3 −3
Original line number Diff line number Diff line
@@ -5,16 +5,16 @@ class PolicyType(Enum):
    BACKFILL = 'backfill'
    DEADLINE = 'deadline'
    PRIORITY = 'priority'
    SJF = 'sfj'
    SJF = 'sjf'
    

class Policy:

    def __init__(self, strategy):
        self.strategy = strategy
        self.strategy = PolicyType(strategy)

    def sort_jobs(self, jobs):
        if self.strategy == PolicyType.FCFS or PolicyType.BACKFILL:
        if self.strategy == PolicyType.FCFS or self.strategy == PolicyType.BACKFILL:
            return sorted(jobs, key=lambda job: job.submit_time)
        elif self.strategy == PolicyType.SJF:
            return sorted(jobs, key=lambda job: job.wall_time)
+1 −5
Original line number Diff line number Diff line
@@ -168,7 +168,6 @@ class Scheduler:
        # Mark the job as running
        job.state = JobState.RUNNING
        self.running.append(job)
        if job.id == 22: print('***', job.nodes_required, self.available_nodes, job.scheduled_nodes)


    def schedule(self, jobs):
@@ -195,13 +194,11 @@ class Scheduler:
                          f"{job.wall_time} on nodes {scheduled_nodes}")

            else:

                # If the job cannot be scheduled, either try backfilling or requeue it
                if self.queue and self.policy == PolicyType.BACKFILL:
                if self.queue and self.policy.strategy == PolicyType.BACKFILL:
                    self.queue.insert(0, job)
                    backfill_job = self.policy.find_backfill_job(self.queue, len(self.available_nodes), self.current_time)
                    if backfill_job:
                        print('here')
                        self.assign_nodes_to_job(backfill_job)
                        self.queue.remove(backfill_job)
                        if self.debug:
@@ -233,7 +230,6 @@ class Scheduler:
                job.state = JobState.COMPLETED

            if job.state == JobState.RUNNING:

                # Deal with node that fails during the course of a running job
                #if any(node in job.scheduled_nodes for node in newly_downed_nodes):
                if False: # currently disabled b/c not working correctly