Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Horizontal Navigation Bar


Button Group

Button Hyperlink
titlePrevious
typestandard
urlhttps://confluence.ecmwf.int/display/ECFLOW/Add+a+Cron
Button Hyperlink
titleUp
typestandard
urlhttps://confluence.ecmwf.int/display/ECFLOW/Advanced+Topics
Button Hyperlink
titleNext
typestandard
urlhttps://confluence.ecmwf.int/display/ECFLOW/Query+state


Some time it is very useful to see task-specific information in ecflow_ui
For this, we can define a label. A label is a string that is attached to a task
and that can be updated using the child command ecflow_client –label
   

Ecf Script

We will create a new family label with a task t1.
Create ecf script $HOME/course/test/label/t1.ecf


Code Block
languagebash
title $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 60            

...

         

...

 

...

 

...

 

...

   # Wait 

...

a 

...

one minute
   (( n 

...

= 

...

$n + 

...

1 ))
done

ecflow_client --label=info "I have now finished my work."

%include <tail.h>


Text

Code Block
# Definition of the suite test. Note Family f1,f2 from previous pages are omitted
suite test
 edit ECF_INCLUDE "$HOME/course"
 edit ECF_HOME    "$HOME/course"
 family label
     task t1
         label info ""
 endfamily
endsuite


Python

The following section shows how to add an ecflow.Label in python: ( Note: families f1 and f2 are omitted for brevity)

Code Block
languagepy
title$HOME/course/test.py
import os
from ecflow import Defs,Suite,Family,Task,Edit,Trigger,Complete,Event,Meter,Time,Day,Date,Label

def create_family_label():
    return Family("label",
                Task("t1",
                Label("info","")))
 
print("Creating suite definition")  
home = os.path.join(os.getenv("HOME"), "course")
defs = Defs( 
        Suite("test",
            Edit(ECF_INCLUDE=home,ECF_HOME=home),
            create_family_label()))
print(defs) 

print("Checking job creation: .ecf -> .job0")  
print(defs.check_job_creation())

print("Checking trigger expressions")
assert len(defs.check()) == 0, defs.check()

print("Saving definition to file 'test.def'")
defs.save_as_defs("test.def")

What to do

  1. Modify the suite definition file or python script
  2. Create the new ecf script file $HOME/course/test/label/t1.ecf
  3. Replace the suite definition
  4. Watch in ecflow_ui
  5. Change the label colour in ecflow_ui, Tools->Preferences...→Appearance->Node Labels
       
Horizontal Navigation Bar


Button Group

Button Hyperlink
titlePrevious
typestandard
urlhttps://confluence.ecmwf.int/display/ECFLOW/Add+a+Cron
Button Hyperlink
titleUp
typestandard
urlhttps://confluence.ecmwf.int/display/ECFLOW/Advanced+Topics
Button Hyperlink
titleNext
typestandard
urlhttps://confluence.ecmwf.int/display/ECFLOW/Query+state

endsuite</pre> </div> <p>The following section shows how to add a <tt class="xref py py-class docutils literal"><span class="pre">ecflow.Label</span></tt> in python:</p> <div class="highlight-python"><div class="highlight"><pre><span class="c">#!/usr/bin/env python2.5</span> <span class="kn">import</span> <span class="nn">os</span> <span class="kn">import</span> <span class="nn">ecflow</span> <span class="k">def</span> <span class="nf">create_family_f3</span><span class="p">():</span> <span class="n">f3</span> <span class="o">=</span> <span class="n">ecflow</span><span class="o">.</span><span class="n">Family</span><span class="p">(</span><span class="s">&quot;f3&quot;</span><span class="p">)</span> <span class="n">t1</span> <span class="o">=</span> <span class="n">f3</span><span class="o">.</span><span class="n">add_task</span><span class="p">(</span><span class="s">&quot;t1&quot;</span><span class="p">)</span> <span class="n">t1</span><span class="o">.</span><span class="n">add_label</span><span class="p">(</span><span class="s">&quot;info&quot;</span><span class="p">,</span><span class="s">&quot;&quot;</span><span class="p">);</span> <span class="k">return</span> <span class="n">f3</span> <span class="n">defs</span> <span class="o">=</span> <span class="n">ecflow</span><span class="o">.</span><span class="n">Defs</span><span class="p">()</span> <span class="n">suite</span> <span class="o">=</span> <span class="n">defs</span><span class="o">.</span><span class="n">add_suite</span><span class="p">(</span><span class="s">&quot;test&quot;</span><span class="p">)</span> <span class="n">suite</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">&quot;ECF_INCLUDE&quot;</span><span class="p">,</span><span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s">&quot;HOME&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="s">&quot;/course&quot;</span><span class="p">)</span> <span class="n">suite</span><span class="o">.</span><span class="n">add_variable</span><span class="p">(</span><span class="s">&quot;ECF_HOME &quot;</span><span class="p">,</span><span class="n">os</span><span class="o">.</span><span class="n">getenv</span><span class="p">(</span><span class="s">&quot;HOME&quot;</span><span class="p">)</span> <span class="o">+</span> <span class="s">&quot;/course&quot;</span><span class="p">)</span> <span class="n">suite</span><span class="o">.</span><span class="n">add_family</span><span class="p">(</span> <span class="n">create_family_f3</span><span class="p">()</span> <span class="p">)</span> </pre></div> </div> <p>We now need to edit the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-ecf-script"><em class="xref std std-term">ecf script</em></a> file <tt class="file docutils literal"><span class="pre">$HOME/course/test/f3/t1.ecf</span></tt>:</p> <div class="highlight-python"><pre>%include &lt;head.h&gt; 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 60 # Wait a one minute (( n = $n + 1 )) done ecflow_client --label info "I have now finished my work." %include &lt;tail.h&gt;</pre> </div> <p>What to do:</p> <ol class="arabic simple"> <li>Modify the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-suite-definition"><em class="xref std std-term">suite definition</em></a> file or python script</li> <li>Edit the new <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-ecf-script"><em class="xref std std-term">ecf script</em></a></li> <li>Load the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-suite-definition"><em class="xref std std-term">suite definition</em></a> file and begin the <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-suite"><em class="xref std std-term">suite</em></a></li> <li>Watch in <a class="reference internal" href="/wiki/display/ECFLOW/Glossary#term-ecflowview"><em class="xref std std-term">ecflowview</em></a></li> </ol> </div>