run your first pipeline permalink

run a built-in pipeline permalink

Run one of the built-in pipelines to get a feel for it:

$ pypyr echo "Ceci n'est pas une pipe"

echo is the name of a built-in pypyr pipeline. The pipeline simply echoes the input string back to console output using the built-in echo step.

The actual pipeline looks like this:

# To execute this pipeline, shell something like:
# pypyr echo text goes here
context_parser: pypyr.parser.string
steps:
  - name: pypyr.steps.contextcopy
    comment: assign input arg to echoMe so echo step can echo it
    in:
      contextCopy:
        echoMe: argString
  - pypyr.steps.echo

You can achieve the same thing by running a pipeline where you set the context in the pipeline yaml rather than passing in as the 2nd positional argument:

$ pypyr magritte
# To execute this pipeline, shell something like:
# pypyr magritte
steps:
  - name: pypyr.steps.echo
    comment: output echoMe
    in:
      echoMe: Ceci n'est pas une pipe

write your first pipeline permalink

A pipeline is simply a yaml file.

The simplest pipeline just needs a steps list. This is the default entry point. steps is a list that has a bunch of individual steps in it that will run sequentially one after the other.

# ./my-first-pipeline.yaml
# To execute this pipeline, shell something like:
# pypyr my-first-pipeline
steps:
  - name: pypyr.steps.echo
    comment: output echoMe
    in:
      echoMe: this is step 1
  - name: pypyr.steps.cmd
    comment: actually invokes any program on your system.
             the program must be available in current path.
             run any program you fancy.
             we're just running echo here for an easy demo.
    in:
      cmd: echo this is step 2

Save this file as ./my-first-pipeline.yaml.

Now you can run your pipeline like this:

term
$ pypyr my-first-pipeline
this is step 1
this is step 2

$

passing arguments to your pipeline permalink

You can pass arguments from the command line to your pipeline easy peasy.

All you need to do is add a context_parser

In this example we’ll be using a key-value pair parser, which will let you specify your own key-value pairs so you can access the values you need by key. There are other types of context parser that can parse the cmd input differently for you.

The context parser will add these values into the pypyr context for you. Your pipeline steps can then use these values as they please with {formatting expressions}.

# ./pipe-with-args.yaml
# To execute this pipeline, shell something like:
# pypyr pipe-with-args akey=avalue anotherkey="another arbitrary value"
context_parser: pypyr.parser.keyvaluepairs
steps:
  - name: pypyr.steps.echo
    in:
      echoMe: this is akey's value {akey}. It came from the cli args.
  - name: pypyr.steps.cmd
    in:
      cmd: echo we can inject {anotherkey} into your cmd

Save this file as ./pipe-with-args.yaml.

Now you can run this pipeline like this:

term
$ pypyr pipe-with-args akey=avalue anotherkey="another value"
this is akey's value avalue. It came from the cli args.
we can inject another value into your cmd

$
last updated on .