Skip to content

Commit aac6dfe

Browse files
Update text after modifying bin documentation
Signed-off-by: Christopher Hakkaart <[email protected]>
1 parent 6627bbc commit aac6dfe

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

docs/module.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ To use this feature, the module binaries must be enabled in your pipeline script
260260
nextflow.enable.moduleBinaries = true
261261
```
262262

263-
Binary scripts must be placed in the module directory named `<module-dir>/resources/usr/bin` and granted execution permissions:
263+
Binary scripts must be placed in the module directory named `<module-dir>/resources/usr/bin` and granted execution permissions. For example:
264264

265265
```
266266
<module-dir>
@@ -276,6 +276,8 @@ Binary scripts must be placed in the module directory named `<module-dir>/resour
276276
Module binary scripts require a local or shared file system for the pipeline work directory, or {ref}`wave-page` when using cloud-based executors.
277277
:::
278278

279+
Scripts can also be stored at the pipeline level using the `bin` directory. See {ref}`bin directory <bundling-executable>` for more information.
280+
279281
## Sharing modules
280282

281283
Modules are designed to be easy to share and re-use across different pipelines, which helps eliminate duplicate work and spread improvements throughout the community. While Nextflow does not provide an explicit mechanism for sharing modules, there are several ways to do it:

docs/process.md

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ workflow {
178178

179179
By default, Nextflow looks for template scripts in the `templates` directory, located alongside the Nextflow script that defines the process. A template can be reused across multiple processes. An absolute path can be used to specify a different template location. However, this practice is discouraged because it hinders pipeline portability.
180180

181-
Templates can be tested independently of pipeline execution. Consider the following template script:
181+
Templates can be tested independently of pipeline execution. However, variables prefixed with the dollar character (`$`) are interpreted as Nextflow variables when the template script is executed by Nextflow and Bash variables when executed directly. Consider the following template script:
182182

183183
```bash
184184
#!/bin/bash
@@ -187,24 +187,18 @@ echo $STR
187187
echo "process completed"
188188
```
189189

190-
The above script can be executed from the command line by providing each input as an environment variable.
190+
The above script can be executed from the command line by providing each input as an environment variable:
191191

192192
```bash
193193
STR='foo' bash templates/my_script.sh
194194
```
195195

196-
Variables prefixed with the dollar character (`$`) are interpreted as Nextflow variables when the template script is executed by Nextflow and Bash variables when executed directly.
197-
198-
The following caveats should be considered when using templates:
196+
Several caveats should be considered when using templates:
199197

200198
- Template scripts are only recommended for Bash scripts.
201-
202199
- Languages that do not prefix variables with `$` (e.g. Python and R) can't be executed directly as a template script from the command line.
203-
204200
- Template variables escaped with `\$` will be interpreted as Bash variables when executed by Nextflow but not the command line.
205-
206201
- Template variables are evaluated even if they are commented out in the template script.
207-
208202
- The pipeline to fail if a template variable is missing, regardless of where it occurs in the template.
209203

210204
:::{tip}

docs/sharing.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,23 +97,27 @@ For maximal reproducibility, make sure to define a specific version for each too
9797

9898
#### The `bin` directory
9999

100-
As for custom scripts, you can include executable scripts in the `bin` directory of your pipeline repository. When configured correctly, these scripts can be executed like a regular command from any process script (i.e. without modifying the `PATH` environment variable or using an absolute path), and changing the script will cause the task to be re-executed on a resumed run (i.e. just like changing the process script itself).
100+
Executable scripts can be included in the pipeline `bin` directory located at the root of your pipeline directory. This allows you to create and organize custom scripts that can be invoked like regular commands from any process in your pipeline without modifying the `PATH` environment variable or using an absolute path. For example:
101101

102-
To configure a custom script:
102+
```
103+
├── bin
104+
│ └── custom_script.py
105+
└── main.nf
106+
```
103107

104-
1. Save the script in the `bin` directory (relative to the pipeline repository root).
105-
2. Specify a portable shebang (see note below for details).
106-
3. Make the script executable. For example: `chmod a+x bin/my_script.py`
108+
Each script should include a shebang line to specify the interpreter for the script. To maximize portability, use `env` to dynamically resolve the interpreter's location instead of hard-coding the interpreter path.
107109

108-
:::{tip}
109-
To maximize the portability of your bundled script, use `env` to dynamically resolve the location of the interpreter instead of hard-coding it in the shebang line.
110+
For example, the shebang definitions `#!/usr/bin/python` and `#!/usr/local/bin/python` hard-code specific paths to the Python interpreter. Use `#!/usr/bin/env python` instead.
110111

111-
For example, shebang definitions `#!/usr/bin/python` and `#!/usr/local/bin/python` both hard-code specific paths to the Python interpreter. Instead, the following approach is more portable:
112+
Scripts placed in the `bin` directory must have executable permissions. Use the `chmod` command to grant the required permissions. For example:
112113

113-
```bash
114-
#!/usr/bin/env python
115114
```
116-
:::
115+
chmod a+x bin/custom_script.py
116+
```
117+
118+
After setting the executable permission, the script can be run directly within your pipeline processes.
119+
120+
Executable scripts can also be stored as scripts that are locally scoped to the processes defined by the tasks. See {ref}`module-binaries` for more information.
117121

118122
#### The `lib` directory
119123

0 commit comments

Comments
 (0)