Skip to content

Commit cd5935c

Browse files
committed
Update test cases for TcsExecutor.
Signed-off-by: Satoshi OHSHIMA <[email protected]>
1 parent a4edb55 commit cd5935c

File tree

2 files changed

+63
-83
lines changed

2 files changed

+63
-83
lines changed

modules/nextflow/src/main/groovy/nextflow/executor/TcsExecutor.groovy

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,6 @@ class TcsExecutor extends AbstractGridExecutor implements TaskArrayExecutor {
5252

5353
result << '-N' << modName(getJobNameFor(task))
5454

55-
result << '-j' << ''
56-
result << '-S' << ''
57-
if( !task.workDir ) {
58-
result << '-o' << (task.isArray() ? '/dev/null' : quote(task.workDir.resolve(TaskRun.CMD_LOG)))
59-
}
60-
//result << '-o' << (task.isArray() ? '/dev/null' : quote(task.workDir.resolve(TaskRun.CMD_LOG)))
61-
6255
// max task duration
6356
if( task.config.getTime() ) {
6457
final duration = task.config.getTime()
@@ -92,9 +85,16 @@ class TcsExecutor extends AbstractGridExecutor implements TaskArrayExecutor {
9285
* @return A list representing the submit command line
9386
*/
9487
List<String> getSubmitCommandLine(TaskRun task, Path scriptFile ) {
95-
return pipeLauncherScript()
96-
? List.of('pjsub')
97-
: List.of('pjsub', scriptFile.getName())
88+
if( task instanceof TaskArrayRun ){
89+
final arraySize = task.getArraySize()
90+
return pipeLauncherScript()
91+
? List.of('pjsub', '--bulk --sparam ', "0-${arraySize - 1}".toString())
92+
: List.of('pjsub', scriptFile.getName())
93+
}else{
94+
return pipeLauncherScript()
95+
? List.of('pjsub')
96+
: List.of('pjsub', scriptFile.getName())
97+
}
9898
/* [ 'pjsub', '-N', modName(getJobNameFor(task)), scriptFile.getName() ] */
9999
}
100100

@@ -123,10 +123,7 @@ class TcsExecutor extends AbstractGridExecutor implements TaskArrayExecutor {
123123

124124
@Override
125125
protected List<String> queueStatusCommand(Object queue) {
126-
//String cmd = 'pjstat | grep -v JOB_ID'
127-
//if( queue ) cmd += ' ' + queue
128-
//return ['bash','-c', "set -o pipefail; $cmd | { grep -E '(Job Id:|job_state =)' || true; }".toString()]
129-
final result = ['pjstat2', '-E']
126+
final result = ['pjstat', '-E']
130127
return result
131128
}
132129

@@ -141,28 +138,7 @@ class TcsExecutor extends AbstractGridExecutor implements TaskArrayExecutor {
141138
'HLD': QueueStatus.HOLD, // holding
142139
'ERR': QueueStatus.ERROR, // error
143140
]
144-
/*
145-
protected QueueStatus decode(String status) {
146-
DECODE_STATUS.get(status)
147-
}
148-
*/
149-
/*
150-
@Override
151-
protected Map<String, QueueStatus> parseQueueStatus(String text) {
152-
final result = new LinkedHashMap<String, QueueStatus>()
153-
text.eachLine { String line ->
154-
def cols = line.split(/\s+/)
155-
if( cols.size() > 1 ) {
156-
result.put( cols[0], STATUS_MAP.get(cols[3]) )
157-
}
158-
else {
159-
log.debug "[TCS] invalid status line: `$line`"
160-
}
161-
}
162141

163-
return result
164-
}
165-
*/
166142
@Override
167143
protected Map<String, QueueStatus> parseQueueStatus(String text) {
168144
final result = new LinkedHashMap<String, QueueStatus>()

modules/nextflow/src/test/groovy/nextflow/executor/TcsExecutorTest.groovy

Lines changed: 52 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import spock.lang.Unroll
2828

2929
/**
3030
*
31-
* @author Satoshi Ohshima <[email protected]>
31+
* @author Satoshi Ohshima <[email protected]>
3232
*/
3333

3434
class TcsExecutorTest extends Specification {
@@ -86,20 +86,60 @@ class TcsExecutorTest extends Specification {
8686
task.workDir = Paths.get('/work/path')
8787
task.name = 'the task name'
8888

89+
// 1min job
8990
when:
9091
task.index = 21
9192
task.config = new TaskConfig()
9293
task.config.time = '00:10:00'
9394
then:
9495
executor.getHeaders(task) == '''
95-
#PJM -N nf-the_task_name
96-
#PJM -j
97-
#PJM -S
98-
#PJM -L elapse=00:10:00
96+
#PJM -N nf-the_task_name
97+
#PJM -L elapse=00:10:00
98+
#PJM -o /work/path/.command.log
99+
#PJM -j
100+
#PJM -S
101+
'''
102+
.stripIndent().leftTrim()
103+
104+
// 1hour job
105+
when:
106+
task.index = 22
107+
task.config = new TaskConfig()
108+
task.config.time = '01:00:00'
109+
task.name = '1hour job'
110+
then:
111+
executor.getHeaders(task) == '''
112+
#PJM -N nf-1hour_job
113+
#PJM -L elapse=01:00:00
114+
#PJM -o /work/path/.command.log
115+
#PJM -j
116+
#PJM -S
117+
'''
118+
.stripIndent().leftTrim()
119+
120+
// job array (bulk job)
121+
when: 'with job array (bulk job)'
122+
task.config = new TaskConfig()
123+
task.workDir = Paths.get('/work/path')
124+
task.name = 'array job'
125+
def taskArray = Mock(TaskArrayRun) {
126+
config >> new TaskConfig()
127+
name >> task.name
128+
getArraySize() >> 5
129+
workDir >> task.workDir
130+
}
131+
taskArray.config.time = '01:00:00'
132+
133+
then:
134+
executor.getHeaders(taskArray) == '''
135+
#PJM -N nf-array_job
136+
#PJM -L elapse=01:00:00
137+
#PJM -j
138+
#PJM -S
99139
'''
100140
.stripIndent().leftTrim()
101141
}
102-
/*
142+
103143
def testWorkDirWithBlanks() {
104144

105145
setup:
@@ -122,16 +162,15 @@ class TcsExecutorTest extends Specification {
122162
task.config.time = '00:10:00'
123163
then:
124164
executor.getHeaders(task) == '''
125-
#PJM -N nf-the_task_name
126-
#PJM -j
127-
#PJM -S
128-
#PJM -L elapse=00:10:00
165+
#PJM -N nf-the_task_name
166+
#PJM -L elapse=00:10:00
129167
#PJM -o "/work/some\\ data/path/.command.log"
168+
#PJM -j
169+
#PJM -S
130170
'''
131171
.stripIndent().leftTrim()
132172

133173
}
134-
*/
135174

136175
def testQstatCommand() {
137176

@@ -169,12 +208,9 @@ class TcsExecutorTest extends Specification {
169208

170209
def testQueueStatusCommand() {
171210
when:
172-
def usr = System.getProperty('user.name')
173211
def exec = [:] as TcsExecutor
174212
then:
175-
usr
176-
exec.queueStatusCommand(null) == ['pjstat2', '-E']
177-
//exec.queueStatusCommand('long') == ['pjstat2','-E']
213+
exec.queueStatusCommand(null) == ['pjstat', '-E']
178214
}
179215

180216
def 'should get array (bulk) index name and start' () {
@@ -197,39 +233,7 @@ class TcsExecutorTest extends Specification {
197233
JOB_ID | TASK_INDEX | EXPECTED
198234
'1234' | 1 | '1234[1]'
199235
'123456' | 2 | '123456[2]'
200-
/*
201-
JOB_ID JOB_NAME MD STATUS USER RSCGROUP START_DATE ELAPSE NODE CORE GPU POINT
202-
3209914 bulk1.sh BU RUN ku40000105 a-batch-low - - - 1 - -
203-
3209914[1] bulk1.sh BU RUN ku40000105 a-batch-low 2025/06/13 17:53:43 00:00:01 - 1 - 1
204-
*/
205236
}
206237
207-
/* There is no project option in TCS. (on Genkai and Flow) */
208-
/*
209-
@Unroll
210-
def 'should set tcs account' () {
211-
given:
212-
// task
213-
def task = new TaskRun()
214-
task.workDir = Paths.get('/work/dir')
215-
task.processor = Mock(TaskProcessor)
216-
task.processor.getSession() >> Mock(Session)
217-
task.config = Mock(TaskConfig)
218-
and:
219-
def executor = Spy(TcsExecutor)
220-
executor.getJobNameFor(_) >> 'foo'
221-
executor.getName() >> 'tcs'
222-
executor.getSession() >> Mock(Session) { getExecConfigProp('tcs', 'account',null)>>ACCOUNT }
223-
224-
when:
225-
def result = executor.getDirectives(task, [])
226-
then:
227-
result == EXPECTED
228-
229-
where:
230-
ACCOUNT | EXPECTED
231-
null | ['-N', 'foo', '-o', '/work/dir/.command.log', '-j']
232-
'project-123' | ['-N', 'foo', '-o', '/work/dir/.command.log', '-j']
233-
}
234-
*/
235238
}
239+

0 commit comments

Comments
 (0)