Module xalt_site_pkg
[hide private]
[frames] | no frames]

Source Code for Module xalt_site_pkg

 1  #----------------------------------------------------------------------- 
 2  # XALT: A tool that tracks users jobs and environments on a cluster. 
 3  # Copyright (C) 2013-2014 University of Texas at Austin 
 4  # Copyright (C) 2013-2014 University of Tennessee 
 5  #  
 6  # This library is free software; you can redistribute it and/or modify 
 7  # it under the terms of the GNU Lesser General Public License as 
 8  # published by the Free Software Foundation; either version 2.1 of  
 9  # the License, or (at your option) any later version.  
10  # 
11  # This library is distributed in the hope that it will be useful, 
12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
14  # Lesser  General Public License for more details.  
15  # 
16  # You should have received a copy of the GNU Lesser General Public 
17  # License along with this library; if not, write to the Free 
18  # Software Foundation, Inc., 59 Temple Place, Suite 330, 
19  # Boston, MA 02111-1307 USA 
20  #----------------------------------------------------------------------- 
21  from __future__ import print_function 
22  import os 
23   
24 -def translate(nameA, envT, userT):
25 """ 26 Site Package prototype. 27 """ 28 sysT = {} 29 queueType = "SLURM" 30 if (envT.get("SGE_ACCOUNT")): 31 queueType = "SGE" 32 elif (envT.get("SLURM_TACC_ACCOUNT") or envT.get("SLURM_TACC_JOBNAME")): 33 queueType = "SLURM_TACC" 34 elif (envT.get("SBATCH_ACCOUNT")): 35 queueType = "SLURM" 36 elif (envT.get("PBS_JOBID")): 37 queueType = "PBS" 38 39 if (queueType == "SGE"): 40 sysT['num_cores'] = "NSLOTS" 41 sysT['num_nodes'] = "NHOSTS" 42 sysT['account'] = "SGE_ACCOUNT" 43 sysT['job_id'] = "JOB_ID" 44 sysT['queue'] = "QUEUE" 45 46 elif (queueType == "SLURM_TACC"): 47 sysT['num_cores'] = "SLURM_TACC_CORES" 48 sysT['num_nodes'] = "SLURM_NNODES" 49 sysT['account'] = "SLURM_TACC_ACCOUNT" 50 sysT['job_id'] = "SLURM_JOB_ID" 51 sysT['queue'] = "SLURM_QUEUE" 52 sysT['submit_host'] = "SLURM_SUBMIT_HOST" 53 54 elif (queueType == "SLURM"): 55 sysT['num_nodes'] = "SLURM_JOB_NUM_NODES" # or SLURM_NNODES 56 sysT['job_id'] = "SLURM_JOB_ID" 57 sysT['queue'] = "SLURM_QUEUE" 58 sysT['submit_host'] = "SLURM_SUBMIT_HOST" 59 60 elif (queueType == "PBS"): 61 sysT['num_cores'] = "PBS_NP" 62 sysT['num_nodes'] = "PBS_NNODES" 63 sysT['account'] = "PBS_ACCOUNT" 64 sysT['job_id'] = "PBS_JOBID" 65 sysT['queue'] = "PBS_QUEUE" 66 67 for name in nameA: 68 result = "unknown" 69 key = sysT.get(name) 70 if (key): 71 result = envT.get(key,"unknown") 72 userT[name] = result 73 74 # Compute number of total nodes for Generic SLURM. 75 if (queueType == "SLURM"): 76 userT['num_cores'] = int(envT.get("SLURM_NNODES",0))*int(envT.get("SLURM_CPUS_ON_NODE",0)) 77 78 keyA = [ 'num_cores', 'num_nodes' ] 79 80 for key in keyA: 81 if (userT[key] == "unknown"): 82 userT[key] = 0 83 else: 84 userT[key] = int(userT[key]) 85 86 if (userT['job_id'] == "unknown"): 87 userT['job_id'] = envT.get('JOB_ID','unknown')
88