diff --git a/modules/local/report/render_notebook.nf b/modules/local/report/render_notebook.nf new file mode 100644 index 0000000..5b98d4d --- /dev/null +++ b/modules/local/report/render_notebook.nf @@ -0,0 +1,32 @@ +// Generic process to render a Quarto notebook to HTML +process RENDER_NOTEBOOK { + tag "${report_name}" + label 'process_single' + + input: + tuple val(report_name), path(notebook), val(data_dir) + val project_name + val workflow_cmd + + output: + path "${report_name}.html" + + script: + """ + ## copy quarto notebook to working directory + cp $notebook ${report_name}.qmd + + ## render qmd report to html + quarto render ${report_name}.qmd \\ + -P project_name:${project_name} \\ + -P workflow_cmd:'${workflow_cmd}' \\ + -P project_dir:${data_dir} \\ + -P sample_table:${file(params.samplesheet)} \\ + --to html + """ + + stub: + """ + touch ${report_name}.html + """ +} diff --git a/tests/fixtures/test.qmd b/tests/fixtures/test.qmd new file mode 100644 index 0000000..2ab696a --- /dev/null +++ b/tests/fixtures/test.qmd @@ -0,0 +1,9 @@ +--- +title: "test notebook" +format: html +engine: knitr +--- + +```{python} +print("Hello world!") +``` diff --git a/tests/modules/local/report/render_notebook.nf.test b/tests/modules/local/report/render_notebook.nf.test new file mode 100644 index 0000000..6497f1d --- /dev/null +++ b/tests/modules/local/report/render_notebook.nf.test @@ -0,0 +1,38 @@ +nextflow_process { + + name "Test RENDER_NOTEBOOK" + script "modules/local/report/render_notebook.nf" + process "RENDER_NOTEBOOK" + + test("Should render basic notebook") { + // note that on Mac M series, jupyter may fail in container + // so the test notebook uses knitr engine instead + + tag "basic" + tag "notebook" + + when { + params { + samplesheet = "${projectDir}/tests/fixtures/valid_samplesheet.csv" + } + + process { + """ + input[0] = [ + "test_notebook", + file("${projectDir}/tests/fixtures/test.qmd"), + "${projectDir}/tests/fixtures" + ] + input[1] = "TCRtoolkit" + input[2] = "nextflow run main.nf" + """ + } + } + + then { + assert process.success + assert process.out.size() == 1 + } + } + +}