File: adding-a-label.rst

package info (click to toggle)
ecflow 5.15.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 51,868 kB
  • sloc: cpp: 269,341; python: 22,756; sh: 3,609; perl: 770; xml: 333; f90: 204; ansic: 141; makefile: 70
file content (90 lines) | stat: -rw-r--r-- 2,495 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
.. index::
   single: labels (tutorial)

.. _tutorial-labels:

Adding a label
==============

It is very useful to see :term:`task` specific information in the :term:`ecflow_ui`. This can be achieved by defining
a :term:`label`, i.e. a string that is attached to a :term:`task`, and that can be populates using the
:term:`child command` :term:`ecflow_client` :code:`--label`.

Update Task Script
------------------

To create a new family :code:`label` with a task :code:`t1`, start by creating the :term:`task script <ecf script>` at :file:`$HOME/course/test/label/t1.ecf`

.. code-block:: shell
   :caption: $HOME/course/test/label/t1.ecf

   %include <head.h>
   
   n=1
   while [[ $n -le 5 ]]                      # Loop 5 times
   do
      msg="The date is now $(date)"
      ecflow_client --label=info "$msg"      # Set the label
      sleep 30                               # Wait half a minute
      (( n = $n + 1 ))
   done
   
   ecflow_client --label=info "Job is done!" # Set the final label
   
   %include <tail.h>

Update Suite Definition
-----------------------

Update the suite definition file to add the new family :code:`label` and task :code:`t1`.

.. tabs::

    .. tab:: Text

        .. code-block:: shell

           suite test
             edit ECF_INCLUDE "{{HOME}}/course" # replace '$HOME' appropriately
             edit ECF_HOME    "{{HOME}}/course"

             [... previous families omitted for brevity ..]

             family label
               task t1
                 label info ""
             endfamily
           endsuite

    .. tab:: Python

        The following example shows how to add a :py:class:`ecflow.Label` in Python. (Note: **families f1 and f2 are omitted for brevity**).

        .. literalinclude:: src/labels.py
           :language: python
           :caption: $HOME/course/test.py

**What to do**

#. Create the new :term:`task script <ecf script>` file, as shown above.
#. Modify the suite definition to include the new family and task, as shown above.
#. Replace the :term:`suite`, using:

   .. tabs::

      .. tab:: Text

         .. code-block:: shell

            ecflow_client --suspend /test
            ecflow_client --replace /test test.def

      .. tab:: Python

         .. code-block:: shell

            python3 test.py
            python3 client.py

#. Observer the label change using the :term:`ecflow_ui`.
#. Customise the label colouring in :ref:`ecflow_ui`, at Tools > Preferences... > Appearance > Node Labels