Sample Project

From Legion
Jump to: navigation, search
Language: English  • Español

As an example project we are going to consider the case of a Distributed Definite Integration project. The general idea is to compute an integral dividing the integration range in many work units. As is well known, the result of the computation would be equal to the sum of the work unit's results. Through this example we are going to show the main features of Legion WS and Legion WI for easily setting up a project and allowing users to send, monitor and retrieve tasks. For an explanation about what a project is in Legion check this.


Contents

Step 1

Step1 pwt.png

Step 2 - Form Specification

Create two sections:

Step2 section setup.png

Now create a textbox for the function to integrate.

Step2 txtFx.png

Now create a textbox for the lower bound.

Step2 txtStart.png

Now create a textbox for the upper bound.

Step2 txtStop.png

Now create a textbox for the step - this will be used to break down the task in workunits: (txtStop - txtStart) / txtStep

Step2 txtStep.png

Now create a textbox for the precision.

Step2 txtPrecision.png

Add the components to theirs sections using the select, and this is how it is supposed to be when finished.

Step2 finish.png

After clicking OK you should get the following xml result. You could load the editor again and it will load the XML for further editing.

Step2 pwt.png

You could copy and paste the following XML in the textarea.


 %config%<form>
   <section name="Integral parameters" open="true">
     <textbox>
       <name>txtFx</name>
       <description>f(x)</description>
       <info>Function to integrate</info>
       <validations>
       </validations>
     </textbox>
     <textbox>
       <name>txtStart</name>
       <description>Lower Limit</description>
       <info>Must be an integer</info>
       <validations>
         <integervalidation>
         </integervalidation>
       </validations>
     </textbox>
     <textbox>
       <name>txtStop</name>
       <description>Upper Limit</description>
       <info>Must be an integer</info>
       <validations>
         <integervalidation>
         </integervalidation>
       </validations>
     </textbox>
     <textbox>
       <name>txtStep</name>
       <description>Step</description>
       <info>Must be an integer</info>
       <validations>
         <integervalidation>
           <minValue>0</minValue>
         </integervalidation>
       </validations>
     </textbox>
   </section>
   <section name="Precision" open="false">
     <textbox>
       <name>txtPrecision</name>
       <description>Precision</description>
       <info>Choose a value like 0.001</info>
       <default>0.001</default>
       <validations>
         <floatvalidation>
           <minValue>0</minValue>
           <maxValue>1</maxValue>
         </floatvalidation>
       </validations>
     </textbox>
   </section>
 </form>


And this is how the rendered form will look like:


Step2 rendered form.png

Step 3

Add users to the project.

Step3 n.png

Step 4

Set up and test the credentials for Legion Web Services Layer.

Step4 n.png

Step 5 - Config.xml Template

As far we've got the Executable File and the Task Submission Form. Now we must supply the Config.xml Template (more details about syntax info). This file is the going to be the task creation specification when interpreted after task submission. For this, we are going to take advantage of the Template Interpreter and the process tag for loops features.

 <task>
   <name>{Form:txtName}</name>
   <desc>{Form:txtDescription}</desc>
   <exec_file>
     <name>integrador</name>
     <cmd>"{Form:txtFx}" {x} {Form:txtStep} {Form:txtPrecision}</cmd>
     <compress>{Project:compress}</compress>
     <extern/>	
     <process>
       <tag>x</tag>
       <start>{Form:txtStart}</start>
       <stop>{Form:txtStop}</stop>
       <step>{Form:txtStep}</step>
     </process>
   </exec_file>
   <out_file>
     <type>cat</type>
     <name>result.txt</name>
   </out_file>
 </task>

This Task Descriptor File basically says that:

  • We are going to create a task with the name and description taken from the correspondent form parameters.
  • The first file uploaded for exec file will be renamed as "integrador".
  • A command line will be created for each workunit: Form values are fixed, but the {x} tag (which is replaced at each workunit generation in Legion Web Services) will take values: txtStart, txtStart + txtStep, txtStart + 2*txtStep ... txtStop.
  • After execution we must retrieve the file named result.txt and we are going to concatenate them all (this is done with the <type>cat</type> ).


Step5 pwt.png


We also need to need to specify how many work units we expect to be created at each task submission as a formula. We should agree that this formula would be:

 {Math:({Form:txtStop}-{Form:txtStart})/{Form:txtStep}}

Step 6 - Files upload

Here we will upload a single executable file that is capable of performing the computation of any definite integral.

Execution example

 integrator "{function}" {begin} {how many units from begin} {precision - 0.01 for instance}
 integrator "sin(x)^2" 5 10 0.01 - will perform the integral of sin(x)^2 between 5 and 15 (which is equal to 5 + 10) and use 0.01 width
                                   rectangles to approximate the integral along the range.

This program will write the output to a text file with name result.txt (This name will be used for the 4th step).

Monitoring page

You will get this page that enable task monitoring, sharing and result retrieval.

%height=400px% Attach:legion_monitoring_page.png

Personal tools
Namespaces

Variants
Views
Actions
Navigation
Legion Web Interface
Legion Web Service
Installation guide
Centralized BOINC Server Management
navigation end