Esempio n. 1
0
def kill_jobs(kill_names, message1='Killing job: ', message2=' early'):
    """This function takes a list of job names and kills the jobs associated with them, if the jobs are active
        
        Parameters
        ----------
            kill_names : list
                List of jobs to kill. 
            message1 : str
                Message prefix to report to stdout.
            message2 : str
                Message suffix to report to stdout.
            
    """
    # This function takes a list of job names and kills the jobs associated with them, if the jobs are active
    if type(kill_names) != list:
        kill_names = [kill_names]
    machine = tools.get_machine()

    active_jobs, active_ids = tools.list_active_jobs(ids=True)
    active_jobs = list(zip(active_jobs, active_ids))

    jobs_to_kill = [[name, id_] for name, id_ in active_jobs
                    if name in kill_names]

    for name, id_ in jobs_to_kill:
        print(message1 + name + message2)
        if machine in ['gibraltar']:
            tools.call_bash('qdel ' + str(id_))
        elif machine in ['comet', 'bridges']:
            tools.call_bash('scancel ' + str(id_))
        else:
            raise ValueError('Sardines.')
Esempio n. 2
0
def kill_jobs(kill_names, message1='Killing job: ', message2=' early'):
    # This function takes a list of job names and kills the jobs associated with them, if the jobs are active
    if type(kill_names) != list:
        kill_names = [kill_names]

    active_jobs, active_ids = tools.list_active_jobs(ids=True)
    active_jobs = list(zip(active_jobs, active_ids))

    jobs_to_kill = [[name, id_] for name, id_ in active_jobs
                    if name in kill_names]

    for name, id_ in jobs_to_kill:
        print((message1 + name + message2))
        tools.call_bash('qdel ' + str(id_))