Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --empty-template flag for creating modules #2175

Merged
merged 17 commits into from
Feb 6, 2023

Conversation

mirpedrol
Copy link
Member

@mirpedrol mirpedrol commented Feb 3, 2023

Close #2091

How to run
nf-core modules create --empty-template foo

Output files:

modules/nf-core/foo/main.nf
process FOO {
    tag "$meta.id"
    label 'process_single'

    conda "YOUR-TOOL-HERE"
    container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
        'https://depot.galaxyproject.org/singularity/YOUR-TOOL-HERE':
        'quay.io/biocontainers/YOUR-TOOL-HERE' }"

    input:
    tuple val(meta), path(input)

    output:
    tuple val(meta), path("*"), emit: output
    path "versions.yml"           , emit: versions

    when:
    task.ext.when == null || task.ext.when

    script:
    def args = task.ext.args ?: ''
    def prefix = task.ext.prefix ?: "${meta.id}"
    """

    cat <<-END_VERSIONS > versions.yml
    "${task.process}":
        : \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' ))
    END_VERSIONS
    """
}
modules/nf-core/foo/meta.yml
name: "foo"
description: write your description here
keywords:
  - sort
tools:
  - "foo":
      description: ""
      homepage: ""
      documentation: ""
      tool_dev_url: ""
      doi: ""
      licence: ""

input:
  # Only when we have meta
  - meta:
      type: map
      description: |
        Groovy Map containing sample information
        e.g. [ id:'test', single_end:false ]
  
  
  - input:
    type: file
    description: 
    pattern: 

output:
  #Only when we have meta
  - meta:
      type: map
      description: |
        Groovy Map containing sample information
        e.g. [ id:'test', single_end:false ]
  
  - versions:
      type: file
      description: File containing software versions
      pattern: "versions.yml"
  
  - output:
    type: file
    description: 
    pattern: 

authors:
  - "@mirpedrol"
tests/modules/nf-core/foo/main.nf
#!/usr/bin/env nextflow

nextflow.enable.dsl = 2

include { FOO } from '../../../../modules/nf-core/foo/main.nf'

workflow test_foo {
    
    input = [
        [ id:'test', single_end:false ], // meta map
        file(params.test_data['sarscov2']['illumina']['test_paired_end_bam'], checkIfExists: true)
    ]

    FOO ( input )
}
tests/modules/nf-core/foo/test.yml
- name: "foo"
  command: nextflow run ./tests/modules/nf-core/foo -entry test_foo -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/foo/nextflow.config
  tags:
    - "foo"
  files:
    - path: ""

PR checklist

  • This comment contains a description of changes (with reason)
  • CHANGELOG.md is updated
  • If you've fixed a bug or added code that should be tested, add tests!
  • Documentation in docs is updated

@github-actions

This comment was marked as resolved.

@mirpedrol mirpedrol changed the base branch from master to dev February 3, 2023 12:00
@codecov
Copy link

codecov bot commented Feb 3, 2023

Codecov Report

Merging #2175 (c6cf507) into dev (110cec8) will decrease coverage by 0.01%.
The diff coverage is 80.26%.

@@            Coverage Diff             @@
##              dev    #2175      +/-   ##
==========================================
- Coverage   71.54%   71.53%   -0.01%     
==========================================
  Files          77       77              
  Lines        8367     8340      -27     
==========================================
- Hits         5986     5966      -20     
+ Misses       2381     2374       -7     
Impacted Files Coverage Δ
nf_core/bump_version.py 89.47% <ø> (ø)
nf_core/create.py 65.01% <ø> (+0.38%) ⬆️
nf_core/download.py 52.72% <ø> (ø)
nf_core/launch.py 63.26% <ø> (ø)
nf_core/lint/__init__.py 74.18% <ø> (ø)
nf_core/lint/files_unchanged.py 72.61% <ø> (ø)
nf_core/lint/template_strings.py 87.50% <ø> (ø)
nf_core/list.py 79.82% <ø> (ø)
nf_core/modules/bump_versions.py 63.90% <ø> (ø)
nf_core/utils.py 82.38% <ø> (+0.24%) ⬆️
... and 11 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@mashehu
Copy link
Contributor

mashehu commented Feb 3, 2023

Nice! I am just not 100% sure about the parameter name (as usual 🙄). "minimal" is a bit too vague for me (could for example mean without tests, like we do for local modules). What do you think about --no-todos?

@mirpedrol
Copy link
Member Author

🤔 There are also some things stripped apart from TODOs, like the command example. Maybe --empty-template or something similar?

@mirpedrol mirpedrol marked this pull request as ready for review February 3, 2023 13:45
@mirpedrol mirpedrol changed the title Add --minimal flag for creating modules Add --empty-template flag for creating modules Feb 3, 2023
Copy link
Contributor

@mashehu mashehu left a comment

Choose a reason for hiding this comment

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

thinking more about this functionality, it might be cumbersome to always have to remove the todo statements, at the same time they help to be sure one doesn't forget something (which might happen easily with all the different files). Do we lint for the most important things we mention in the todos?

nf_core/__main__.py Outdated Show resolved Hide resolved
Co-authored-by: Matthias Hörtenhuber <mashehu@users.noreply.github.com>
@mirpedrol
Copy link
Member Author

Yes, I agree it's good to have them as a checklist, I think this feature is only for people who are very used to add modules and don't need them.
We don't lint for most of the TODOs because it's difficult to lint those, they depend a lot on the module. But we lint for the important things, and reviewers usually check the steps mentioned in the TODOs.

@mirpedrol mirpedrol merged commit 0298ebd into nf-core:dev Feb 6, 2023
@mirpedrol mirpedrol deleted the modules-create-minimal branch February 6, 2023 08:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants