def list_cus(self, pilot_url): pilot_compute = PilotCompute(pilot_url=pilot_url) cus = pilot_compute.list_compute_units() counter=1 print "\nPilot Compute: %s"%(pilot_compute.get_url()) print "State: %s"%(pilot_compute.get_state()) print "#\tCompute Unit\t\t\t\t\tState\tQueue\tRuntime" print "-----------------------------------------------------------------------------------------" if len(cus)==0: print "No Compute Unit found." for i in cus: url = i.get_url() short_url = url[url.index("sj"):] if short_url.find("/?")!=-1: short_url=short_url[:short_url.index("/?")] queue_time = 0.0 run_time = 0.0 try: pass #details = i.get_details() #state = details["state"] except: pass state = i.get_state() details=i.get_details() if details.has_key("start_time") and details.has_key("end_queue_time"): queue_time = float(details["end_queue_time"]) - float(details["start_time"]) if details.has_key("end_time") and details.has_key("end_queue_time"): run_time = float(details["end_time"]) - float(details["end_queue_time"]) print "%d\t%s\t\t%s\t%.1f\t%.1f"%(counter, short_url, state, queue_time, run_time) counter = counter + 1 print ""
def list_pilots(self): print "\nPilot Compute\t\t\t\t\t\t\t\t\tState" print "-----------------------------------------------------------------------------------------------------" if len(self.pilots)==0: print "No pilot found" for i in self.pilots: pilot_compute = PilotCompute(pilot_url=i) print "%s\t%s"%(pilot_compute.get_url(), pilot_compute.get_state()) print ""
def stop_run_pilot(pilot_id): pilot = DareBigJobPilot.objects.get(id=pilot_id) pilot_url = pilot.pilot_url pilot_compute = PilotCompute(pilot_url=str(pilot.pilot_url)) pilot_compute.cancel() pilot.pilot_url = "" pilot.status = "Stopped" pilot.save() print("Stopped Pilot: %s " % (pilot_url), pilot.id)
def stop_run_pilot(pilot_id): pilot = DareBigJobPilot.objects.get(id=pilot_id) pilot_url = pilot.pilot_url pilot_compute = PilotCompute(pilot_url=str(pilot.pilot_url)) pilot_compute.cancel() pilot.pilot_url = "" pilot.status = "Stopped" pilot.save() print(("Stopped Pilot: %s " % (pilot_url), pilot.id))
def update_status_run_pilot(pilot_id): pilot = DareBigJobPilot.objects.get(id=pilot_id) pilot_url = pilot.pilot_url if len(pilot_url) > 0: pilot_compute = PilotCompute(pilot_url=str(pilot.pilot_url)) if pilot_compute.get_state() in [State.Done]: pilot.status = "Stopped" elif pilot_compute.get_state() in [State.New, State.Unknown]: pilot.status = "Submitted" elif pilot_compute.get_state() in [State.Running]: pilot.status = "Active" else: if not pilot.status == "Stopped": pilot.status = "New" pilot.save() print("Stopped Pilot: %s " % (pilot_url), pilot.id)
def update_status_run_pilot(pilot_id): pilot = DareBigJobPilot.objects.get(id=pilot_id) pilot_url = pilot.pilot_url if len(pilot_url) > 0: pilot_compute = PilotCompute(pilot_url=str(pilot.pilot_url)) if pilot_compute.get_state() in [State.Done]: pilot.status = "Stopped" elif pilot_compute.get_state() in [State.New, State.Unknown]: pilot.status = "Submitted" elif pilot_compute.get_state() in [State.Running]: pilot.status = "Active" else: if not pilot.status == "Stopped": pilot.status = "New" pilot.save() print(("Stopped Pilot: %s " % (pilot_url), pilot.id))
def start_run_task(task_id): taskinfo = DareBigJobTask.objects.get(id=task_id) if len(taskinfo.dare_bigjob_pilot.pilot_url) > 0: code = compile_restricted(taskinfo.script, '<string>', 'exec') restricted_globals = dict(__builtins__=safe_builtins) _print_ = PrintCollector _write_ = full_write_guard _getattr_ = getattr global _getiter_, _getattr_, _write_, _print_, restricted_globals _getiter_ = list exec(code) cus = tasks() pilot_compute = PilotCompute(pilot_url=str(taskinfo.dare_bigjob_pilot.pilot_url)) taskinfo.cu_url = '' for cu in cus: compute_unit = pilot_compute.submit_compute_unit(cu) print "Started ComputeUnit: %s" % (compute_unit.get_url()) taskinfo.cu_url += '@@@' + compute_unit.get_url() taskinfo.status = 'Submitted' taskinfo.save() return compute_unit
def start_run_task(task_id): taskinfo = DareBigJobTask.objects.get(id=task_id) if len(taskinfo.dare_bigjob_pilot.pilot_url) > 0: code = compile_restricted(taskinfo.script, '<string>', 'exec') restricted_globals = dict(__builtins__=safe_builtins) _print_ = PrintCollector _write_ = full_write_guard _getattr_ = getattr global _getiter_, _getattr_, _write_, _print_, restricted_globals _getiter_ = list exec(code) cus = tasks() pilot_compute = PilotCompute( pilot_url=str(taskinfo.dare_bigjob_pilot.pilot_url)) taskinfo.cu_url = '' for cu in cus: compute_unit = pilot_compute.submit_compute_unit(cu) print("Started ComputeUnit: %s" % (compute_unit.get_url())) taskinfo.cu_url += '@@@' + compute_unit.get_url() taskinfo.status = 'Submitted' taskinfo.save() return compute_unit
def cancel_pilot(self, pilot_url): pilot_compute = PilotCompute(pilot_url=pilot_url) pilot_compute.cancel() self.pilots.remove(pilot_url) self.__persist()
def wait_cu(self, pilot_url): pilot_compute = PilotCompute(pilot_url=pilot_url) pilot_compute.wait()
def submit_cu_by_description(self, pilot_url, compute_unit_description={}): pilot_compute = PilotCompute(pilot_url=pilot_url) compute_unit = pilot_compute.submit_compute_unit(compute_unit_description) print "Started ComputeUnit: %s"%(compute_unit.get_url()) return compute_unit