1 / 34

WS-VLAM Tutorial: Part III (part2): Learn how to WS-VLAM PYTHON API

WS-VLAM Tutorial: Part III (part2): Learn how to WS-VLAM PYTHON API. Adam Belloum. Outline. Part I: Hands on the User Graphical Interface Part III: Port a Legacy application to WS-VLAM Part III: Learn how to use WS-VLAM API Notation (Title background): Generic step

squeen
Download Presentation

WS-VLAM Tutorial: Part III (part2): Learn how to WS-VLAM PYTHON API

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. WS-VLAM Tutorial: Part III (part2): Learn how to WS-VLAM PYTHON API Adam Belloum

  2. Outline • Part I: Hands on the User Graphical Interface • Part III: Port a Legacy application to WS-VLAM • Part III: Learn how to use WS-VLAM API • Notation (Title background): • Generic step • Tutorial specific step

  3. Outline (Part III): Learn how to use WS-VLAM API Step 1: Define an Interface for your component Step 2: Create a description for your component Step 3: Define the component dependencies Step 4: JAVA Tutorial (create a WSVLAM JAVA component) Step 6: C/C++ Tutorial (create a WSVLAM C/C++ component) Step 5: PYTHON Tutorial (create a WSVLAM PYTHON component) Step 6: Deploy the component/dependencies lib Step 7: Compose a workflow using the component Step 8: execute the workflow / monitor

  4. Step 1: Define the component interface • The Interface defines how WS-VLAM will interact with your components • Parameter Interface: is use to interact at runtime with your module • Port interface: is used to stage in/out the data consumed/produced by your module • Port in allows to stage in the consumed data • Port out allows to stage out the produced data

  5. The file reader “fileReader”opens a file specified as a URI using the parameter Interface “filename” and sends the content through an output port “port_out”. • fileReader support many protocols: GSIFTP, ftp, http, file Step 1: Example File Reader

  6. To create a description of your component: use CLAM workflow component configuration tool Step 2.1: Create a description • Action: • Click on CLAM Button in the WS-VLAM menubar

  7. CLAM workflow component configuration tool will allow you to define: name of the component, default host, ports, parameters, classification, category Step 2.2: Create a description • Action: • Enter the name of the component • Entre the name of the default host “fs2.das3.science.uva.nl”

  8. CLAM workflow component configuration tool allows you to define: name of the component, default host, ports, and parameters Step 2.3: Create a description • Action: • Click on ports tab • Click + to add new input or output port • Type the name of the ports exactly as you did it in config.xml

  9. To add a port a pop up window appears “Add input Port” or “Add output port” Step 2.4: Create a description • Action: • Type the name of the ports exactly as you did it in source code • Specify the type of the port either a simple data type, a file type, or Complex data type (see documentation for more details)

  10. Create a description of your component: use CLAM workflow component configuration tool Step 2.5: Create a description • Action: • Click on save to created the description file “component-name.xml”

  11. Create a description of your component: use CLAM workflow component configuration tool Step 2.6: Create a description • Action: • You will see in the filed file path the full path to the created

  12. Create a description of fileReader: use CLAM workflow component configuration tool • The FileReader has • One output: port-name = “port_out” and Type=“file” • One parameter parameter-name = “filename” and Type=“String” Step 2.7: Example File Reader • Action: • Perform the tasks described in step 2.1 to step 2.6 to create the fileReader.xml

  13. Step 3.1: Define the component dependencies • Dependencies are libraries & auxiliary software that are required by your component but are not available standard Operating systems • You have to list the name of these libraries & auxiliary software in a file called “dependencies” • Every libraries & auxiliary software listed in the dependencies files have to be packaged as a “pseudo-module”

  14. Step 3.2: Create a pseudo-module • A pseudo module is just a simple software package for which you need to create a profile.sh in the root directory • Using your favorite text editor created a file call profile.sh # ############ NOTE #################### # In the profile.sh export all the environment # variables needed to execute your package # # bash environment # # export VARIABLE_NAME=VARIABLE_VALUE # # Add your VARIABLES bellow the line ######################################

  15. Step 5.1: PYTHON API • From a developer’s point of view your components are applications that use a special library provided by the WS-VLAM framework: the “vlport” library

  16. Step 5.2: PYTHON modules (pre-requisite) • Before you build the wrapper make sure that the SWIG toolkit and Python are installed in your system. • The SWIG version should be higher then 1.3.19. • To compile the python wrapper • the environment variable VLAM_INSTALL must be set. • Just type ‘‘make dist‘‘. • You will find the library in dist/lib subdirectory. • The wrapper consists of an ”adapter” shared library with the name ” vlport.so” and a python module named ”vlport.py”.

  17. Step 5.3: Extend your PYTHON code • initialize • >>> Import vlport • create an instance of vlport application • >>>> vlapp=vlport.VLAppFactory.activate (["inputPort1","inputPort2"], ["outputPort1", "outputPort2"]) • get references to input and output ports • >>>inputPort1=vlapp.getInputPort("inputPort1") >>>outputPort1=vlapp.getOutputPort("outputPort1") • Note: should provide the same names for the ports as specified at the initialization stag

  18. Step 5.4: API for writing to an output port • writeInt (integer number) • writes an integer to the output port • writeDouble (decimal number) • writes a decimal number to the output port • writeString (String) • writes a string to the output port which accepts strings • Write (String) • write a raw data from String to the port without serialization

  19. Step 5.5: API for reading from in input port • readInt() • reads an integer number from the input port • readDouble() • reads a decimal number from the input • readString() • reads a string from input the port Write (String) • read([size]) • Read at most size bytes from the port (less if the read encounters EOF before obtaining size bytes)

  20. Step 5.6: API for reading/writing to/from parameter • getParameter ("paramName”) • Reads the value of “paramName” • setParameter ("paramName", "paramValue”) • Writes the value of “paramValue” to “ paramName”

  21. Step 5.5: Example of PYTHON component • The Example : shows the code for a module which open a file using “inputPort” and write is to the ”outputPort”. The name of the file is read through eh parameter interface • #include "vlapp.h" • #!/usr/bin/python • import vlport • vlapp=vlport.VLAppFactory.activate([“inpputPort], ["outputPort"]) • filename=vlapp.getParameter("fileName") • file=open(filename) • outputPort=vlapp.getOutputPort("outputPort") • fileDaata = file.read() • outputPort.write(fileData) =vlport.VLAppFactory.deactivate(vlapp)

  22. Step 6.1: Deploy your workflow component #!/bin/sh export PYTHONPATH=$VLAM_INSTALL/lib: \ $PYTHONPATH python $BASE_DIR/bin/fileReader $* • Create a file “main.sh”:

  23. Step 6.2: package your component Create a tar file of your component: (1) Created fileReader.tar $ tar cf fileReader.tar fileReader/ (1) Compress fileReader.tar $ gzip fileReader.tar • Create a directory with the fileReader name as the component • Copy the files you have created: • dependencies (step 3.1) • main.sh(step 6.1) • Copy any other files or directory related to your component: • bin/fileReader.py(step5.5) • lib/

  24. Step 6.3: Deploy your workflow component • # On a machine where both GT4 & WS-VLAM • # runtime system are installed • # Create in your HOME directory called “.wsvlam” • (1) copy fileReader..tar.gz to the default directory • $ mkdir .wsvlam • $ cd .wsvlam/ • $ mkdir modules • $ cd modules • #untar the component tar file you have created • # in step 4 • untar fileReader..tar.gz • $ tar –zxvf fileReader.tar.gz • Test mode: you can test your component • Perform the steps described in the blue box • Shared mode: you can share your module with other users: • by moving the tar file you have created in step 6.2 to a component repository

  25. In the component list window you will see the created FileREader components as well as other components Step 7.1: Compose a workflow fileReader • Action: • Click on the fileReader in the list and drag and drop in the composition panel

  26. An instance of fileReader will be instantiated Step 7.2: Compose a workflow using LA • Action: • Click on the fileReader in the list and drag and drop in the composition panel

  27. Instantiate the fileWriter component: • This component will move the file produced by fileReader to any remote location the user specifies Step 7.3: Compose a workflow using LA • Action: • Click on the WriterReader in the list and drag and drop in the composition panel

  28. Create a communication channel: • This component will move the file produced by FileReader to any remote location the user specifies Step 7.4: Compose a workflow using LA • Action: • Create a communication channel by dragging between an output port (read square) and input port (blue square)

  29. In the step you should check if all the default values of the parameters of the workflow components composing your workflow are set correctly Step 7.5: customize the composed workflow • Action: • Click on the fileReader in composition panel • In the property window select the parameter tab • Type in the URI to the file you want stage in FileReader support many protocols: GSIFTP, http, file, ftp

  30. In the step you should check if all the default values of the parameters of the workflow components composing your workflow are set correctly Step 7.6: customize the composed workflow • Action: • Click on the fileWriterin composition panel • In the property window select the parameter tab • Type in the URI to the file you want stage in fileWriter support many protocols: GSIFTP, http, file, ftp

  31. Input file: fileReader parameter • fs2.das2.science.uva.nl: Type in the following URI for parameter in each fileReader • gsiftp://fs2.das.3science.uva.nl/home2/<user-account>/<filename-you-want-to-cp> • output file: fileWriter parameter • fs0.das3.cs.vu.nl: Type in the following URI for parameter in each fileReader • gsiftp://fs0.das3.cs.vu.nl/home0/<user-account>/<filename-you-want-to-created> Step 7.8: customize the composed workflow

  32. Now you are ready to execute the omnimatch workflow, which automatically stage in the data file needed for the omnimatch application, and stage out the result files Step 8: execute the composed workflow • Action: • Click on the run button

  33. Some References • Science Z Zhao, A Belloum, M Bubak Editorial: Special section on workflow systems and applications in e-Future Generation Computer Systems 25 (5), 525-527 • A. Wibisono, D. Vasyunin, V. Korkhov, AS.Z. Belloum WS-VLAM: a GT4 based workflow management system , The 2nd International Workshop on Scientific Workflows, In conjunction with ICCS 2007, Beijing, China, 2007 • A.S.Z. Belloum, V. Korkhov, S. Koulouzis, M. A Inda, and M. BubakCollaborative e-Science experiments: from scientific workflow to knowledge sharing JULY/AUGUST, IEEE Internet Computing, 2011 • IlkayAltintas, Manish Kumar Anand, Daniel Crawl, Shawn Bowers, Adam Belloum, Paolo Missier, Bertram Ludascher, Carole A. Goble, Peter M.A. Sloot, Understanding Collaborative Studies Through Interoperable Workflow Provenance, IPAW2010, Troy, NY, USA

  34. Some References • A. Belloum, Z. Zhao, and M. Bubak Workflow systems and applications , Future Generation Comp. Syst. 25 (5): 525-527 (2009) •  Z. Zhao, A.S.Z. Belloum, et al., Distributed execution of aggregated multi domain workflows using an agent framework The 1st IEEE International Workshop on Scientific Workflows, Salt Lake City, U.SA, 2007 • Zhiming Zhao, Adam Belloum, Cees De Laat, Pieter Adriaans, Bob Hertzberger Using Jade agent framework to prototype an e-Science workflow bus Authors Cluster Computing and the Grid, 2007. CCGRID 2007

More Related