Skip to content

Commit

Permalink
Merge pull request #2 from AlexVCaron/fix/port_workflow_errors
Browse files Browse the repository at this point in the history
Fix port workflow errors
  • Loading branch information
arnaudbore authored Sep 16, 2024
2 parents 907e5d1 + f30020e commit 1caf80a
Show file tree
Hide file tree
Showing 11 changed files with 132 additions and 94 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,11 @@ indent_size = 2

[LICENSE]
indent_size = unset

[tests/.runs]
charset = unset
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
indent_style = unset
indent_size = unset
18 changes: 18 additions & 0 deletions .editorconfig-checker.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"Verbose": true,
"Debug": false,
"IgnoreDefaults": false,
"SpacesAftertabs": false,
"NoColor": false,
"Exclude": ["^tests/.runs/", "^\\.nf-test/", "^\\.venv/", "^\\node_modules/", "\\.nf-test.log$"],
"AllowedContentTypes": [],
"PassedFiles": [],
"Disable": {
"EndOfLine": false,
"Indentation": false,
"IndentSize": false,
"InsertFinalNewline": false,
"TrimTrailingWhitespace": false,
"MaxLineLength": false
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ yarn-error.log
.work/
.nextflow*
.nf-test*
tests/.runs/

# Misc
.DS_Store
Expand Down
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
.nextflow/
.nf-test/
.pytest_cache/
.test_data/
tests/.runs/
venv/
.venv/
.vscode/
85 changes: 43 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,45 +18,44 @@ primary focus of the library is to provide pre-built processes and processing se
technologies and made easily available to pipeline's developers through the `nf-core`
framework.

* [Using modules from `nf-neuro`](#using-modules-from-nf-neuro)
* [Developing in `nf-neuro`](#developing-in-nf-neuro)
* [Manual configuration](#manual-configuration)
* [Dependencies](#dependencies)
* [Python environment](#python-environment)
* [Loading the project's environment](#loading-the-projects-environment)
* [Global environment](#global-environment)
* [Working with VS Code](#working-with-vs-code)
* [Configuration via the `devcontainer` :](#configuration-via-the-devcontainer-)
* [Contributing to the `nf-neuro` project](#contributing-to-the-nf-neuro-project)
* [Adding a new module to nf-neuro](./docs/MODULE.md#adding-a-new-module-to-nf-neuro)
* [Generate the template](./docs/MODULE.md#generate-the-template)
* [Edit the template](./docs/MODULE.md#edit-the-template)
* [Edit `main.nf`:](./docs/MODULE.md#edit-mainnf)
* [Edit `environment.yml`:](./docs/MODULE.md#edit-environmentyml)
* [Edit `meta.yml`:](./docs/MODULE.md#edit-metayml)
* [Create test cases](./docs/MODULE.md#create-test-cases)
* [Edit `tests/main.nf.test`:](./docs/MODULE.md#edit-testsmainnftest)
* [Edit `tests/nextflow.config`:](./docs/MODULE.md#edit-testsnextflowconfig)
* [Generate tests snapshots](./docs/MODULE.md#generate-tests-snapshots)
* [Lint your code](./docs/MODULE.md#lint-your-code)
* [Submit your PR](./docs/MODULE.md#submit-your-pr)
* [Defining optional input parameters](./docs/MODULE.md#defining-optional-input-parameters)
* [Test data infrastructure](./docs/MODULE.md#test-data-infrastructure)
* [Adding a new subworkflow to nf-neuro](./docs/SUBWORKFLOWS.md#adding-a-new-subworkflow-to-nf-neuro)
* [Generate the template](./docs/SUBWORKFLOWS.md#generate-the-template)
* [Edit the template](./docs/SUBWORKFLOWS.md#edit-the-template)
* [Edit `main.nf`](./docs/SUBWORKFLOWS.md#edit-mainnf)
* [Define your subworkflow inputs](./docs/SUBWORKFLOWS.md#define-your-subworkflow-inputs)
* [Fill the `main:` section](./docs/SUBWORKFLOWS.md#fill-the-main-section)
* [Define your Workflow outputs](./docs/SUBWORKFLOWS.md#define-your-workflow-outputs)
* [Edit `meta.yml`](./docs/SUBWORKFLOWS.md#edit-metayml)
* [Create test cases](./docs/SUBWORKFLOWS.md#create-test-cases)
* [Lint your code](./docs/SUBWORKFLOWS.md#lint-your-code)
* [Submit your PR](./docs/SUBWORKFLOWS.md#submit-your-pr)
* [Running tests](#running-tests)
* [Configuring Docker for easy usage](#configuring-docker-for-easy-usage)
* [Installing Prettier](#installing-prettier)

- [Using modules from `nf-neuro`](#using-modules-from-nf-neuro)
- [Developing in `nf-neuro`](#developing-in-nf-neuro)
- [Manual configuration](#manual-configuration)
- [Dependencies](#dependencies)
- [Python environment](#python-environment)
- [Loading the project's environment](#loading-the-projects-environment)
- [Global environment](#global-environment)
- [Working with VS Code](#working-with-vs-code)
- [Configuration via the `devcontainer`](#configuration-via-the-devcontainer)
- [Contributing to the `nf-neuro` project](#contributing-to-the-nf-neuro-project)
- [Adding a new module to nf-neuro](./docs/MODULE.md#adding-a-new-module-to-nf-neuro)
- [Generate the template](./docs/MODULE.md#generate-the-template)
- [Edit the template](./docs/MODULE.md#edit-the-template)
- [Edit `main.nf`](./docs/MODULE.md#edit-mainnf)
- [Edit `environment.yml`](./docs/MODULE.md#edit-environmentyml)
- [Edit `meta.yml`](./docs/MODULE.md#edit-metayml)
- [Create test cases](./docs/MODULE.md#create-test-cases)
- [Edit `tests/main.nf.test`](./docs/MODULE.md#edit-testsmainnftest)
- [Edit `tests/nextflow.config`](./docs/MODULE.md#edit-testsnextflowconfig)
- [Generate tests snapshots](./docs/MODULE.md#generate-tests-snapshots)
- [Lint your code](./docs/MODULE.md#lint-your-code)
- [Submit your PR](./docs/MODULE.md#submit-your-pr)
- [Defining optional input parameters](./docs/MODULE.md#defining-optional-input-parameters)
- [Test data infrastructure](./docs/MODULE.md#test-data-infrastructure)
- [Adding a new subworkflow to nf-neuro](./docs/SUBWORKFLOWS.md#adding-a-new-subworkflow-to-nf-neuro)
- [Generate the template](./docs/SUBWORKFLOWS.md#generate-the-template)
- [Edit the template](./docs/SUBWORKFLOWS.md#edit-the-template)
- [Edit `main.nf`](./docs/SUBWORKFLOWS.md#edit-mainnf)
- [Define your subworkflow inputs](./docs/SUBWORKFLOWS.md#define-your-subworkflow-inputs)
- [Fill the `main:` section](./docs/SUBWORKFLOWS.md#fill-the-main-section)
- [Define your Workflow outputs](./docs/SUBWORKFLOWS.md#define-your-workflow-outputs)
- [Edit `meta.yml`](./docs/SUBWORKFLOWS.md#edit-metayml)
- [Create test cases](./docs/SUBWORKFLOWS.md#create-test-cases)
- [Lint your code](./docs/SUBWORKFLOWS.md#lint-your-code)
- [Submit your PR](./docs/SUBWORKFLOWS.md#submit-your-pr)
- [Running tests](#running-tests)
- [Configuring Docker for easy usage](#configuring-docker-for-easy-usage)
- [Installing Prettier and editorconfig](#installing-prettier-and-editorconfig)

# Using modules from `nf-neuro`

Expand Down Expand Up @@ -188,7 +187,7 @@ This will make it so the `nf-core` commands target the right repository by defau
The `nf-neuro` project curates a bundle of useful extensions for Visual Studio Code, the `nf-neuro-extensions` package. You can find it easily on the [extension
marketplace](https://marketplace.visualstudio.com/items?itemName=nf-neuro.nf-neuro-extensions).

## Configuration via the `devcontainer` :
## Configuration via the `devcontainer`

The `devcontainer` definition for the project contains all required dependencies and setup
steps are automatically executed. To use this installation method, you need to have **Docker** (refer to [this section](#configuring-docker-for-easy-usage) for configuration requirements or validate your configuration) and **Visual Studio Code** installed on your system.
Expand Down Expand Up @@ -239,9 +238,9 @@ sudo usermod -aG docker $USER

After running this command, you need to log out and log back in to apply the changes.

# Installing Prettier
# Installing Prettier and editorconfig

To install **Prettier** for the project, you need to have `node` and `npm` installed on your system to at least version 14. On Ubuntu, you can do it using snap :
To install **Prettier** and **editorconfig** for the project, you need to have `node` and `npm` installed on your system to at least version 14. On Ubuntu, you can do it using snap :

```bash
sudo snap install node --classic
Expand All @@ -256,6 +255,8 @@ curl -fsSL https://deb.nodesource.com/setup_${NODE_MAJOR}.x | bash - &&\
apt-get install -y nodejs

npm install --save-dev --save-exact prettier
npm install --save-dev --save-exact editorconfig-checker

echo "function prettier() { npm exec prettier $@; }" >> ~/.bashrc
echo "function editorconfig-checker() { npm exec editorconfig-checker $@; }" >> ~/.bashrc
```
72 changes: 38 additions & 34 deletions docs/MODULE.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# Contributing to nf-neuro <!-- omit in toc -->

* [Adding a new module to nf-neuro](#adding-a-new-module-to-nf-neuro)
* [Generate the template](#generate-the-template)
* [Edit the template](#edit-the-template)
* [Edit `main.nf`:](#edit-mainnf)
* [Edit `environment.yml`:](#edit-environmentyml)
* [Edit `meta.yml`:](#edit-metayml)
* [Create test cases](#create-test-cases)
* [Edit `tests/main.nf.test`:](#edit-testsmainnftest)
* [Edit `tests/nextflow.config`:](#edit-testsnextflowconfig)
* [Generate tests snapshots](#generate-tests-snapshots)
* [Lint your code](#lint-your-code)
* [Submit your PR](#submit-your-pr)
* [Defining optional input parameters](#defining-optional-input-parameters)
* [Test data infrastructure](#test-data-infrastructure)
- [Adding a new module to nf-neuro](#adding-a-new-module-to-nf-neuro)
- [Generate the template](#generate-the-template)
- [Edit the template](#edit-the-template)
- [Edit `main.nf`](#edit-mainnf)
- [Edit `environment.yml`](#edit-environmentyml)
- [Edit `meta.yml`](#edit-metayml)
- [Create test cases](#create-test-cases)
- [Edit `tests/main.nf.test`](#edit-testsmainnftest)
- [Edit `tests/nextflow.config`](#edit-testsnextflowconfig)
- [Generate tests snapshots](#generate-tests-snapshots)
- [Lint your code](#lint-your-code)
- [Submit your PR](#submit-your-pr)
- [Defining optional input parameters](#defining-optional-input-parameters)
- [Test data infrastructure](#test-data-infrastructure)

# Adding a new module to nf-neuro

Expand Down Expand Up @@ -57,7 +57,7 @@ already follow all guidelines. You will find related files in :
- `modules/nf-neuro/betcrop/fslbetcrop`
- `tests/modules/nf-neuro/betcrop/fslbetcrop`

### Edit `main.nf`:
### Edit `main.nf`

- Remove the line `conda "YOUR-TOOL-HERE"`.

Expand Down Expand Up @@ -148,24 +148,19 @@ already follow all guidelines. You will find related files in :
- Call `touch <file>` to generate empty files for all required outputs.
### Edit `environment.yml`:
### Edit `environment.yml`
Start by removing the comments added automatically by `nf-core`, then, replace the existing `channels` section by:
This file is used by `nf-core` to manage `conda` environements for modules. It is not
used by `nf-neuro` for now, but must be created following a basic format for linting to
pass. The file should contain the following :
```yml
channels:
- Docker
- Apptainer
```yaml
name: <category>_<tool>
channels: []
dependencies: []
```
and add the name of the tools used within your module in the `dependencies` section. For example, if you are using `scilpy` tools, write:
```yml
dependencies:
- scilpy
```
### Edit `meta.yml`:
### Edit `meta.yml`
Fill the sections you find relevant. There is a lot of metadata in this file, but we
don't need to specify them all. At least define the `keywords`, describe the process'
Expand All @@ -189,7 +184,7 @@ The module's test infrastructure is auto-generated when creating a module using
> [!NOTE]
> Multiple tests can be specified one after the other in the `main.nf.test`, be sure to corner most of the use-case of your module to ensure catching any potential bugs!
### Edit `tests/main.nf.test`:
### Edit `tests/main.nf.test`
To specify test data, you need to define a `setup` section before the actual test definition. This setup section will use the `LOAD_TEST_DATA` workflow to fetch your test data from an available package (refer to [this section](#test-data-infrastructure) to learn how to find packages). Once you selected the archives and files you need, add a `setup` section before the test section.
Expand Down Expand Up @@ -295,7 +290,7 @@ Finally, ensure all the tags at the beginning of the process definition include
Make sure there is no more comments generated by the `nf-core` template, and you should be good to go!
### Edit `tests/nextflow.config`:
### Edit `tests/nextflow.config`
The `nextflow.config` file does not exist by default, so you will have to create it if needed. This is not mandatory, except if you have defined optional parameters with `task.ext` and want to alter their values for some test cases. Refer to [this section](#defining-optional-input-parameters) to
see how to scope those parameters to specific tests using `selectors`.
Expand All @@ -316,19 +311,28 @@ nf-core modules test -u <category>/<tool>
```
All the test case you defined will be run, watch out for errors ! Once everything runs
smoothly, look at the snapshot file produced at `tests/main.nf.test.snap` in your module's
smoothly, look at the snapshot file produced at `tests/main.nf.test.snap` in your module's
directory and validate that ALL outputs produced by test cases are caught. Their `md5sum` is
critical to ensure future executions of your test produce valid outputs.
## Lint your code
Before submitting to _nf-neuro_, once you've commit and push everything, the code need to be correctly linted, else the checks won't pass. This is done using `prettier` on your new module, through the _nf-core_ command line :
Before submitting to _nf-neuro_, once you've commit and push everything, the code need to be correctly linted, else the checks won't pass. This is done using `prettier` and `editorconfig-checker` on your new module, through the _nf-core_ command line :
```bash
nf-core modules lint <category>/<tool>
```
You'll probably get a bunch of _whitespace_ and _indentation_ errors, but also image errors, bad _nextflow_ syntax and more. You need to fix all `errors` and as much as the `warnings`as possible.
You'll probably get a bunch of _whitespace_ and _indentation_ errors, but also image errors, bad _nextflow_ syntax and more. You need to fix all `errors` and as much as the `warnings` as possible.
If at any point you modified files outside of your module's directory, those also need to be linted. To do so, run the following commands at the root of the repository :
```bash
prettier --check .
editorconfig-checker
```
You'll get lists of syntax errors to fix from both commands. For prettier, you can run `prettier --write .` to fix most of them automatically. For `editorconfig-checker`, you'll have to fix them manually.
## Submit your PR
Expand Down
31 changes: 19 additions & 12 deletions docs/SUBWORKFLOWS.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
# Contributing to nf-neuro <!-- omit in toc -->

* [Adding a new subworkflow to nf-neuro](#adding-a-new-subworkflow-to-nf-neuro)
* [Generate the template](#generate-the-template)
* [Edit the template](#edit-the-template)
* [Edit `main.nf`](#edit-mainnf)
* [Define your subworkflow inputs](#define-your-subworkflow-inputs)
* [Fill the `main:` section](#fill-the-main-section)
* [Define your Workflow outputs](#define-your-workflow-outputs)
* [Edit `meta.yml`](#edit-metayml)
* [Create test cases](#create-test-cases)
* [Lint your code](#lint-your-code)
* [Submit your PR](#submit-your-pr)
- [Adding a new subworkflow to nf-neuro](#adding-a-new-subworkflow-to-nf-neuro)
- [Generate the template](#generate-the-template)
- [Edit the template](#edit-the-template)
- [Edit `main.nf`](#edit-mainnf)
- [Define your subworkflow inputs](#define-your-subworkflow-inputs)
- [Fill the `main:` section](#fill-the-main-section)
- [Define your Workflow outputs](#define-your-workflow-outputs)
- [Edit `meta.yml`](#edit-metayml)
- [Create test cases](#create-test-cases)
- [Lint your code](#lint-your-code)
- [Submit your PR](#submit-your-pr)

# Adding a new subworkflow to nf-neuro

Expand Down Expand Up @@ -152,7 +152,14 @@ Run `prettier` on your new module, through the `nf-core` command line :
nf-core subworkflows lint <subworkflow>
```

and fix all `errors` and as many `warnings` as possible.
and fix all `errors` and as many `warnings` as possible. If at any point you modified files outside of your module's directory, those also need to be linted. To do so, run the following commands at the root of the repository :

```bash
prettier --check .
editorconfig-checker
```

You'll get lists of syntax errors to fix from both commands. For prettier, you can run `prettier --write .` to fix most of them automatically. For `editorconfig-checker`, you'll have to fix them manually.

## Submit your PR

Expand Down
4 changes: 2 additions & 2 deletions modules/environment-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"channels": {
"type": "array",
"items": {
"type": "string"
}
"type": "string"
}
},
"dependencies": {
"type": "array",
Expand Down
2 changes: 1 addition & 1 deletion nf-test.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ config {

ignore ".venv/**/*.nf*"

requires(
requires(
"nf-test": "0.9.0"
)

Expand Down
1 change: 0 additions & 1 deletion tests/.gitignore

This file was deleted.

2 changes: 1 addition & 1 deletion tests/nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ report {
overwrite = true
}

includeConfig "$projectDir/tests/config/nextflow.config"
includeConfig "$projectDir/tests/config/nextflow.config"

0 comments on commit 1caf80a

Please sign in to comment.