Example #1
0
 def cancel(self):
     darelogger.debug("Terminate Pilot Compute/Data Service")
     self.compute_data_service.cancel()
     try: 
         self.pilot_data_service.cancel()         
         self.pilot_compute_service.cancel()
     except:
         pass
Example #2
0
    def quit(self, message=None):
        if message:
            darelogger.debug(message)
        darelogger.debug("Terminating steps")
        for step, thread in list(self.step_threads.items()):
            darelogger.debug("Stoppping step %s" % step)
            thread._Thread__stop()

        darelogger.debug("Terminating Pilot Compute/Data Service")
        try:
            self.compute_data_service.cancel()
            self.pilot_data_service.cancel()
            self.pilot_compute_service.cancel()
        except:
            pass
Example #3
0
    def quit(self, message=None):
        if message:
            darelogger.debug(message)
        darelogger.debug("Terminating steps")
        for step, thread  in self.step_threads.items():
            darelogger.debug("Stoppping step %s" % step)
            thread._Thread__stop()

        darelogger.debug("Terminating Pilot Compute/Data Service")
        try:
            self.compute_data_service.cancel()
            self.pilot_data_service.cancel()
            self.pilot_compute_service.cancel()
        except:
            pass
Example #4
0
def main():
    
    # parse conf files
    #parser = optparse.OptionParser()
    #parser.add_option("-c", "--conf_job", dest="conf_job", help="job configuration file")
    #(options, args) = parser.parse_args()

    #confjob = options.conf_job

    if (len(sys.argv)> 1): 
       conffile = sys.argv[1] 
    else:
       raise Exception, "missing dare configurtion file"


    darelogger.debug("starting DARE")
    try:
       dare = DareManager(conffile)
       #dare.start()
    except KeyboardInterrupt:
       dare.cancel()

    darelogger.debug("DARE Exec Done")
Example #5
0
    def run_step(self, step_id):
        #self.step_run_lock.acquire()
        #job started update status
        this_su = self.workflow.step_units_repo[step_id].UnitInfo
        self.updater.update_status(
            this_su['dare_web_id'],
            "%s in step %s" % ('Running', this_su['name']))

        darelogger.info(" Started running %s " % step_id)

        jobs = []
        job_start_times = {}
        job_states = {}
        NUMBER_JOBS = len(
            self.workflow.step_units_repo[step_id].UnitInfo['compute_units'])
        for cu_id in self.workflow.step_units_repo[step_id].UnitInfo[
                'compute_units']:
            compute_unit_desc = self.workflow.compute_units_repo[cu_id]
            input_dus = compute_unit_desc.pop('input_data_units')
            output_dus = compute_unit_desc.pop('output_data_units')
            input_data_units = []
            for du_id in input_dus:
                input_data_units.append(
                    self.compute_data_service.submit_data_unit(
                        self.workflow.data_units_repo[du_id]))
            output_data_units = []
            for du_id in output_dus:
                output_data_units.append(
                    self.compute_data_service.submit_data_unit(
                        self.workflow.data_units_repo[du_id]))

            compute_unit_desc["input_data"] = [
                du.get_url() for du in input_data_units
            ]
            compute_unit_desc["output_data"] = [{
                du.get_url(): ['std*']
            } for du in output_data_units]
            compute_unit = self.compute_data_service.submit_compute_unit(
                compute_unit_desc)

            darelogger.info("Compute Unit: Description: \n%s" %
                            (str(self.workflow.compute_units_repo[cu_id])))
            jobs.append(compute_unit)
            job_start_times[compute_unit] = time.time()
            job_states[compute_unit] = compute_unit.get_state()

        darelogger.debug(
            "************************ All Jobs submitted ************************"
        )

        while 1:
            finish_counter = 0
            result_map = {}
            for i in range(0, NUMBER_JOBS):
                old_state = job_states[jobs[i]]
                state = jobs[i].get_state()
                if state in result_map == False:
                    result_map[state] = 0
                result_map[state] = result_map.get(state, 0) + 1
                #print "counter: " + str(i) + " job: " + str(jobs[i]) + " state: " + state
                if old_state != state:
                    darelogger.debug("Job " + str(jobs[i]) +
                                     " changed from: " + old_state + " to " +
                                     state)
                if old_state != state and self.has_finished(state) == True:
                    darelogger.info("%s step Job: " %
                                    (self.workflow.step_units_repo[step_id].
                                     UnitInfo['name']) + str(jobs[i]) +
                                    " Runtime: " +
                                    str(time.time() -
                                        job_start_times[jobs[i]]) + " s.")
                if self.has_finished(state) == True:
                    finish_counter = finish_counter + 1
                job_states[jobs[i]] = state

            darelogger.debug("Current states: " + str(result_map))
            time.sleep(5)
            if finish_counter == NUMBER_JOBS:
                break

        self.workflow.step_units_repo[step_id].set_status(StepUnitStates.Done)

        #self.compute_data_service.wait()
        darelogger.debug(" Compute jobs for step %s complete" % step_id)

        #runtime = time.time()-starttime

        #all jobs done update status
        self.updater.update_status(this_su['dare_web_id'],
                                   "%s is Done" % this_su['name'])
Example #6
0
    def run_step(self, step_id):
        #self.step_run_lock.acquire()
        #job started update status
        this_su = self.workflow.step_units_repo[step_id].UnitInfo
        self.updater.update_status(this_su['dare_web_id'], "%s in step %s" % ('Running',  this_su['name']))

        darelogger.info(" Started running %s " % step_id)

        jobs = []
        job_start_times = {}
        job_states = {}
        NUMBER_JOBS = len(self.workflow.step_units_repo[step_id].UnitInfo['compute_units'])
        for cu_id in self.workflow.step_units_repo[step_id].UnitInfo['compute_units']:
            compute_unit_desc = self.workflow.compute_units_repo[cu_id]
            input_dus = compute_unit_desc.pop('input_data_units')
            output_dus = compute_unit_desc.pop('output_data_units')
            input_data_units = []
            for du_id in input_dus:
                input_data_units.append(self.compute_data_service.submit_data_unit(self.workflow.data_units_repo[du_id]))
            output_data_units = []
            for du_id in output_dus:
                output_data_units.append(self.compute_data_service.submit_data_unit(self.workflow.data_units_repo[du_id]))

            compute_unit_desc["input_data"] = [du.get_url() for du in input_data_units]
            compute_unit_desc["output_data"] = [{du.get_url(): ['std*']} for du in output_data_units]
            compute_unit = self.compute_data_service.submit_compute_unit(compute_unit_desc)

            darelogger.info("Compute Unit: Description: \n%s" % (str(self.workflow.compute_units_repo[cu_id])))
            jobs.append(compute_unit)
            job_start_times[compute_unit] = time.time()
            job_states[compute_unit] = compute_unit.get_state()

        darelogger.debug("************************ All Jobs submitted ************************")

        while 1:
            finish_counter = 0
            result_map = {}
            for i in range(0, NUMBER_JOBS):
                old_state = job_states[jobs[i]]
                state = jobs[i].get_state()
                if  state in result_map == False:
                    result_map[state] = 0
                result_map[state] = result_map.get(state, 0) + 1
                #print "counter: " + str(i) + " job: " + str(jobs[i]) + " state: " + state
                if old_state != state:
                    darelogger.debug("Job " + str(jobs[i]) + " changed from: " + old_state + " to " + state)
                if old_state != state and self.has_finished(state) == True:
                    darelogger.info("%s step Job: " % (self.workflow.step_units_repo[step_id].UnitInfo['name']) + str(jobs[i]) + " Runtime: " + str(time.time() - job_start_times[jobs[i]]) + " s.")
                if self.has_finished(state) == True:
                    finish_counter = finish_counter + 1
                job_states[jobs[i]] = state

            darelogger.debug("Current states: " + str(result_map))
            time.sleep(5)
            if finish_counter == NUMBER_JOBS:
                break

        self.workflow.step_units_repo[step_id].set_status(StepUnitStates.Done)

        #self.compute_data_service.wait()
        darelogger.debug(" Compute jobs for step %s complete" % step_id)

        #runtime = time.time()-starttime

        #all jobs done update status
        self.updater.update_status(this_su['dare_web_id'], "%s is Done" % this_su['name'])