Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions modules/local/report/render_notebook.nf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Generic process to render a Quarto notebook to HTML
process RENDER_NOTEBOOK {
tag "${report_name}"
label 'process_single'

Comment thread
dimalvovs marked this conversation as resolved.
input:
tuple val(report_name), path(notebook), val(data_dir)
val project_name
val workflow_cmd

Comment thread
dimalvovs marked this conversation as resolved.
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
"""
}
9 changes: 9 additions & 0 deletions tests/fixtures/test.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: "test notebook"
format: html
engine: knitr
---

```{python}
print("Hello world!")
```
Comment on lines +1 to +9

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd still like to execute the test as opposed to a stub-style run.

38 changes: 38 additions & 0 deletions tests/modules/local/report/render_notebook.nf.test
Original file line number Diff line number Diff line change
@@ -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

Comment thread
dimalvovs marked this conversation as resolved.
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
}
Comment thread
dimalvovs marked this conversation as resolved.
}

}
Loading