Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Introduction

This tutorial is designed to introduce the concept of building simple workflows within Kepler 2.5.

[Kepler|https://kepler-project.org/] is a workflow engine and design platform for analysing and modelling scientific data. Kepler provides a graphical interface and a library of pre-defined components to enable users to construct scientific workflows which can undertake a wide range of functionality. It is primarily designed to access, analyse, and visualise scientific data but can be used to construct whole programs or run pre-existing simulation codes.

...

The main components in a Kepler workflow are actors, which are used in a design (inherited from Ptolemy II) that separates workflow components ("actors") from workflow orchestration ("directors"), making components more easily reusable. Workflows can work at very levels of granularity, from low-level workflows (that explicitly move data around or start and monitor remote jobs, for example) to high-level workflows that interlink complex steps/actors. Actors can be reused to construct more complex actors enabling complex functionality to be encapsulated in easy to use packages. A wide range of actors are available for use and reuse.{

Panel

...

title

...

Table of Contents

...

...

Table of Contents

...

maxLevel

...

6

...

Anchor
serpens
serpens

...

1 Installing Kepler

...

Warning

...

title

...

Requirements

...

...

  • Kepler take ~300 MB. Please make sure that you have at least this amount of free space available.

...

  • The required version of JRE is 1.8. Please check if you have it installed on your system before taking further steps described in this tutorial.

...

Info
titleInstalling Kepler

...

Download and install kepler from:

...

https://kepler-project.org/users/downloads
You can always access tutorial workflows at following address:

...

http://scilla.man.poznan.pl/kepler_basics/tutorial.tar

{info}Now you can start Kepler application and proceed to tutorial examples.h4.

1.1 Running Kepler in Docker based installation

If you are running Docker based installation, simply *Right Click* and choose *_Kepler_* from the menu. It will start Kepler application.

!DockerOpenWorkflow.gif!

...

Image Added

2. Executing simple workflows

In order to execute workflow, you have to load workflow XML file into Kepler. During this tutorial session we will use following workflows:||

Workflow description

...

Location

...

...

"Hello world"

...

$HOME/tutorial/workflow/basic/Hello_World.xml

...

...

"Hello world debug"

...

$HOME/tutorial/workflow/basic/Hello_World_Debug.xml

...

...

"If-else-simple"

...

$HOME/tutorial/workflow/basic/if_else_simple.xml

...

...

"If-else-simple-expression"

...

$HOME/tutorial/workflow/basic/if_else_simple_expression.xml

...

...

"Simple-Loop"

...

$HOME/tutorial/workflow/basic/simple_loop.xml

...

...

"Array-Copy-Loop"

...

$HOME/tutorial/workflow/basic/array_loop_copy_files.xml

...

...

"Feedback-Loop"

...

$HOME/tutorial/workflow/basic/array_loop_composite_repeat_feedback.xml

...

...

"Loop with relation"

...

$HOME/tutorial/workflow/basic/loop/ssimple_loop_relation.xml

...

...

"Loop without DDF Boolean Select"

...

$HOME/tutorial/workflow/basic/loops/loop-no-ddf-b-s.xml

...

...

"Loop based on variables"

...

$HOME/tutorial/workflow/basic/loops/loop-variables.xml

...

...

"Loop using encapsulated Python script"

...

$HOME/tutorial/workflow/basic/python/python_script.xml

...

...

"Series plotting based on looped computations"

...

$HOME/tutorial/workflow/basic/python/xyplotter.xml

...

...

2.1 Hello world workflow

...

2.1.1 Using existing "Hello world" workflow

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to start Kepler
  • know how to load simple workflow

...

  • know how to execute workflow

...

  • know how to animate workflow

...

Panel

...

...

title

...

Exercise no. 1 (approx. 10 min)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=1xsPH6Mnzx0
In this exercise you will execute simple Kepler workflow. In order to this follow the instructions:

...

  1. Start Kepler application by issuing:

...

  1. Code Block

...

  1. cd ~/kepler/

...

  1. 
    ./kepler.sh

...

  1. 
    

...

  1. Open "Hello world" workflow by issuing: File

...

  1. -> Open and navigate to:

...

  1. Code Block

...

  1. $HOME/tutorial/workflow/basic/Hello_World.xml
    

...

  1. After workflow is opened, press "Play" button

...

  1. Image Added
    workflow should generate output within Display actor

...

  1. Info

...

  1. title

...

  1. Animating workflows

...

  1. In Kepler it is possible to animate workflows during execution. In order to animate workflow you have to turn on animations. You can do this by choosing:

...

  1. Tools

...

  1. -> Animate at Runtime...

...


  1. Demo movie for this feature can be found at following location:

...

  1. animation

2.

...

1.2 Using existing "Hello world - with debug" workflow

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to start Kepler

...

  • know how to load simple workflow

...

  • know how to execute workflow

...

  • know how to listen to the actor

...

Panel

...

...

title

...

Exercise no. 2 (approx. 10 min)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=EVGSXC4kcks
In this exercise you will execute simple Kepler workflow with Debug information. In order to this follow the instructions:

...

  1. If Kepler is not already running start it by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh
    

...

  1. Open "Hello world debug" workflow by issuing: File

...

  1. -> Open and navigate to:

...

  1. Code Block

...

  1. $HOME/tutorial/workflow/basic/Hello_World_Debug.xml

...

  1. 
    

...

  1. After workflow is opened, "Right-click"

...

  1. Expression

...

  1. actor and choose "Listen to actor"

...

  1. Press "Play" button

...

  1. Image Added
    Workflow should generate output within Display actor and should print debug information generated by Expression actor

...

...

2.1.3 Building "Hello world" from the scratch

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to start Kepler

...

  • know how to build simple workflow

...

  • know how to connect elements

...

  • know how to add elements to the workflow

...

  • know how to search for the actors within Kepler's library

...

Panel

...

title
Exercise no. 3 (approx. 15)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=DXXYnuDjnWw

In this exercise you will build simple "Hello World" workflow and execute it. In order to get this task done, follow the instructions:

...

  1. If Kepler is not already running start it by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh
    

...

  1. Type in "SDF" into "Search" field and press "Search" button

...

  1. Drag and Drop

...

  1. SDF director

...

  1. into workflow

...

  1. Right-click on

...

  1. SDF director

...

  1. and choose "Configure Director"

...

  1. Set number of iterations to "1"

...

  1. Type in "String" into "Search" field and press "Search" button

...

  1. Add "String Constant" actor to the workflow

...

  1. Right-click "String Constant" actor and choose "Configure Actor"

...

  1. Type "Hello world

...

  1. !" into "value" field

...

  1. Commit changes

...

  1. Type in "Display" into "Search" field and press "Search" button

...

  1. Add "Display" actor into workflow

...

  1. Connect "String Constant" actor with "Display" actor

...

  1. Intermediate results

...

  1. Image Added

  2. After workflow is ready, press "Play" button

...

  1. Image Added
    workflow should generate output within Display actor

...

...

2.2 Relations, Paths and Synchronization

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to add elements into workflow

...

  • know hot to use expressions

...

  • know how to synchronize workflow's execution

...

  • know how to use parametrs

...

  • know how to use relations

...

Panel

...

...

title

...

Exercise no. 4 (approx. 20 minutes)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=OCO9L5MzUrM

...

  1. If Kepler is not already running start it by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh
    

...

  1. Add

...

  1. DDF

...

  1. director into workflow

...

  1. Add

...

  1. Constant

...

  1. into workflow and set it's value to "true" (double click

...

  1. Constant

...

  1. and enter "true")

...

  1. Set

...

  1. Constant

...

  1. "firingCountLimit" to "1" (Right Click -> Configure Actor -> firingCountLimit Text Field)

...

  1. Add

...

  1. Relation

...

  1. next to the

...

  1. Constant

...


  1. Image Added
  2. Connect Relation and Constant::output

...

...

  1. Add

...

  1. Parameter

...

  1. and rename it to "a" (Right click -> Customize name)

...

  1. Set value of

...

  1. a

...

  1. to "1" (double click

...

  1. a

...

  1. )

...

  1. Add

...

  1. Parameter

...

  1. and rename it to "b" (Right click -> Customize name)

...

  1. Set value of

...

  1. b

...

  1. to "2" (double click

...

  1. b

...

  1. )

...

  1. Add

...

  1. Constant

...

  1. into workflow and rename it to "Send a to output"

...

  1. Set

...

  1. Send a to output

...

  1. value to "a"

...

  1. Add

...

  1. Constant

...

  1. into workflow and rename it "Send b to output"

...

  1. Set *Send b to output" value to "b"

...

  1. Connect

...

  1. Send a to output::trigger" with *Relation

...

...

  1. Connect

...

  1. Send b to output::trigger" with *Relation

...

...

  1. Add

...

  1. Relation

...

  1. to workflow and connect it with

...

  1. Send a to output

...

...

  1. Add

...

  1. Relation

...

  1. to workflow and connect it with

...

  1. Send b to output

...

...

  1. Add

...

  1. Display

...

  1. to workflow and connect relation connected to

...

  1. Send a to output

...

...

  1. Set

...

  1. Display

...

  1. "Display name" (Right click -> Customize Name) to "Value a"

...

  1. Add

...

  1. Display

...

  1. to workflow and connect it with other relation

...

  1. Set

...

  1. Display

...

  1. "Display name" (Right click -> Customize Name) to "Value b"

...

  1. Add

...

  1. Expression

...

  1. to the workflow

...

  1. Add input port

...

  1. input_a

...

  1. to the

...

  1. Expression

...

  1. (Right click -> Configure Ports -> Add, select checkbox "in")

...

  1. Add input port

...

  1. input_b

...

  1. to the

...

  1. Expression

...

  1. (Right click -> Configure Ports -> Add, select checkbox "in")

...

  1. Connect

...

  1. Expression::input_a

...

  1. with relation bound to

...

  1. Send a to output

...

...

  1. Connect

...

  1. Expression::input_b

...

  1. with relation bound to

...

  1. Send b to output

...

...

  1. Add

...

  1. Display

...

  1. to the workflow and set it's "Display name" to "Result"

...

  1. Connect

...

  1. Result::input

...

  1. with *Expression::output"

...

  1. Set

...

  1. Expression

...

  1. value to "a+b" (Double click

...

  1. Expression

...

  1. )
    At this point your workflow should be similar to the one below

...

  1. Intermediate results

...

  1. Image Added

  2. Execute workflow

...

  1. Image Added
    Simple modification in order to make Kepler workflow fail

...

  1. Set

...

  1. Expression

...

  1. value to "a/b"

...

  1. Set

...

  1. b

...

  1. value to "0"

...

...

2.3 If-else workflow

...

2.2.1 Using existing "if-else" workflow

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to use different paths for data flow

...

  • know how to split workflow execution path

...

  • know how to use

...

  • Boolean Switch

...

  • actor

...

Panel

...

...

title

...

Exercise no. 5 (approx. 10 minutes)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=rr03bekyiDU

In this exercise you will execute simple Kepler workflow. In order to this follow the instructions:

...

  1. If Kepler is not already running start it by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh

...

  1. 
    

...

  1. Open "If-else" workflow by issuing: File

...

  1. -> Open and navigate to:

...

  1. Code Block

...

  1. $HOME/tutorial/workflow/basic/if_else_simple.xml

...

...

  1. After workflow is opened, press "Play" button

...

  1. Image Added
    workflow should generate output within Display actor

...

...

2.2.2 Building "if-else" from the scratch

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*
borderStyledashed
  • know how to use different paths for data flow

...

  • know how to split workflow execution path

...

  • know how to use

...

  • Boolean Switch

...

  • actor

...

Panel

...

...

title

...

Exercise no. 6 (approx. 20 minutes)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=3M7IFyzSTAY

In this exercise you will build "if-else" workflow.

...

Info

...

title

...

You should complete previous examples before starting this one

...

In this example it is assumed that you already know how to use actor/director browser (left panel) and how to put actors into workflow (right panel)

...

...

  1. If Kepler is not already running start it by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh

...

  1. 
    

...

  1. Drag and Drop "DDF Director" into workflow

...

  1. Drag and Drop "String Constant" actor into workflow

...

  1. Change it's name to "String Hello" (Right-click

...

  1. -> Custimize name)

...

  1. Change it's value to "Hello world will test if-else" (Right-click

...

  1. -> Configure Actor

...

  1. -> value)

...

  1. Change it's firingCountLimit to "1" (Right-click

...

  1. -> Configure Actor

...

  1. -> firingCountLimit)

...

  1. Drag and Drop "Parameter" actor into workflow

...

  1. Change it's name to "a" (Right-click

...

  1. -> Customize name)

...

  1. Change it's value to "1" (Double click

...

  1. -> value)

...

  1. Drag and Drop "Parameter" actor into workflow

...

  1. Change it's name to "b" (Right-click

...

  1. -> Customize name)

...

  1. Change it's value to "2" (Double click

...

  1. -> value)

...

  1. Drag and Drop "Boolean Switch" actor into workflow

...

  1. Drag and Drop "Display" actor into workflow next to "Boolean Switch" actor

...

  1. Change it's name to "Display if"

...

  1. Drag and Drop "Display" actor into workflow below "Display if" actor

...

  1. Change it's name to "Display else"

...

  1. Drag and Drop "Constant" actor into workflow below "Boolean Switch" actor

...

  1. Change it's value to "a < b" (Right-click

...

  1. -> Configure Actor

...

  1. -> value)

...

  1. Change it's firingCountLimit to "1" (Right-click

...

  1. -> Configure Actor

...

  1. -> firingCountLimit)

...

  1. After all actors are at the workflow's area, you have to connect them

...

  1. Connect

...

  1. Boolean Switch::trueOutput

...

  1. with

...

  1. Display if::input

...

...

  1. Connect

...

  1. Boolean Switch::falseOutput

...

  1. with

...

  1. Display else::input

...

...

  1. Connect

...

  1. Boolean Switch::input

...

  1. with

...

  1. String Hello::output

...

...

  1. Connect

...

  1. Boolean Switch::control

...

  1. with

...

  1. Constant::output

...


  1. At this point your workflow should be similar to the one below

...

  1. Intermediate results

...

  1. Image Added

  2. Press "Play" button

...

  1. Image Added
    workflow should generate output within "Display else" actor

...

  1. Change value of

...

  1. Constant

...

  1. to "a > b" and execute workflow once again

...

  1. Save the workflow (e.g. as ~/my_workflow.xml) - we will need it in next excersise

...

...

2.2.2 Building "if-else-expression" from the scratch

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to use different paths for data flow

...

  • know how to split workflow execution path

...

  • know how to use

...

  • Boolean Switch

...

  • actor

...

  • know how to use

...

  • Expression

...

...

  • know how to use data flowing within workflow

...

Panel

...

...

title

...

Exercise no. 7 (approx. 20 minutes)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=qC6eVPXW4Fs

In this exercise you will build "if-else-expression" workflow.

...

Info

...

title

...

You should complete previous examples before starting this one

...

In this example it is assumed that you already know how to use actor/director browser (left panel) and how to put actors into workflow (right panel)

...

...

  1. If Kepler is not already running start it by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh

...

  1. 
    

...

  1. Load workflow that you have previously saved (~/my_workflow.xml) or open workflow at following location:

...

  1. Code Block

...

  1. $HOME/tutorial/workflow/basic/if_else_simple.xml
    

...

  1. Remove

...

  1. link

...

  1. between

...

  1. Display if

...

  1. and

...

  1. Boolean Switch

...

  1. (select link and press "Delete" or choose

...

  1. Edit -> Delete

...

  1. )

...

  1. Remove

...

  1. link

...

  1. between

...

  1. Display else

...

  1. and

...

  1. Boolean Switch

...

...

  1. Add

...

  1. Expression

...

  1. between

...

  1. Display if

...

  1. and

...

  1. Boolean Switch

...

...

  1. Set

...

  1. Expression

...

  1. Display name to "Expression if"

...

  1. Add input port

...

  1. in

...

  1. into

...

  1. Expression if

...

...

  1. Set

...

  1. Expression if

...

  1. value to

...

  1. Code Block

...

  1. in + " - this was added by Expression if"

...

  1. remember to copy " as well!

...

  1. Connect

...

  1. Expression if::in

...

  1. with

...

  1. Boolean Switch::trueOutput

...

...

  1. Connect

...

  1. Expression if::output

...

  1. with

...

  1. Display if::input

...

...

  1. Add

...

  1. Expression

...

  1. between

...

  1. Display else

...

  1. and

...

  1. Boolean Switch

...

...

  1. Set

...

  1. Expression

...

  1. Display name to "Expression else"

...

  1. Add input port

...

  1. in

...

  1. into

...

  1. Expression else

...

...

  1. Set

...

  1. Expression else

...

  1. value to

...

  1. Code Block

...

  1. in + " - this was added by Expression else"

...

  1. remember to copy " as well!

...

  1. Connect

...

  1. Expression else::in

...

  1. with

...

  1. Boolean Switch::falseOutput

...

...

  1. Connect

...

  1. Expression else::output

...

  1. with

...

  1. Display else::input

...

...

  1. At this point your workflow should be similar to the one below

...

  1. Intermediate results

...

  1. Image Added

  2. press "Play" button

...

  1. Image Added
    workflow should generate output within "Display if" actor

...

  1. Change value of

...

  1. Constant

...

  1. to "a < b" and execute workflow once again

...

...

3 Loops within Kepler

In this section of tutorial we will go through basic concepts of looping within Kepler. We will execute simple loop, build it from the scratch and, at the end, we will go through more complex examples of loops.h4.

3.1 Executing simple loop example (classic)

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to build simple loops
  • know how to use SampleDelay actor

...

  • know how to create loop condition checks

...

  • know difference between SDF and DDF Directors

...

Panel

...

...

title

...

Exercise no. 8 (approx. 15 minutes)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=fJlV7Jd30cQ

In this exercise you will execute simple loop example. In order to this follow the instructions:

...

  1. If Kepler is not already running start it by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh

...

  1. 
    

...

  1. Open workflow

...

  1. Code Block

...

  1. $HOME/tutorial/workflow/basic/simple_loop.xml
    

...

  1. You should see following workflow loaded into Kepler

...

  1. Image Added

  2. After workflow is loaded, execute it

...

  1. Image Added
    workflow should generate output within Display actor

...

  1. You can change

...

  1. Constant

...

  1. values and see what happens after you start workflow again

...

...

3.2 Executing simple loop example (using relation instead of SampleDelay)

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to build simple loops

...

  • know how to create loop condition checks

...

Panel

...

...

title

...

Exercise no. 9 (approx. 15 minutes)

...

borderStyle

...

dashed

...

In this exercise you will execute simple loop example. In order to this follow the instructions:

...

  1. If Kepler is not already running start it by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh
    

...

  1. Open workflow

...

  1. Code Block

...

  1. $HOME/tutorial/workflow/basic/loops/simple_loop_relation.xml

...

  1. 
    

    You should see following workflow loaded into Kepler

...

  1. Image Added

  2. After workflow is loaded, execute it

...

  1. Image Added
    workflow should generate output within Display actor

...

  1. You can change

...

  1. Constant

...

  1. values and see what happens after you start workflow again

...

...

3.3 Executing simple loop example (using parameters and Variable Setter)

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to build simple loops

...

  • know how to use Variable Setter actor

...

  • know how to create loop condition checks

...

Panel

...

...

title

...

Exercise no. 10 (approx. 15 minutes)

...

borderStyle

...

dashed

...

In this exercise you will execute simple loop example. In order to this follow the instructions:

...

  1. If Kepler is not already running start it by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh
    

...

  1. Open workflow

...

  1. Code Block

...

  1. $HOME/tutorial/workflow/basic/loops/loop-variables.xml

...

  1. 
    

    You should see following workflow loaded into Kepler

...

  1. Image Added

  2. After workflow is loaded, execute it

...

  1. Image Added
    workflow should generate output within Display actor

...

  1. You can change

...

  1. Constant

...

  1. values and see what happens after you start workflow again

...

3.4 Executing simple loop example (without DDF Boolean Select actor)

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to build simple loops

...

  • know how to create loop condition checks

...

Panel

...

...

title

...

Exercise no. 11 (approx. 15 minutes)

...

borderStyle

...

dashed

...

In this exercise you will execute simple loop example. In order to this follow the instructions:

...

  1. If Kepler is not already running start it by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh

...

  1. 
    

...

  1. Open workflow

...

  1. Code Block

...

  1. $HOME/tutorial/workflow/basic/loops/loop-no-ddf-b-s.xml
    

...

  1. You should see following workflow loaded into Kepler

...

  1. Image Added

  2. After workflow is loaded, execute it

...

  1. Image Added
    workflow should generate output within Display actor

...

  1. You can change

...

  1. Constant

...

  1. values and see what happens after you start workflow again

...

3.5 Building simple loop from the scratch

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to build simple loops

...

  • know how to use SampleDelay actor

...

  • know how to create loop condition checks

...

  • know difference between DDF and SDF directors

...

Panel

...

...

title

...

Exercise no. 12 (approx. 30 minutes)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=oYdOYnK7WI4
In this exercise you will build simple loop. In order to this follow the instructions:

...

  1. Start Kepler application by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh

...

  1. 
    

...

  1. Add

...

  1. DDF director

...

  1. into workflow

...

  1. Add

...

  1. Constant

...

  1. into workflow, set it's value to

...

  1. 5

...

...

  1. Add

...

  1. DDF Boolean Select

...

  1. actor to the workflow

...

  1. Connect

...

  1. Constant::output

...

  1. with

...

  1. DDF Boolean Select::falseInput

...

...

  1. Add

...

  1. Relation

...

  1. next to

...

  1. DDF Boolean Select

...

...

  1. Connect

...

  1. Relation

...

  1. (we will call it

...

  1. Relation A

...

  1. ) with

...

  1. DDF Boolean Select::output

...

...

  1. Add

...

  1. Expression

...

  1. actor to the workflow (next to

...

  1. Relation A

...

  1. )

...

  1. Add input port

...

  1. in

...

  1. into

...

  1. Expression

...

...

  1. Connect

...

  1. Relation A

...

  1. with

...

  1. Expression::in

...

...

  1. Set

...

  1. Expression

...

  1. value to

...

  1. Code Block

...

  1.  in > 0

...

  1.  

...

  1. Add

...

  1. Relation

...

  1. next to

...

  1. Expression

...

  1. (we will call it

...

  1. Relation B

...

  1. )

...

  1. Connect

...

  1. Expression::output

...

  1. with

...

  1. Relation B

...

...

  1. Intermediate result

...

  1. Image Added

  2. Add SampleDelay actor to workflow

...

  1. Change

...

  1. SampleDelay::input

...

  1. port direction to

...

  1. EAST

...

  1. (Right click -> Configure Ports -> Direction)

...

  1. Change

...

  1. SampleDelay::output

...

  1. port direction to

...

  1. WEST

...

  1. (Right click -> Configure Ports -> Direction)

...

  1. Connect

...

  1. SampleDelay::output

...

  1. with

...

  1. DDF Boolean Select::control

...

...

  1. Connect

...

  1. SampleDelay::input

...

  1. with

...

  1. Relation B

...

...

  1. Set

...

  1. SampleDelay

...

  1. value to

...

  1. Code Block

...

  1.  {false}

...

  1.  

...

  1. Add

...

  1. Boolean Switch

...

  1. next to

...

  1. Relation B

...

...

  1. Connect

...

  1. Boolean Switch::control

...

  1. with

...

  1. Relation B

...

...

  1. Connect

...

  1. Boolean Switch::input

...

  1. with

...

  1. Relation A

...

...

  1. Intermediate result

...

  1. Image Added

  2. Add Expression into workflow and set it's name to

...

  1. Decrease counter

...

...

  1. Add input port

...

  1. in

...

  1. into

...

  1. Decrease counter

...

  1. and set it's Direction to

...

  1. EAST

...

...

  1. Set output port Direction to

...

  1. WEST

...

...

  1. Set

...

  1. Expression

...

  1. value to

...

  1. Code Block

...

  1.  in - 1

...

  1.  

...

  1. Connect

...

  1. Decrease counter::output

...

  1. with

...

  1. DDF Boolean Select::trueInput

...

...

  1. Connect

...

  1. Decrease counter::input

...

  1. with

...

  1. Boolean Select::trueOutput

...

...

  1. Add

...

  1. Is Present

...

  1. next to

...

  1. Boolean Switch

...

...

  1. Connect

...

  1. Is Present::input

...

  1. with

...

  1. Boolean Switch::falseOutput

...

...

  1. Add

...

  1. Stop

...

  1. next to

...

  1. Is Present

...

...

  1. Connect

...

  1. Stop::input

...

  1. with

...

  1. Is Present::output

...

...

  1. Add

...

  1. Display

...

  1. next to

...

  1. Relation A

...

...

  1. Connect

...

  1. Display::input

...

  1. with

...

  1. Relation A

...

...

  1. Intermediate result

...

  1. Image Added

  2. After workflow is opened, press "Play" button

...

  1. Image Added
  2. You can change

...

  1. Constant

...

  1. values and see what happens next time you start workflow

...

...

3.6 Executing advanced loop workflow (Composite loop + Repeat)

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to utilize loop concept

...

  • know how to build advanced loop workflows

...

  • know how to use

...

  • Repeat

...

  • actor

...

  • know how to set value of the parameter

...

Panel

...

...

title

...

Exercise no. 13 (approx. 15 minutes)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=muhBH7jM5dU
In this exercise you will execute advanced loop workflow. In order to this follow the instructions:

...

  1. Start Kepler application by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh

...

  1. 
    

...

  1. Open workflow

...

  1. Code Block

...

  1. $HOME/tutorial/workflow/basic/array_loop_copy_files.xml
    

...

  1. After workflow is loaded

...

  1. Image Added
    You can open composite actor by right clicking it and choosing "Open"

...

  1. Image Added
  2. You can start workflow by pressing Play button

...

  1. Image Added
    workflow should copy input files from/to

...

  1. Code Block

...

  1. $HOME/tutorial/data -> $HOME/tutorial/output
    

...

  1. You can open terminal and verify it's execution results

...

  1. Code Block

...

  1. ls -la ~/tutorial/data

...

  1. 
    ls -la ~/tutorial/output

...

  1. 
    

...

3.7 Executing advanced loop workflow (Composite loop + feedback)

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to utilize loop concept

...

  • know how to build advanced loop workflows

...

  • know how to use

...

  • Repeat

...

  • actor

...

  • know how to set value of the parameter

...

Panel

...

...

title

...

Exercise no. 14 (approx. 15 minutes)

...

borderStyle

...

dashed

...

Film available: http://www.youtube.com/watch?v=4xjLcI776vg
In this exercise you will execute advanced loop workflow with feedback. In order to this follow the instructions:

...

  1. Start Kepler application by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh

...

  1. 
    

...

  1. Open workflow

...

  1. Code Block

...

  1. $HOME/tutorial/workflow/basic/array_loop_composite_repeat_feedback.xml
    

...

  1. After workflow is loaded

...

  1. Image Added
    open composite actor by right clicking it and choosing "Open"

...

  1. Image Added
  2. You can execute it by pressing Play button

...

  1. Image Added
    workflow should generate output within Display actor

...

Info
title
Animating workflows

...

In Kepler it is possible to animate workflows during execution. In order to animate workflow you have to turn on animations. You can do this by choosing:

...

Tools

...

-> Animate at Runtime...

...


Demo movie for this feature can be found at following location:

...

animation

...

...

3.7 Creating a loop using PythonScript actor

...

Panel
borderColor#ccc
bgColor#99CCFF
titleColor#ffffff
titleBGColor#81a4ca
title*After this exercise you will:*

...

borderStyle

...

dashed
  • know how to use Python script inside a Kepler actor

...

  • know how to create a generic loop using PythonScript actor

...

Panel

...

...

title

...

Exercise no. 15 (approx. 15 minutes)

...

borderStyle

...

dashed

...

In this exercise you will create a simple loop in Python and put it inside a special Kepler actor. Steps below describe the process of workflow creation from scratch. If you wish to see a final solution, please open the workflow

...

$HOME/tutorial/workflow/basic/python/python_script.xml

...

...

  1. Start Kepler application by issuing:

...

  1. Code Block

...

  1. cd ~/kepler

...

  1. 
    ./kepler.sh

...

  1. 
    

...

  1. Instantiate a PythonScript actor by choosing menu

...

  1. Tools -> Instantiate Component

...

  1. and setting as

...

  1. Class name

...

  1. a value

...

  1. ptolemy.actor.lib.python.PythonScript

...

  1. .

...

  1. This actor starts with zero ports. They need to be added manually. Please right-click on PythonScript and choose

...

  1. Configure Ports

...

  1. .

...

  1. Add an input port named

...

  1. in

...

  1. and output port named

...

  1. out

...

  1. .

...

  1. Note

...

  1. Kepler's automatic type resolver may not correctly infer types of PythonScript ports due to dynamic features of Python programming language. This may lead to errors and unexpected behaviour. Thus you need to specify these types explicitly. For this tutorial, please set type of

...

  1. in

...

  1. to

...

  1. int

...

  1. and type of

...

  1. out

...

  1. to

...

  1. arrayType(int)

...

  1. .

...

...

  1. By default Kepler initialises the

...

  1. script

...

  1. parameter of this actor to be of type

...

  1. Line

...

  1. . To develop a script in Python, it needs to be changed. Please right-click on PythonScript and choose

...

  1. Configure Actor

...

  1. . Go to

...

  1. Preferences

...

  1. and select

...

  1. expert mode

...

  1. .

...

  1. Close the window with actor's preferences and once again start with right-clicking and choosing

...

  1. Configure Actor

...

  1. . Again choose

...

  1. Preferences

...

  1. and change type of

...

  1. script

...

  1. parameter to

...

  1. Text

...

  1. .

...

  1. Now you can see a Python code displayed in several lines. Some remarks here:

    ...

      1. Python is a dynamic language, so no typecasting takes place,

    ...

      1. Do not declare any constructor.

    ...

      1. You only need to fill the fire() method.

    ...

      1. You can assume that the configured ports are already instantiated (ie. you can use names

    ...

      1. in

    ...

      1. and

    ...

      1. out

    ...

      1. to work with actor's ports)

    ...

    1. Let's assume a following problem to solve. The actor receives a number which will be interpreted as iteration count. In each

    ...

    1. i-th

    ...

    1. iteration, the actor will output

    ...

    1. i

    ...

    1. 2

    ...

    1. . Example:

    ...

    1. in

    ...

    1. = 4,

    ...

    1. out

    ...

    1. =

    ...

    1. {0, 1, 4, 9

    ...

    1. }.

    ...

    1. In Python, the following script will do this:

    ...

    1. Code Block

    ...

    1. import ptolemy.data

    ...

    1. 
      
      class Main:

    ...

    1. 
          def fire(self):

    ...

    1. 
              # read value of input token
              val = self.in.get(0).intValue()

    ...

    1. 
              arr = []
              for i in range(val):

    ...

    1. 
                  # create a new IntToken with each value
                  arr.append(ptolemy.data.IntToken(i**2))

    ...

    1. 
              # send an ArrayToken with array of values
              self.out.send(0, ptolemy.data.ArrayToken(arr))

    ...

    1. 
              return
      
    2. You can now instantiate Constant actor. Set its

    ...

    1. firingCountLimit

    ...

    1. to 1 and

    ...

    1. value

    ...

    1. to 4. Connect it with

    ...

    1. in

    ...

    1. port of PythonScript.

    ...

    1. Instantiate also a Display actor and connect PythonScript's

    ...

    1. out

    ...

    1. with it.

    ...

    1. Finally add an SDF actor and execute the workflow.

    ...

    1. Image Added
    2. You will see

    ...

    1. {0, 1, 4, 9

    ...

    1. }. Now you can change the input value 4 to some other one. Or you can change the actor source code to execute a different task.

    ...

    3.8 Creating a time-loop with series plotting

    ...

    Panel
    borderColor#ccc
    bgColor#99CCFF
    titleColor#ffffff
    titleBGColor#81a4ca
    title*After this exercise you will:*

    ...

    borderStyle

    ...

    dashed
    • know how to provide data from the loop to the plotting actor

    ...

    Panel

    ...

    ...

    title

    ...

    Exercise no. 16 (approx. 15 minutes)

    ...

    borderStyle

    ...

    dashed

    ...

    In this exercise you will create a simple loop containing some potentially time-consuming operations which will be plotted live. Steps below describe the process of workflow creation from scratch. If you wish to see a final solution, please open the workflow

    ...

    $HOME/tutorial/workflow/basic/python/xyplotter.xml

    ...

    ...

    1. Start Kepler application by issuing:

    ...

    1. Code Block

    ...

    1. cd ~/kepler

    ...

    1. 
      ./kepler.sh

    ...

    1. 
      

    ...

    1. Put DDF Director.

    ...

    1. Put Constant actor and set its

    ...

    1. firingCountLimit

    ...

    1. to

    ...

    1. 1

    ...

    1. . This will be the starting source for the example workflow.

    ...

    1. Put a relation symbol (Ctrl+click) next to the Constant and link them.

    ...

    1. Put an Expression actor and add an input port named

    ...

    1. in

    ...

    1. . Let's set the expression to

    ...

    1. in

    ...

    1. * in

    ...

    1. which indicates that we will plot the square function. Then connect the relation with

    ...

    1. in

    ...

    1. port.

    ...

    1. Put an XYPlotter actor and connect its

    ...

    1. inputX

    ...

    1. with the relation symbol and

    ...

    1. inputY

    ...

    1. with Expression actor's output port.

    ...

    1. Your workflow should look like the one presented below. It applies some function to input data and plots it. However, it works for a single value now. We need to create a loop.

    ...

    1. Image Added
    2. Put another Expression actor. Add an input port named

    ...

    1. in

    ...

    1. , set expression to

    ...

    1. in + 1

    ...

    1. and connect the input port with relation. This is responsible for the step of loop.

    ...

    1. Create another relation symbol next to this Expression actor and connect them.

    ...

    1. Put next Expression actor. Again add an input port named

    ...

    1. in

    ...

    1. , set expression to

    ...

    1. in < 10

    ...

    1. and connect the input port with the just created relation. This is responsible for loop termination when it reaches specific point.

    ...

    1. Put Boolean Switch actor, connect its

    ...

    1. input

    ...

    1. port to the

    ...

    1. in + 1

    ...

    1. expression and its

    ...

    1. control

    ...

    1. port to the

    ...

    1. in < 10

    ...

    1. expression.

    ...

    1. Now we want to simulate the time-consuming behaviour, so we are going to add an artificial sleep time. To do this, you need to choose from menu

    ...

    1. Tools -> Instantiate Component

    ...

    1. and set as

    ...

    1. Class name

    ...

    1. a value

    ...

    1. ptolemy.actor.lib.Sleep

    ...

    1. . A new Sleep actor will appear. It's purpose is to grab some input, wait for the specified amount of time and then send the data. For this workflow, please set its

    ...

    1. sleepTime

    ...

    1. to 1000 (the unit here is milliseconds, so we will simulate one second of time-consuming operations).

    ...

    1. Connect Boolean Switch

    ...

    1. trueOutput

    ...

    1. port with Sleep's

    ...

    1. input

    ...

    1. , and Sleep's

    ...

    1. output

    ...

    1. to the relation symbol at the beginning of the loop. Your workflow should look like the one below. You can run it and you will see that the output is plotted live and updated every second (ie. every time it receives new data).

    ...

    1. Image Added