Skip to content

Commit f1bd1db

Browse files
committed
work in progress
1 parent b48c6d2 commit f1bd1db

11 files changed

Lines changed: 170 additions & 61 deletions

File tree

process/score_upload.nf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ nextflow.enable.dsl=2
55
params.cpus = 8
66
params.mem = 20
77

8+
params.max_retries = 5 // set to 0 will disable retry
9+
params.first_retry_wait_time = 1 // in seconds
10+
811
// required params w/ default
912
params.container_version = "5.0.0"
1013
params.transport_mem = 2 // Transport memory is in number of GBs
@@ -17,6 +20,12 @@ params.api_token = "" // song/score API token for download process
1720
// --score_url score url for download process
1821

1922
process scoreUpload {
23+
maxRetries params.max_retries
24+
errorStrategy {
25+
sleep(Math.pow(2, task.attempt) * params.first_retry_wait_time * 1000 as long); // backoff time doubles before each retry
26+
return params.max_retries ? 'retry' : 'finish'
27+
}
28+
2029
pod = [secret: workflow.runName + "-secret", mountPath: "/tmp/rdpc_secret"]
2130

2231
cpus params.cpus

process/song_manifest.nf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ nextflow.enable.dsl=2
55
params.cpus = 1
66
params.mem = 1
77

8+
params.max_retries = 5 // set to 0 will disable retry
9+
params.first_retry_wait_time = 1 // in seconds
10+
811
// required params w/ default
912
params.container_version = "4.2.1"
1013

@@ -16,6 +19,12 @@ params.api_token = "" // song/score API token for download process
1619
// --score_url score url for download process
1720

1821
process songManifest {
22+
maxRetries params.max_retries
23+
errorStrategy {
24+
sleep(Math.pow(2, task.attempt) * params.first_retry_wait_time * 1000 as long); // backoff time doubles before each retry
25+
return params.max_retries ? 'retry' : 'finish'
26+
}
27+
1928
pod = [secret: workflow.runName + "-secret", mountPath: "/tmp/rdpc_secret"]
2029

2130
cpus params.cpus

process/song_publish.nf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ nextflow.enable.dsl=2
55
params.cpus = 1
66
params.mem = 1
77

8+
params.max_retries = 5 // set to 0 will disable retry
9+
params.first_retry_wait_time = 1 // in seconds
10+
811
// required params w/ default
912
params.container_version = "4.2.1"
1013

@@ -16,6 +19,12 @@ params.api_token = "" // song/score API token for download process
1619
// --score_url score url for download process
1720

1821
process songPublish {
22+
maxRetries params.max_retries
23+
errorStrategy {
24+
sleep(Math.pow(2, task.attempt) * params.first_retry_wait_time * 1000 as long); // backoff time doubles before each retry
25+
return params.max_retries ? 'retry' : 'finish'
26+
}
27+
1928
pod = [secret: workflow.runName + "-secret", mountPath: "/tmp/rdpc_secret"]
2029

2130
cpus params.cpus

process/song_submit.nf

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ nextflow.enable.dsl=2
55
params.cpus = 1
66
params.mem = 1
77

8+
params.max_retries = 5 // set to 0 will disable retry
9+
params.first_retry_wait_time = 1 // in seconds
10+
811
// required params w/ default
912
params.container_version = "4.2.1"
1013

@@ -16,6 +19,12 @@ params.api_token = "" // song/score API token for download process
1619
// --score_url score url for download process
1720

1821
process songSubmit {
22+
maxRetries params.max_retries
23+
errorStrategy {
24+
sleep(Math.pow(2, task.attempt) * params.first_retry_wait_time * 1000 as long); // backoff time doubles before each retry
25+
return params.max_retries ? 'retry' : 'finish'
26+
}
27+
1928
pod = [secret: workflow.runName + "-secret", mountPath: "/tmp/rdpc_secret"]
2029

2130
cpus params.cpus
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

song-score-upload/main.nf

Lines changed: 75 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
limitations under the License.
1717
1818
Authors:
19+
Alex Lepsa
1920
Junjun Zhang
2021
*/
2122

@@ -25,37 +26,88 @@ version = '2.6.0' // package version
2526
// universal params go here, change default value as needed
2627
params.container = ""
2728
params.container_registry = ""
28-
params.container_version = ""
29-
params.cpus = 1
30-
params.mem = 1 // GB
3129
params.publish_dir = "" // set to empty string will disable publishDir
3230

33-
// tool specific parmas go here, add / change as needed
34-
params.input_file = ""
35-
params.cleanup = true
36-
37-
38-
39-
// please update workflow code as needed
40-
workflow SongScoreUpload {
41-
take: // update as needed
42-
input_file
43-
44-
45-
main: // update as needed
46-
demoCopyFile(input_file)
47-
if (params.cleanup) { cleanupWorkdir(demoCopyFile.out, true) }
48-
49-
emit: // update as needed
50-
output_file = demoCopyFile.out.output_file
31+
params.max_retries = 5 // set to 0 will disable retry
32+
params.first_retry_wait_time = 1 // in seconds
5133

34+
// tool specific parmas go here, add / change as needed
35+
params.study_id = "TEST-PR"
36+
params.payload = "NO_FILE"
37+
params.upload = []
38+
39+
params.api_token = ""
40+
41+
params.song_cpus = 1
42+
params.song_mem = 1 // GB
43+
params.song_url = "https://song.rdpc-qa.cancercollaboratory.org"
44+
params.song_api_token = ""
45+
params.song_container_version = "4.2.1"
46+
47+
params.score_cpus = 1
48+
params.score_mem = 1 // GB
49+
params.score_transport_mem = 1 // GB
50+
params.score_url = "https://score.rdpc-qa.cancercollaboratory.org"
51+
params.score_api_token = ""
52+
params.score_container_version = "5.0.0"
53+
54+
55+
song_params = [
56+
*:params,
57+
'cpus': params.song_cpus,
58+
'mem': params.song_mem,
59+
'song_url': params.song_url,
60+
'song_container_version': params.song_container_version,
61+
'api_token': params.song_api_token ?: params.api_token,
62+
'publish_dir': ''
63+
]
64+
65+
score_params = [
66+
*:params,
67+
'cpus': params.score_cpus,
68+
'mem': params.score_mem,
69+
'transport_mem': params.score_transport_mem,
70+
'song_url': params.song_url,
71+
'score_url': params.score_url,
72+
'score_container_version': params.score_container_version,
73+
'api_token': params.score_api_token ?: params.api_token
74+
]
75+
76+
include { songSubmit } from './local_modules/song-submit' params(song_params)
77+
include { songManifest } from './local_modules/song-manifest' params(song_params)
78+
include { scoreUpload } from './local_modules/score-upload' params(song_params)
79+
include { songPublish } from './local_modules/song-publish' params(song_params)
80+
81+
82+
workflow songScoreUpload {
83+
take: study_id
84+
take: payload
85+
take: upload
86+
87+
main:
88+
// Create new analysis
89+
songSubmit(study_id, payload)
90+
91+
// Generate file manifest for upload
92+
songManifest(study_id, songSubmit.out, upload)
93+
94+
// Upload to SCORE
95+
scoreUpload(songSubmit.out, songManifest.out, upload)
96+
97+
// Publish the analysis
98+
songPublish(study_id, scoreUpload.out.ready_to_publish)
99+
100+
emit:
101+
analysis_id = songPublish.out.analysis_id
52102
}
53103

54104

55105
// this provides an entry point for this main script, so it can be run directly without clone the repo
56106
// using this command: nextflow run <git_acc>/<repo>/<pkg_name>/<main_script>.nf -r <pkg_name>.v<pkg_version> --params-file xxx
57107
workflow {
58108
SongScoreUpload(
59-
file(params.input_file)
109+
params.study_id,
110+
file(params.payload),
111+
Channel.fromPath(params.upload)
60112
)
61-
}
113+
}

song-score-upload/tests/checker.nf

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,63 +27,79 @@
2727
nextflow.enable.dsl = 2
2828
version = '0.2.6' // package version
2929

30-
// universal params
31-
params.publish_dir = ""
30+
// universal params go here, change default value as needed
3231
params.container = ""
3332
params.container_registry = ""
34-
params.container_version = ""
33+
params.publish_dir = "" // set to empty string will disable publishDir
34+
35+
params.max_retries = 5 // set to 0 will disable retry
36+
params.first_retry_wait_time = 1 // in seconds
3537

3638
// tool specific parmas go here, add / change as needed
37-
params.input_file = ""
38-
params.expected_output = ""
39-
params.cleanup = false
39+
params.study_id = "TEST-PR"
40+
params.payload = "NO_FILE"
41+
params.upload = []
42+
43+
params.api_token = ""
44+
45+
params.song_cpus = 1
46+
params.song_mem = 1 // GB
47+
params.song_url = "https://song.rdpc-qa.cancercollaboratory.org"
48+
params.song_api_token = ""
49+
params.song_container_version = "4.2.1"
50+
51+
params.score_cpus = 1
52+
params.score_mem = 1 // GB
53+
params.score_transport_mem = 1 // GB
54+
params.score_url = "https://score.rdpc-qa.cancercollaboratory.org"
55+
params.score_api_token = ""
56+
params.score_container_version = "5.0.0"
57+
58+
59+
song_params = [
60+
*:params,
61+
'cpus': params.song_cpus,
62+
'mem': params.song_mem,
63+
'song_url': params.song_url,
64+
'song_container_version': params.song_container_version,
65+
'api_token': params.song_api_token ?: params.api_token,
66+
'publish_dir': ''
67+
]
68+
69+
score_params = [
70+
*:params,
71+
'cpus': params.score_cpus,
72+
'mem': params.score_mem,
73+
'transport_mem': params.score_transport_mem,
74+
'song_url': params.song_url,
75+
'score_url': params.score_url,
76+
'score_container_version': params.score_container_version,
77+
'api_token': params.score_api_token ?: params.api_token
78+
]
4079

4180
include { SongScoreUpload } from '../main'
42-
// include section starts
43-
// include section ends
44-
45-
46-
process file_smart_diff {
47-
input:
48-
path output_file
49-
path expected_file
50-
51-
output:
52-
stdout()
53-
54-
script:
55-
"""
56-
# Note: this is only for demo purpose, please write your own 'diff' according to your own needs.
57-
# remove date field before comparison eg, <div id="header_filename">Tue 19 Jan 2021<br/>test_rg_3.bam</div>
58-
# sed -e 's#"header_filename">.*<br/>test_rg_3.bam#"header_filename"><br/>test_rg_3.bam</div>#'
59-
60-
diff <( cat ${output_file} | sed -e 's#"header_filename">.*<br/>#"header_filename"><br/>#' ) \
61-
<( ([[ '${expected_file}' == *.gz ]] && gunzip -c ${expected_file} || cat ${expected_file}) | sed -e 's#"header_filename">.*<br/>#"header_filename"><br/>#' ) \
62-
&& ( echo "Test PASSED" && exit 0 ) || ( echo "Test FAILED, output file mismatch." && exit 1 )
63-
"""
64-
}
6581

6682

6783
workflow checker {
6884
take:
69-
input_file
70-
expected_output
85+
study_id
86+
payload
87+
upload
7188

7289
main:
7390
SongScoreUpload(
74-
input_file
91+
study_id,
92+
payload,
93+
upload
7594
)
7695

77-
file_smart_diff(
78-
SongScoreUpload.out.output_file,
79-
expected_output
80-
)
8196
}
8297

8398

8499
workflow {
85100
checker(
86-
file(params.input_file),
87-
file(params.expected_output)
101+
params.study_id,
102+
file(params.payload),
103+
Channel.fromPath(params.upload)
88104
)
89105
}

0 commit comments

Comments
 (0)