Giter VIP home page Giter VIP logo

hello-mess-nf's Introduction

logo

Hello Mess Pipeline

Nextflow

This pipeline demonstrates how to integrate the Zero-Mess library to send events to a Kafka-compatible broker.

Description

4 processes, each of them appends a line (in a different language) to a file consumed by the next process. At the end of the execution, the content of the final file is shown.

Messages

There are two types of messages:

  • Stateful messages (PipelineMessage, ProcessMessage)
  • Stateless messages (BashMessage)

Stateful messages are used inside the main pipeline code and benefit from the current state of the execution.

Stateless messages are executed locally or remotely inside a process execution (task). They don't have a state nor can access to the pipeline's state. They need more parameters as they must be 'self-contained'.

Pipeline Messages

Pipeline messages can be sent at any point in the pipeline Groovy code (main workflow, subworkflows, etc.).

The following code shows how to build and send a message that notifies the pipeline has started:

PipelineMessage.started().forTopic('pipelineEvents')
        .data('launch time', "${workflow.start.format('dd-MMM-yyyy HH:mm:ss')}")
        .data('hope', 'wish it works').send()

or

PipelineMessage.started(workflow).forTopic('pipelineEvents')
        .data('hope', 'wish it works').send()

In the latter case, PipelineMessage extracts some default metadata from the workflow object and add them to the message.

data() can be invoked as many times as needed, and it keeps appending information to the message payload.

Process Messages

A process can log started and completed events using ProcessMessage inside the beforeScript and afterScript directives.

These two directives allow to specify one or more commands to execute in a shell before and after the process execution. For this reason, the buildCommand() should be invoked instead of send()

process A {
    // Messaging
    beforeScript ProcessMessage.started('A').forTopic('processEvents').data('my info','message').buildCommand()
    
    afterScript ProcessMessage.completed('A').forTopic('processEvents').data('another info','another message').buildCommand()

    input:
    
    output:
    
    """
    """
}

As for PipelineMessage, data() can be invoked as many times as needed.

Bash messages

If the process' script is a Bash script, the BashMessage function can be used at any point in the script.

The expected parameters are:

  • the topic where to publish the message
  • the data for the payload. Format:
    "name1":"value1","name2":"value2","name3":"value3"
    surrounded by single quotes. For example:
BashMessage 'taskEvents' '"process":"A"','"messageStatus":"about to echo from A"'
echo 'Hello from A' > helloA.txt
if [[ $? != 0 ]]; then
    BashMessage 'A.failure' '"process":"A"',"exitStatus":"127","message":"A failed to echo"'
    exit 127
fi

Execution

Clone the project and run:

nextflow run main.nf  

or with pipeline sharing, just run:

nextflow run eipm/hello-mess-nf

Note: The pipeline will run but won't publish any message. For that, you need to start an instance of Kafka-Dispatcher and configure the related endpoint in nextflow.config.

hello-mess-nf's People

Contributors

manuelesimi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.