Skip to content

Commit 8b2a57c

Browse files
author
Yan Xu
committed
Move report options from command to config file
1 parent af0b61f commit 8b2a57c

File tree

5 files changed

+35
-14
lines changed

5 files changed

+35
-14
lines changed

webapp/server/config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ const config = {
8484
JOBS_INPUT_MAX_SIZE_BYTES: makeIntIfDefined(process.env.NEXTFLOW_JOBS_INPUT_MAX_SIZE_BYTES) || 161061273600,
8585
// Directory of the workflow files.
8686
WORKFLOW_DIR: process.env.NEXTFLOW_WORKFLOW_DIR || NEXTFLOW_BASE_DIR,
87-
// Directory of the workflow templates. The Workflow templates are used for creating cromwell inputs.
87+
// Directory of the workflow templates. The Workflow templates are used for creating nextflow workflow inputs.
8888
TEMPLATE_DIR: process.env.NEXTFLOW_TEMPLATE_DIR || path.join(NEXTFLOW_BASE_DIR, 'templates'),
89+
// Directory of the workflow configs. The Workflow configs are used for running nextflow workflows.
90+
CONFIG_DIR: process.env.NEXTFLOW_TEMPLATE_DIR || path.join(NEXTFLOW_BASE_DIR, 'configs'),
8991
},
9092
CROMWELL: {
9193
// Base URL at which HTTP clients can access the Cromwell API.

webapp/server/utils/nextflow.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const fs = require('fs');
33
const ejs = require('ejs');
44
const Papa = require('papaparse');
55
const Job = require('../edge-api/models/job');
6-
const { workflowList, generateWorkflowResult } = require('./workflow');
6+
const { nextflowConfigs, workflowList, generateWorkflowResult } = require('./workflow');
77
const { write2log, execCmd, sleep } = require('./common');
88
const logger = require('./logger');
99
const config = require('../config');
@@ -13,7 +13,12 @@ const generateInputs = async (projHome, projectConf, proj) => {
1313
// workflowList in utils/workflow
1414
const workflowSettings = workflowList[projectConf.workflow.name];
1515
const template = String(fs.readFileSync(`${config.NEXTFLOW.TEMPLATE_DIR}/${workflowSettings.config_tmpl}`));
16-
const params = { ...projectConf.workflow.input, outdir: `${projHome}/${workflowSettings.outdir}`, project: proj.name };
16+
const params = {
17+
...projectConf.workflow.input,
18+
outdir: `${projHome}/${workflowSettings.outdir}`,
19+
project: proj.name,
20+
report_config: `${config.NEXTFLOW.CONFIG_DIR}/${nextflowConfigs.report_config}`
21+
};
1722
// render input template and write to nextflow_params.json
1823
const inputs = ejs.render(template, params);
1924
await fs.promises.writeFile(`${projHome}/nextflow.config`, inputs);
@@ -35,12 +40,8 @@ const submitWorkflow = async (proj, projectConf, inputsize) => {
3540
return;
3641
}
3742
// submit workflow
38-
const runReport = `${projHome}/nextflow/report.html`;
39-
const runTrace = `${projHome}/nextflow/trace.txt`;
40-
const runTimeline = `${projHome}/nextflow/timeline.html`;
4143
const runName = `edge-${proj.code}`;
42-
const nextflowRunOptions = `-with-report ${runReport} -with-trace ${runTrace} -with-timeline ${runTimeline}`;
43-
const cmd = `cd ${workDir}; nextflow -c ${projHome}/nextflow.config -bg -q run ${config.NEXTFLOW.WORKFLOW_DIR}/${workflowList[projectConf.workflow.name].nextflow_main} -name ${runName} ${nextflowRunOptions}`;
44+
const cmd = `cd ${workDir}; nextflow -c ${projHome}/nextflow.config -bg -q run ${config.NEXTFLOW.WORKFLOW_DIR}/${workflowList[projectConf.workflow.name].nextflow_main} -name ${runName}`;
4445
write2log(log, 'Run pipeline');
4546
// Don't need to wait for the command to complete. It may take long time to finish and cause an error.
4647
// The updateJobStatus will catch the error if this command failed.

webapp/server/utils/workflow.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ const config = require('../config');
55

66
const cromwellWorkflows = ['sra2fastq'];
77
const nextflowWorkflows = ['runFaQCs'];
8+
const nextflowConfigs = {
9+
report_config: 'report.config',
10+
};
811

912
const workflowList = {
1013
default_wdl_version: '1.0',
@@ -19,7 +22,7 @@ const workflowList = {
1922
},
2023
runFaQCs: {
2124
outdir: 'output/runFaQCs',
22-
nextflow_main: 'testmain.nf',
25+
nextflow_main: 'main.nf',
2326
config_tmpl: 'runFaQCs_config.tmpl',
2427
},
2528
};
@@ -84,6 +87,7 @@ const generateWorkflowResult = (proj) => {
8487
module.exports = {
8588
cromwellWorkflows,
8689
nextflowWorkflows,
90+
nextflowConfigs,
8791
workflowList,
8892
linkUpload,
8993
generateWorkflowResult,
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
report {
2+
enabled = true
3+
file = 'report.html'
4+
overwrite = true
5+
}
6+
7+
timeline {
8+
enabled = true
9+
file = 'timeline.html'
10+
overwrite = true
11+
}
12+
13+
trace {
14+
enabled = true
15+
file = 'trace.txt'
16+
fields = 'name,status,start,complete,duration'
17+
overwrite = true
18+
}

workflows/Nextflow/templates/runFaQCs_config.tmpl

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,4 @@ executor {
8787
submitRateLimit = '1/5sec'
8888
}
8989

90-
trace {
91-
enabled = true
92-
file = 'trace.txt'
93-
fields = 'name,status,start,complete,duration'
94-
}
90+
includeConfig "<%= report_config %>"

0 commit comments

Comments
 (0)