當前位置: 首頁>>代碼示例>>Python>>正文


Python CommonUtils.convertJobSize方法代碼示例

本文整理匯總了Python中CommonUtils.convertJobSize方法的典型用法代碼示例。如果您正苦於以下問題:Python CommonUtils.convertJobSize方法的具體用法?Python CommonUtils.convertJobSize怎麽用?Python CommonUtils.convertJobSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在CommonUtils的用法示例。


在下文中一共展示了CommonUtils.convertJobSize方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run

# 需要導入模塊: import CommonUtils [as 別名]
# 或者: from CommonUtils import convertJobSize [as 別名]
    def run(self):
        line = self.stream.readline()
        
        while line:
            try:
                           
                line = line.strip()
                
                if len(line) == 0:
                    continue
                    
                qTuple = line.split()
                
                if len(qTuple) <> 9:
                    self.errList.append("Wrong partition info column number: %d" % len(qTuple))
                    continue
                
                queue = qTuple[0]
                if queue.endswith('*'):
                    queue = queue[:-1]
                if not queue in self.qtable:
                    self.qtable[queue] = PartitionInfo()
                    
                if qTuple[1] == 'down' or qTuple[1] == 'inactive':
                    self.qtable[queue].state = 'Closed'
                elif qTuple[1] == 'drain':
                    self.qtable[queue].state = 'Draining'
                else:
                    self.qtable[queue].state = 'Production'
                
                parsed = self.cpuRegex.match(qTuple[2])
                if not parsed:
                    self.errList.append("Wrong format for partition cpu info: " + qTuple[2])
                    continue
                self.qtable[queue].freeCPU = int(parsed.group(2))
                self.qtable[queue].activeCPU = int(parsed.group(1))
                self.qtable[queue].totalCPU = int(parsed.group(4))
                
                if qTuple[3] <> 'n/a':
                    self.qtable[queue].maxRuntime = CommonUtils.convertTimeLimit(qTuple[3])
                
                if qTuple[4] <> 'n/a':
                    self.qtable[queue].defaultRuntime = CommonUtils.convertTimeLimit(qTuple[4])
                elif self.qtable[queue].maxRuntime <> -1:
                    self.qtable[queue].defaultRuntime = self.qtable[queue].maxRuntime
                    
                try:
                    minNodes, maxNodes = CommonUtils.convertJobSize(qTuple[5])
                    
                    if maxNodes < 0:
                        continue
                    
                    if qTuple[7].lower() <> 'unlimited':
                    
                        maxCPUNode = int(qTuple[7])
                        self.qtable[queue].slotsPerJob = maxNodes * maxCPUNode
                        
                    else:
                        tmpl = [ i.translate(None, '+') for i in qTuple[8].split(':') ]                        
                        socketNum = int(tmpl[0])
                        coreNum = int(tmpl[1])
                        thrNum = int(tmpl[2])
                        self.qtable[queue].slotsPerJob = maxNodes * socketNum * coreNum * thrNum
                        
                except Exception, ex:
                    logger.debug("Cannot calculate MaxSlotsPerJob for %s", queue, exc_info=True)
                    self.errList.append("Cannot calculate MaxSlotsPerJob for %s" % queue)

                                
            finally:
                line = self.stream.readline()
開發者ID:italiangrid,項目名稱:info-dynamic-scheduler-slurm,代碼行數:73,代碼來源:SInfoHandler.py


注:本文中的CommonUtils.convertJobSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。