Esempio n. 1
0
    def status(self):
        """
        Get job status from HPC. 

        Returns
        -------
        status : (str)
            Job status. Possible status are 'PENDING','RUNNING','NOT IN QUEUE'.
        """
        hpc = HPCInterface()
        stdout, stderr = hpc.qstat(printout=False)
        queue = stdout.splitlines()
        job_lines = grep_list(self.name, queue)
        if job_lines == []:
            status = 'NOT IN QUEUE'
        elif len(job_lines) > 1:
            raise ValueError(
                f'More than one job named "{self.name}" has been found in queue:\n{stdout}'
            )
        else:
            job_line = job_lines[0].split()
            status = job_line[4]
            if status == 'PD':
                status = 'PENDING'
            if status == 'R':
                status = 'RUNNING'
            if status == 'CG':
                status = 'COMPLETED'

        return status
Esempio n. 2
0
    def job_queue(self):
        """
        Print job queue from HPC on screen
        
        Returns
        -------
        stdout : (str)
            Output.
        stderr : (str)
            Error.
        """
        hpc = HPCInterface()
        stdout, stderr = hpc.qstat()

        return stdout, stderr
Esempio n. 3
0
 def queue(self,stdouts=False):
     """
     Display queue from HPC. If stdouts is True returns out and err strings.
     
     Returns
     -------
     stdout : (str)
         Output.
     stderr : (str)
         Error.
     """
     hpc = HPCInterface()
     stdout,stderr = hpc.qstat()
     if stdouts:
         return stdout,stderr
     else:
         return
Esempio n. 4
0
    def job_id(self):
        """Get job ID from the queue on HPC"""
        hpc = HPCInterface()
        stdout, stderr = hpc.qstat(printout=False)
        queue = stdout.splitlines()
        job_lines = grep_list(self.name, queue)
        if job_lines == []:
            raise ValueError(
                f'Job named "{self.name}" is not currently running or pending')
        elif len(job_lines) > 1:
            raise ValueError(
                f'More than one job named "{self.name}" has been found in queue:\n{stdout}'
            )
        else:
            job_line = job_lines[0].split()
            job_id = job_line[0]

        return job_id