diff --git a/modules/nf-core/quartonotebook/main.nf b/modules/nf-core/quartonotebook/main.nf index dddae78ffcc6..ce76eb8d4040 100644 --- a/modules/nf-core/quartonotebook/main.nf +++ b/modules/nf-core/quartonotebook/main.nf @@ -17,7 +17,8 @@ process QUARTONOTEBOOK { path input_files output: - tuple val(meta), path("*.html") , emit: html + tuple val(meta), path("*.html") , emit: html, optional: true + tuple val(meta), path("*.pdf") , emit: pdf, optional: true tuple val(meta), path("artifacts/*"), emit: artifacts, optional: true tuple val(meta), path("params.yml") , emit: params_yaml, optional: true path "versions.yml" , emit: versions @@ -39,6 +40,10 @@ process QUARTONOTEBOOK { def implicit_params = (task.ext.implicit_params == null) ? true : task.ext.implicit_params def meta_params = (task.ext.meta_params == null) ? true : task.ext.meta_params + // Get notebook base name and file extension for building final output name + def nb_name = notebook.getBaseName() + def nb_extension = notebook.getExtension() + // Dump parameters to yaml file. // Using a YAML file over using the CLI params because // - No issue with escaping @@ -77,8 +82,12 @@ process QUARTONOTEBOOK { quarto render \\ ${notebook} \\ ${render_args} \\ - ${args} \\ - --output ${prefix}.html + ${args} + + # Change report name to use the prefix and the rendered filetype extension + REPORT=\$(find . -name "${nb_name}.*" -not -name "*.${nb_extension}") + EXTENSION="\${REPORT/.\\/${nb_name}./}" + mv "\$REPORT" "${prefix}.\$EXTENSION" cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-core/quartonotebook/meta.yml b/modules/nf-core/quartonotebook/meta.yml index 2738d16205f6..33fb67f6cc9d 100644 --- a/modules/nf-core/quartonotebook/meta.yml +++ b/modules/nf-core/quartonotebook/meta.yml @@ -50,6 +50,10 @@ output: type: file description: The HTML report generated by Quarto. pattern: "*.html" + - pdf: + type: file + description: The PDF report generated by Quarto. + pattern: "*.pdf" - artifacts: type: file description: Artifacts generated by during report execution. diff --git a/modules/nf-core/quartonotebook/tests/main.nf.test b/modules/nf-core/quartonotebook/tests/main.nf.test index 57cea2f13cfd..ae7f81999050 100644 --- a/modules/nf-core/quartonotebook/tests/main.nf.test +++ b/modules/nf-core/quartonotebook/tests/main.nf.test @@ -45,7 +45,7 @@ nextflow_process { [ id:'test' ], // meta map file(params.test_data['generic']['notebooks']['quarto_python'], checkIfExists: true) // Notebook ] - input[1] = [] // Parameters + input[1] = [:] // Parameters input[2] = [] // Input files """ } @@ -166,6 +166,59 @@ nextflow_process { } + test("test notebook - pdf - [qmd:r]") { + + config "./pdf.config" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.test_data['generic']['notebooks']['quarto_r'], checkIfExists: true) // Notebook + ] + input[1] = [:] // parameters + input[2] = [] // input files + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match() }, + { assert path(process.out.pdf[0][1]).exists() } + ) + } + + } + + test("test notebook - pdf [qmd:python]") { + + config "./pdf.config" + + when { + process { + """ + input[0] = [ + [ id:'test' ], // meta map + file(params.test_data['generic']['notebooks']['quarto_python'], checkIfExists: true) // Notebook + ] + input[1] = [:] // Parameters + input[2] = [] // Input files + """ + } + } + + then { + assertAll( + { assert process.success }, + { assert snapshot(process.out.versions).match() }, + { assert path(process.out.pdf[0][1]).exists() } + ) + } + + } test("test notebook - stub - [qmd:r]") { config "./no-parametrization.config" diff --git a/modules/nf-core/quartonotebook/tests/main.nf.test.snap b/modules/nf-core/quartonotebook/tests/main.nf.test.snap index be0eb0993906..66799db67fb4 100644 --- a/modules/nf-core/quartonotebook/tests/main.nf.test.snap +++ b/modules/nf-core/quartonotebook/tests/main.nf.test.snap @@ -17,7 +17,10 @@ ], "3": [ - "versions.yml:md5,71fc3342027094581a4ad38a59f5d453" + + ], + "4": [ + "versions.yml:md5,93481281b24bb1b44ecc4387e0957a0e" ], "artifacts": [ @@ -32,9 +35,12 @@ ], "params_yaml": [ + ], + "pdf": [ + ], "versions": [ - "versions.yml:md5,71fc3342027094581a4ad38a59f5d453" + "versions.yml:md5,93481281b24bb1b44ecc4387e0957a0e" ] } ], @@ -42,7 +48,7 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-02-06T14:10:04.999966" + "timestamp": "2024-02-07T13:43:09.215767" }, "test notebook - [qmd:r]": { "content": [ @@ -52,7 +58,7 @@ { "id": "test" }, - "test.html:md5,b316056232a6a5e17d53bf29adad253d" + "test.html:md5,dd31182eb085738d02e0b0a7b752b99d" ] ], "1": [ @@ -62,7 +68,10 @@ ], "3": [ - "versions.yml:md5,3539a1dd6be8c177b8c2ab21046a12d4" + + ], + "4": [ + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" ], "artifacts": [ @@ -72,14 +81,17 @@ { "id": "test" }, - "test.html:md5,b316056232a6a5e17d53bf29adad253d" + "test.html:md5,dd31182eb085738d02e0b0a7b752b99d" ] ], "params_yaml": [ + ], + "pdf": [ + ], "versions": [ - "versions.yml:md5,3539a1dd6be8c177b8c2ab21046a12d4" + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" ] } ], @@ -87,12 +99,24 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-02-07T10:56:11.852807" + "timestamp": "2024-02-07T13:42:00.685386" + }, + "test notebook - pdf - [qmd:r]": { + "content": [ + [ + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-02-07T13:42:53.343666" }, "test notebook - parametrized - [qmd:python]": { "content": [ [ - "versions.yml:md5,3539a1dd6be8c177b8c2ab21046a12d4" + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" ], [ [ @@ -115,7 +139,7 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-02-07T10:56:34.645037" + "timestamp": "2024-02-07T13:42:29.143633" }, "test notebook - parametrized - [rmd]": { "content": [ @@ -125,10 +149,13 @@ { "id": "test" }, - "test.html:md5,0662d05b5ca1c9c4547e1c05abdc15f7" + "test.html:md5,2b2026646ed8b59d49fdcbd54cb3a463" ] ], "1": [ + + ], + "2": [ [ { "id": "test" @@ -136,7 +163,7 @@ "artifact.txt:md5,b10a8db164e0754105b7a99be72e3fe5" ] ], - "2": [ + "3": [ [ { "id": "test" @@ -144,8 +171,8 @@ "params.yml:md5,efd62bc975f429e8749ba787a93042dd" ] ], - "3": [ - "versions.yml:md5,3539a1dd6be8c177b8c2ab21046a12d4" + "4": [ + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" ], "artifacts": [ [ @@ -160,7 +187,7 @@ { "id": "test" }, - "test.html:md5,0662d05b5ca1c9c4547e1c05abdc15f7" + "test.html:md5,2b2026646ed8b59d49fdcbd54cb3a463" ] ], "params_yaml": [ @@ -170,9 +197,12 @@ }, "params.yml:md5,efd62bc975f429e8749ba787a93042dd" ] + ], + "pdf": [ + ], "versions": [ - "versions.yml:md5,3539a1dd6be8c177b8c2ab21046a12d4" + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" ] } ], @@ -180,7 +210,7 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-02-07T10:56:41.333553" + "timestamp": "2024-02-07T13:42:36.26751" }, "test notebook - parametrized - [ipynb]": { "content": [ @@ -190,13 +220,16 @@ { "id": "test" }, - "test.html:md5,d0471cfd8394c6e91607885ce1347cda" + "test.html:md5,d7378ec0d1fd83b44424a68bf03a8fc3" ] ], "1": [ ], "2": [ + + ], + "3": [ [ { "id": "test" @@ -204,8 +237,8 @@ "params.yml:md5,efd62bc975f429e8749ba787a93042dd" ] ], - "3": [ - "versions.yml:md5,3539a1dd6be8c177b8c2ab21046a12d4" + "4": [ + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" ], "artifacts": [ @@ -215,7 +248,7 @@ { "id": "test" }, - "test.html:md5,d0471cfd8394c6e91607885ce1347cda" + "test.html:md5,d7378ec0d1fd83b44424a68bf03a8fc3" ] ], "params_yaml": [ @@ -225,9 +258,12 @@ }, "params.yml:md5,efd62bc975f429e8749ba787a93042dd" ] + ], + "pdf": [ + ], "versions": [ - "versions.yml:md5,3539a1dd6be8c177b8c2ab21046a12d4" + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" ] } ], @@ -235,12 +271,12 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-02-07T10:56:47.173321" + "timestamp": "2024-02-07T13:42:42.579337" }, "test notebook - [qmd:python]": { "content": [ [ - "versions.yml:md5,3539a1dd6be8c177b8c2ab21046a12d4" + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" ], [ @@ -253,7 +289,19 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-02-07T10:56:19.76781" + "timestamp": "2024-02-07T13:42:12.977284" + }, + "test notebook - pdf [qmd:python]": { + "content": [ + [ + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" + ] + ], + "meta": { + "nf-test": "0.8.4", + "nextflow": "23.10.1" + }, + "timestamp": "2024-02-07T13:43:04.813815" }, "test notebook - parametrized - [qmd:r]": { "content": [ @@ -263,10 +311,13 @@ { "id": "test" }, - "test.html:md5,86d86df9dc6390aa05749012c57cabc1" + "test.html:md5,6c90e701955162f9e3a4eda64ecb2681" ] ], "1": [ + + ], + "2": [ [ { "id": "test" @@ -274,7 +325,7 @@ "artifact.txt:md5,b10a8db164e0754105b7a99be72e3fe5" ] ], - "2": [ + "3": [ [ { "id": "test" @@ -282,8 +333,8 @@ "params.yml:md5,efd62bc975f429e8749ba787a93042dd" ] ], - "3": [ - "versions.yml:md5,3539a1dd6be8c177b8c2ab21046a12d4" + "4": [ + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" ], "artifacts": [ [ @@ -298,7 +349,7 @@ { "id": "test" }, - "test.html:md5,86d86df9dc6390aa05749012c57cabc1" + "test.html:md5,6c90e701955162f9e3a4eda64ecb2681" ] ], "params_yaml": [ @@ -308,9 +359,12 @@ }, "params.yml:md5,efd62bc975f429e8749ba787a93042dd" ] + ], + "pdf": [ + ], "versions": [ - "versions.yml:md5,3539a1dd6be8c177b8c2ab21046a12d4" + "versions.yml:md5,55e1f767fbd72aae14cbbfb638e38a90" ] } ], @@ -318,6 +372,6 @@ "nf-test": "0.8.4", "nextflow": "23.10.1" }, - "timestamp": "2024-02-07T10:56:26.703136" + "timestamp": "2024-02-07T13:42:20.385595" } } \ No newline at end of file diff --git a/modules/nf-core/quartonotebook/tests/pdf.config b/modules/nf-core/quartonotebook/tests/pdf.config new file mode 100644 index 000000000000..57a3dcfd3b3c --- /dev/null +++ b/modules/nf-core/quartonotebook/tests/pdf.config @@ -0,0 +1,4 @@ +process { + ext.parametrize = false + ext.args = "--to pdf" +}