Using query command

The ecflow_client command --query can be used to determine the current value of several characteristics (e.g. node state, node default state, event, meter, variable, trigger). The same capability is provided by the Python API.

The general format of the ecflow_client command --query is as follows:

Listing 47 query command
ecflow_client --query arg1 arg2 arg3

Where:

  • arg1 = [ state | event | meter | label | variable | trigger | limit | limit_max | … ]

  • arg2 = <path> | <path>:name where name is name of a event, meter,limit or variable

  • arg3 = trigger expression (optional) | prev | next # prev,next only used when arg1 is repeat

Some examples using the query command:

# return node state
state=$(ecflow_client --query state /path/to/node)

# state that can includes suspended
dstate=$(ecflow_client --query dstate /path/to/node)

# return the current value as a string
value=$(ecflow_client --query repeat /path/to/node )

# return the previous value as a string, does not modify real repeat
value=$(ecflow_client --query repeat /path/to/node   prev )

# return the next value as a string, does not modify real repeat
value=$(ecflow_client --query repeat /path/to/node   next)

# return set | clear to standard out
event=$(ecflow_client --query event /path/to/task/with/event:event_name)

# returns the current value of the meter
meter=$(ecflow_client --query meter /path/to/task/with/meter:meter_name)

# returns the variable value
value=$(ecflow_client --query variable /path/to/task/with/var:var_name)

# returns the current value of the limit
limit_value=$(ecflow_client --query limit  /path/to/task/with/limit:limit_name)

# returns the max value of the limit
limit_max=$(ecflow_client --query limit_max /path/to/task/with/limit:limit_name)

# returns the current value of the label
label_value=$(ecflow_client --query label %ECF_NAME%:label_name)

# return true if expression evaluates false otherwise
value=$(ecflow_client --query trigger /path/to/node/with/trigger \"/suite/task == complete\")

Update Task Script

Create a task script for a new task named query, as follows:

Listing 48 $HOME/course/f1/query.ecf
%include <head.h>

meter=$(ecflow_client --query meter /test/f1/t1:progress)
while [[ $meter -lt 100 ]]
do
    sleep 2
    meter=$(ecflow_client --query meter /test/f1/t1:progress)
    eventa=$(ecflow_client --query event /test/f1/t2:a)
    eventb=$(ecflow_client --query event /test/f1/t2:b)
    t5_state=$(ecflow_client --query state /test/f1/t5)
    ecflow_client --label=query "meter($meter) eventa($eventa) eventb($eventb) t5_state($t5_state)"
done

%include <tail.h>

Update Suite Definition

Modify the suite definition to add a new task query to the family f1 as follows:

# Definition of the suite test.
suite test
    edit ECF_INCLUDE "{{HOME}}/course" # replace '{{HOME}}' appropriately
    edit ECF_HOME    "{{HOME}}/course"
    family f1
        edit SLEEP 20

        [... previously defined tasks omitted ...]

        task query
            label query ""
    endfamily
endsuite

What to do

  1. Add the new task script query.ecf, as shown above.

  2. Modify suite definition to add a new task query to the family f1, as shown above.

  3. Replace the suite, using:

    ecflow_client --suspend /test
    ecflow_client --replace /test test.def
    
  4. Observe the tasks in ecflow_ui

  5. Modify the task script to query variable SLEEP, and add this variable to the query label.

Note

Although a variable can be made accessible in the script by using %VAR%, using the query command allows to dynamically access the current value or a value from a different server.