Exemple #1
0
	def __init__(self, username, password, scheduler):
		self.jobs = {}
		self.next_job_id = 0
		
		self.nodes = {}
		self.node_ids = {}

		self.auth_header = auth_header(username, password)

		# (Proportion of nodes, max wall_time (hours), list of nodes)
		self.node_queue = {
			'DEFAULT': (0.5, walltime.strptime("7:00:00:00"), []),
			'BATCH': (0.3, None, []),
			'FAST': (0.2, walltime.strptime("01:00:00"), []) 
		}

		self.next_node_id = 0

		self.queue_lock = threading.Lock()
		self.queue = []

		# Remove all job related files
		path = os.path.join('www', 'jobs')
		if os.path.exists(path):
			shutil.rmtree(path)

		# Start the scheduler
		self.scheduler = scheduler
Exemple #2
0
    def __init__(self, username, password, scheduler):
        self.jobs = {}
        self.next_job_id = 0

        self.nodes = {}
        self.node_ids = {}

        self.auth_header = auth_header(username, password)

        # (Proportion of nodes, max wall_time (hours), list of nodes)
        self.node_queue = {
            'DEFAULT': (0.5, walltime.strptime("7:00:00:00"), []),
            'BATCH': (0.3, None, []),
            'FAST': (0.2, walltime.strptime("01:00:00"), [])
        }

        self.next_node_id = 0

        self.queue_lock = threading.Lock()
        self.queue = []

        # Remove all job related files
        path = os.path.join('www', 'jobs')
        if os.path.exists(path):
            shutil.rmtree(path)

        # Start the scheduler
        self.scheduler = scheduler
Exemple #3
0
    def add_task(self, job_id, work_unit_id, executable, filename, flags,
                 wall_time, deadline):
        # create the task
        task = Task(task_id=self.next_task_id,
                    job_id=job_id,
                    work_unit_id=work_unit_id,
                    executable=executable,
                    filename=filename,
                    flags=flags,
                    wall_time=walltime.strptime(wall_time),
                    deadline=deadline)

        # Get the files for the task
        self.get_task_executable(task)
        self.get_task_file(task)

        # Task is now READY
        task.ready()

        self.tasks.update({task.task_id: task})
        self.next_task_id += 1

        return task
Exemple #4
0
	def add_task(self, job_id, work_unit_id, executable, filename, flags, wall_time, deadline):
		# create the task
		task = Task(
			task_id = self.next_task_id, 
			job_id = job_id,
			work_unit_id = work_unit_id,
			executable = executable, 
			filename = filename,
			flags = flags, 
			wall_time = walltime.strptime(wall_time),
			deadline = deadline
		)

		# Get the files for the task
		self.get_task_executable(task)
		self.get_task_file(task)

		# Task is now READY
		task.ready()
	
		self.tasks.update({ task.task_id: task })
		self.next_task_id += 1

		return task
Exemple #5
0
    def add_job(self, flags, wall_time, deadline, budget, job_type, name):

        # Need to check job_type is a valid queue
        if job_type is None:
            job_type = "DEFAULT"
        elif job_type not in self.node_queue.keys():
            raise InvalidJobTypeException(
                "Invalid Job Type specified: %s. Valid job types are: %s." %
                (job_type, ", ".join(self.node_queue.keys())))

        # Check for Valid budget
        try:
            budget = int(budget)
        except (TypeError, ValueError):
            raise InvalidJobBudgetException(
                "Invalid Budget specified: %s. Format: amount in cents as a whole number."
                % budget)
        if budget < 0:
            raise InvalidJobBudgetException(
                "Invalid Budget specified: %s. Budget must be greater than 0" %
                budget)

        # Check that wall_time is valid:
        try:
            wall_stripped = walltime.strptime(wall_time)
        except WallTimeFormatException:
            raise InvalidWallTimeFormatException(
                "Invalid Wall Time specified: %s. Format: DD:HH:MM:SS." %
                wall_time)

        # Check that deadline format is valid
        try:
            deadline_since_epoch = time.mktime(
                time.strptime(deadline, "%Y-%m-%d %H:%M:%S"))
        except ValueError:
            raise InvalidJobDeadlineFormatException(
                "Invalid Deadline specified: %s. Format: YYYY-MM-DD HH:MM:SS" %
                deadline)

        # Check that deadline is valid
        if deadline_since_epoch <= int(time.time()):
            raise InvalidJobDeadlineException(
                "Invalid Deadline specified: %s. Deadline specified is in the past."
                % deadline)

        # Check that deadline is reasonable
        if (deadline_since_epoch - walltime.wall_secs(wall_stripped)) < int(
                time.time()):
            raise InvalidJobDeadlineException(
                "Error: Current time plus wall time is later than the specified deadline. Please adjust either and resubmit."
            )

        # Check that wall time is within acceptable range for job queue placement
        if self.node_queue[job_type][1] != None and walltime.wall_secs(
                wall_stripped) > walltime.wall_secs(
                    self.node_queue[job_type][1]):
            raise InvalidJobTypeException(
                "Invalid Job Type specified: %s. Wall time %s is too large. Wall time must be shorter than %s for job type %s."
                % (job_type, walltime.strftime(wall_stripped),
                   self.node_queue[job_type][1], job_type))

        #
        # All tests passed, add to grid.
        #

        job = Job(job_id=self.next_job_id,
                  flags=flags,
                  wall_time=wall_stripped,
                  deadline=deadline_since_epoch,
                  budget=budget,
                  job_type=job_type,
                  name=name)

        self.jobs[self.next_job_id] = job
        self.next_job_id += 1

        return job
Exemple #6
0
	def add_job(self, flags, wall_time, deadline, budget, job_type, name):
	
		# Need to check job_type is a valid queue
		if job_type is None:
			job_type = "DEFAULT"
		elif job_type not in self.node_queue.keys():
			raise InvalidJobTypeException(
				"Invalid Job Type specified: %s. Valid job types are: %s." % (job_type, ", ".join(self.node_queue.keys()))
				)
		
		# Check for Valid budget
		try:
			budget = int(budget)
		except (TypeError, ValueError):
			raise InvalidJobBudgetException("Invalid Budget specified: %s. Format: amount in cents as a whole number." % budget)
		if budget < 0:
			raise InvalidJobBudgetException("Invalid Budget specified: %s. Budget must be greater than 0" % budget)

		# Check that wall_time is valid:
		try:
			wall_stripped = walltime.strptime(wall_time)
		except WallTimeFormatException:
			raise InvalidWallTimeFormatException("Invalid Wall Time specified: %s. Format: DD:HH:MM:SS." % wall_time)

		# Check that deadline format is valid
		try:
			deadline_since_epoch = time.mktime(time.strptime(deadline, "%Y-%m-%d %H:%M:%S"))
		except ValueError:
			raise InvalidJobDeadlineFormatException("Invalid Deadline specified: %s. Format: YYYY-MM-DD HH:MM:SS" % deadline)

		# Check that deadline is valid
		if deadline_since_epoch <= int(time.time()):
			raise InvalidJobDeadlineException("Invalid Deadline specified: %s. Deadline specified is in the past." % deadline)
		
		# Check that deadline is reasonable
		if (deadline_since_epoch - walltime.wall_secs(wall_stripped)) < int(time.time()):
			raise InvalidJobDeadlineException(
				"Error: Current time plus wall time is later than the specified deadline. Please adjust either and resubmit."
				)
		
		# Check that wall time is within acceptable range for job queue placement
		if self.node_queue[job_type][1] != None and walltime.wall_secs(wall_stripped) > walltime.wall_secs(self.node_queue[job_type][1]):
			raise InvalidJobTypeException(
				"Invalid Job Type specified: %s. Wall time %s is too large. Wall time must be shorter than %s for job type %s."
				% (job_type, walltime.strftime(wall_stripped), self.node_queue[job_type][1], job_type)
				) 

		#
		# All tests passed, add to grid.
		#

		job = Job(
			job_id = self.next_job_id,
			flags = flags, 
			wall_time = wall_stripped, 
			deadline = deadline_since_epoch, 
			budget = budget,
			job_type = job_type,
			name = name
		)


		self.jobs[ self.next_job_id ] = job
		self.next_job_id += 1

		return job
	for node_id in request.response:
		node = request.response[node_id]
		if node['status'] == "DEAD":
			continue

		print "Node: %s" % (node_id)
		print "Status: %s" % node['status']
		print "CPU: %s" % (float(node['cpu'])/int(node['cores']))
		print "Cost: $ %0.2f" % (node['cost']/100)
		print "Cores: %s" % node['cores']
		print "Type: %s" % node['type']
		print "Free Spots: %s" % (int(node['cores']) - len(node['work_units']))
		if (int(node['cores']) - len(node['work_units'])) == 0:
			earliest_end = None
			for unit in node['work_units']:
				end = int(unit['created_ts']) + walltime.wall_secs(walltime.strptime(unit['wall_time']))
				if earliest_end == None:
					earliest_end = end
				if end < earliest_end:
					earliest_end = end
			print "Next free: %s" % time.asctime(time.localtime(earliest_end))
		print

	sys.exit(1)


#
# Begin Client
#

# Check the files exist before starting to avoid creating