Skip to content

Instantly share code, notes, and snippets.

@imoutsatsos
Created September 8, 2023 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imoutsatsos/7f666e83cc9ddaa7298c656e7630d8e5 to your computer and use it in GitHub Desktop.
Save imoutsatsos/7f666e83cc9ddaa7298c656e7630d8e5 to your computer and use it in GitHub Desktop.
/*
How to get a task IDs from a qstat grid engine report civilized
qstat reports failed tasks as comma separated mixed list of task-IDs and range-like task-IDs
Example: '135-139:1,143,146,147'
We want to transform this to a civilized Array List like: [135, 136, 137, 138, 139, 143, 146, 147]
*/
mixedListRanges='135-139:1,143,146,147'
def failedTasks=mixedListRanges.tokenize(',').collect{qstatRangeToList(it)}.flatten()
def qstatRangeToList(String rangeString){
l=[]
if (rangeString.contains('-')){
println rangeString
rFirst=rangeString.split('-')[0] as int
rLast=rangeString.split('-')[1].split(':')[0]as int
rStep=rangeString.split('-')[1].split(':')[1] as int
taskRange=rFirst..rLast
taskRangeList=taskRange.step(rStep)
return taskRangeList
} else{
l.add(rangeString as int)
return l
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment