Skip to content

Side Quest: best practices for Python scripts #972

Description

@bentsherman

Inspired by: nextflow-io/nextflow#5172

This page should basically expand on this sentence we added recently about template scripts:

The best practice for using a custom script is to embed it in the process definition at first and move it to a separate file with its own command line interface once the code matures.

I imagined it as a tutorial that focuses on Python scripts. We would write a small pipeline that wires together 2-3 python scripts:

  1. Start with each script embedded in the process definition
  2. In a second iteration, move each script into a separate file, add a CLI to it using argparse, and call the script like a regular command-line tool from the process definition

The main thing we want to show is the design of the CLI for each Python script based on the process inputs/outputs. This is the best practice for custom Python scripts with Nextflow but we don't have any material on it.

The main question is what should the pipeline be. My hyperopt pipeline might be too complex, so maybe we could do some simple text processing instead. You could take the your first script example or something from the training and replace the bash commands with Python scripts.

Feel free to close if something similar is already written

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions