-- TirilRoedland - 11-Aug-2010

DIANE Dashboard updates

Task-specific information

One of the new functions of DIANE Dashboard is the possibility to add multiple arguments to each individual task under your run, to easier separate them. There is also an application label that is possible to set, to make things easier if only one argument is needed.

How to format the variables

This part goes through how to add the information correctly formatted to some variables. These temporary variables will be added to the task in a later section, so keep reading.

The application label

The application label is simply a string, that can be set like this:

application_label = "My label"

It is of course a bonus if the application label is unique for each task. Depending on your tasks, you might want to extract some information to add to your label, making it look more like this:

application_label = "Task number " + str(i)

No matter how you choose to add your information, make sure the application label is a string.

The task arguments

The task arguments are a bit trickier. This is a list of tuples, where each tuple consists of two values.

The first value is a string which will create the heading in the table. So make sure it is in a pretty format, capitalized and grammatically correct.

The second value is the value of the parameter. This can be either a string, an integer or a float. The type given here will decide how it is saved in the database.

Just to show, you can add the information directly like this:

task_arguments = []
task_arguments.append(('Particle', 'e-'))
task_arguments.append(('Energy [GeV]', 7500))
task_arguments.append(('B field [T]', 4.0))

But since it generally is a bad idea to hard code values like that, you should come up with a way to do this more modularly. Assuming you for each task have a dictionary with the task-specific information, you can for example do something like this:

task_arguments = []
task_arguments.append(('Particle', taskinfo['particle']))
task_arguments.append(('Energy [GeV]', taskinfo['energy']))
task_arguments.append(('B field [T]', taskinfo['bfield']))

Precisely how you get the task-specific information is your choice and problem, but make sure that the information added is either a string, integer of float.

How to add the information

There are two possible ways to set these parameters, depending on how you specify your run.

Own application manager

For larger projects, a specialized application manager is not uncommon. This specialized application manager should be a subclass of the SimpleApplicationManager.

Somewhere in its initialize method, all the tasks will be iterated over, and created using self._task(). Both the application label and the task arguments are added in this self._task():

self._task(application_label=application_label, task_arguments=task_arguments)

Of course, not both the application_label and the task_arguments need to be in use. You can use none, one or both. But remember to initialize the variables used, as seen above.

Directly in the runfile

Smaller projects might want to specify the tasks directly in the runfile. This is for example done in the DIANE tutorial application, the hello.run. In that case, the application label and the task arguments are specified directly there (note the last three lines):

# tell DIANE that we are just running executables
# the ExecutableApplication module is a standard DIANE test application

from diane_test_applications import ExecutableApplication as application

# the run function is called when the master is started
# input.data stands for run parameters
def run ( input, config ) :
    d = input.data.task_defaults # this is just a convenience shortcut

    # all tasks will share the default parameters (unless set otherwise in individual task)
    d.input_files = ['hello']
    d.output_files = ['message.out']
    d.executable = 'hello'

    # here are tasks differing by arguments to the executable
    for i in range( 20 ):
        t = input.data.newTask()
        t.args = [str( i )]
        t.application_label = "hello %d"%i
        t.task_arguments.append(('Number',i))
        t.task_arguments.append(('Value',i+1))

Each task is specified using the

t = input.data.newTask()

This t task have the attributes t.application_label and t.task_arguments, a string and a list, respectively. These you can then update directly, or you can specify the information in temporary variables as seen in How to format the variables, and instead use:

    ...
    # here are tasks differing by arguments to the executable
    for i in range( 20 ):
        t = input.data.newTask()

        application_label = ...
        task_arguments = ...

        t.args = [str( i )]
        t.application_label = application_label
        t.task_arguments = task_arguments

Just make sure that the application_label is a string and the task_arguments is a list of two-valued tuples, starting with a string.

Navigating the dashboard

Edit | Attach | Watch | Print version | History: r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r3 - 2020-08-19 - TWikiAdminUser
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    Sandbox/SandboxArchive All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright &© 2008-2023 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback