Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
HTML
<div class="section" id="example">
<span id="index-0"></span><span id="id1"></span>
<p>A suite template is provided to demonstrate basic SMS features which
can be used as a starting point for suite design.</p>
<ul>
<li><p class="first">Download the tar-file <a class="reference download internal" href="../../_downloads/skull.tgz"><tt class="xref download docutils literal"><span class="pre">skull</span> <span class="pre">suite</span></tt></a></p>
</li>
<li><p class="first">untar it:</p>
<div class="highlight-python"><pre>&gt; tar -xzvf skull.tgz</pre>
</div>
</li>
<li><p class="first">eventually, start a SMS server:</p>
<div class="highlight-python"><pre>&gt; sms_start</pre>
</div>
</li>
<li><p class="first">convention at ECMWF is to attribute a program number
according to the formula:</p>
<div class="highlight-python"><pre>&gt; prog_num=$((900000 + $(id -u))); echo $prog_num</pre>
</div>
</li>
<li><p class="first">open xcdp, File-&gt;Login to: &#8220;localhost &lt;prog_num&gt;&#8221;</p>
</li>
<li><p class="first">play the skull suite into sms:</p>
<div class="highlight-python"><pre>&gt; export SMS_PROG=$((900000+$(id -u)))
&gt; LOGGER="setenv -i $SMS_PROG; login localhost $USER 1;"
&gt; /usr/local/apps/sms/bin/cdp -c "$LOGGER play -r /skull skull.def"</pre>
</div>
</li>
<li><p class="first">skull suite families are</p>
<ul class="simple">
<li>make: to open a xterm window from jobs run on local workstation, ecgate, HPC, linux cluter</li>
<li>consumer: to demonstrate the producer-consumer pattern</li>
<li>dinner: a resource sharing example through the dinning philosophers example</li>
<li>shop: to practice dynamic tasks generation</li>
<li>perl, Python: as task template examples that do not use ksh</li>
</ul>
<img alt="../../_images/skull.png" src="../../_images/wiki/download/attachments/7373012/skull.png" />
</li>
<li><p class="first">conversion to a text based definition file written by ksh (skull.sh) is rather straightfoward:</p>
<div class="highlight-python"><pre>&gt; make sh</pre>
</div>
<p>libgen.sh is generated to provide cdp:play commands in ksh environment:</p>
<div class="highlight-python"><pre>&gt; bin/genlibdef.sh sh libgen.sh</pre>
</div>
<div class="highlight-python"><pre>set -eu
if [[ ${DEBUG_DEF2ECF:=0} != 0 ]] ; then set -eux ; fi
alias EOF='echo EOF &gt;&amp;3 '
alias abort='echo abort &gt;&amp;3 '
alias action='echo action &gt;&amp;3 '
alias autocancel='echo autocancel &gt;&amp;3 '
alias automigrate='echo automigrate &gt;&amp;3 '
alias autorestore='echo autorestore &gt;&amp;3 '
alias clock='echo clock &gt;&amp;3 '
alias complete='echo complete &gt;&amp;3 '
alias cron='echo cron &gt;&amp;3 '
alias date='echo date &gt;&amp;3 '
alias day='echo day &gt;&amp;3 '
alias defstatus='echo defstatus &gt;&amp;3 '
alias edit='echo edit &gt;&amp;3 '
alias endfamily='echo endfamily &gt;&amp;3 '
alias endsuite='echo endsuite &gt;&amp;3 '
alias endtask='echo endtask &gt;&amp;3 '
alias event='echo event &gt;&amp;3 '
alias extern='echo extern &gt;&amp;3 '
alias family='echo family &gt;&amp;3 '
alias inlimit='echo inlimit &gt;&amp;3 '
alias label='echo label &gt;&amp;3 '
alias late='echo late &gt;&amp;3 '
alias limit='echo limit &gt;&amp;3 '
alias meter='echo meter &gt;&amp;3 '
alias owner='echo owner &gt;&amp;3 '
alias repeat='echo repeat &gt;&amp;3 '
alias suite='echo suite &gt;&amp;3 '
alias task='echo task &gt;&amp;3 '
alias text='echo text &gt;&amp;3 '
alias time='echo time &gt;&amp;3 '
alias today='echo today &gt;&amp;3 '
alias trigger='echo trigger &gt;&amp;3 '
</pre>
</div>
<p>At this stage, libgen.sh can be manually updated, to replace EOF
with exit 0, inhibit the action, automigrate, autorestore, owner commands
(which are unavailable in ecFlow). Change the limit, date, time naming, as it
interferes with ksh intrinsics.</p>
<p>It is possible to transcode most CDP commands into ksh, defining
aliases that will print the cdp:play command and redirect their output in a
dedicated file descriptor:</p>
<div class="highlight-python"><pre>&gt; bin/def2ecf.sh sh gen</pre>
</div>
<p>sh/skull.sh contains the ksh command to create the file descriptor 3:</p>
<div class="highlight-python"><pre>&gt; exec 3&gt; expanded.tmp</pre>
</div>
<p>SMS <strong>.def</strong> definition files may be updated to facilitate such
transcoding (#CONV tags into *.def files):</p>
<blockquote>
<div><ul>
<li><p class="first">commands can be split into multiline commands to simplify
mathematical expressions
incompatible commands (owner, autorestore, automigrate, action)
can be removed or set as a comment</p>
</li>
<li><p class="first">multiline triggers changed into one line commands</p>
</li>
<li><p class="first">the heavy use of aliases can lead to confused transcoding</p>
</li>
<li><p class="first">CDP is known to be &#8220;tolerant&#8221;: for example, an unboumded endin
command is transparent to CDP, but it would mislead the
transcoder.</p>
</li>
<li><p class="first">for CDP, commands accept minimum significant string for options;
they should be replace with their unambiguous version:</p>
<div class="highlight-python"><pre>&gt; # CDP: repeat int iter 1 $life_expectency
&gt; repeat integer iter 1 $life_expectency</pre>
</div>
</li>
<li><p class="first">through its simplicity, the CDP language was a way to keep away from
complex code. Once left behind, it is each suite designers
responsability to stick to simple manageable, portable and
maintainable code.</p>
</li>
<li><p class="first">beware homonyms: such as date, time, limit</p>
</li>
</ul>
</div></blockquote>
<p>This demonstrates the feasibility, for a simple suite. Past
experience shows it is not as easy when considering a more complex suite design.</p>
<p>The suite definition is then expanded, as a file sh/expanded.tmp:</p>
<div class="highlight-python"><pre>&gt; bin/def2ecf.sh sh expand</pre>
</div>
<p>or:</p>
<div class="highlight-python"><pre>&gt; cd sh; ksh skull.sh</pre>
</div>
</li>
<li><p class="first">the suite can be played locally and expanded for comparison:</p>
<div class="highlight-python"><pre>&gt; /usr/local/apps/sms/bin/cdp -c "play -l skull.def; show &gt; expand.cdp"
&gt; kompare expand.cdp sh/expand.tmp
&gt; kompare skull.def  sh/skull.sh</pre>
</div>
</li>
<li><p class="first">it can then be loaded into SMS:</p>
<div class="highlight-python"><pre>&gt; /usr/local/apps/sms/bin/cdp -c "LOGGER play -r /skull sh/expanded.tmp"</pre>
</div>
</li>
<li><p class="first">apply the command begin and resume with XCdp or CDP</p>
</li>
<li><p class="first">We can then start ecFlow server, if not already done:</p>
<div class="highlight-python"><pre>&gt; use ecflow
&gt; export ECF_PORT=$((20000+$(id -u)))
&gt; mkdir ecf &amp;&amp; cd ecf
&gt; ecflow_server</pre>
</div>
</li>
<li><p class="first">expanded suite can be loaded into ecFlow:</p>
<div class="highlight-python"><pre>&gt; cd ..
&gt; ecflow_client --load sh/expanded.tmp</pre>
</div>
</li>
<li><p class="first">once loaded, it can be replaced with:</p>
<div class="highlight-python"><pre>&gt; ecflow_client --replace /skull sh/expanded.tmp</pre>
</div>
</li>
<li><p class="first">commands begin and resume can be applied on the console or with ecflowview:</p>
<div class="highlight-python"><pre>&gt; ecflow_client --begin /skull
&gt; ecflow_client --resume /skull
&gt; ecflow_client --resume /skull/skull /skull/perl /skull/python</pre>
</div>
</li>
<li><p class="first">in this example, it is enough to <strong>link task wrappers</strong> from the
original name <em>.sms</em> to the expected name <em>.ecf</em>.</p>
<p>Alternatively, ECF_EXTN variable may be defined, as <strong>.sms</strong> on the
top node.</p>
</li>
<li><p class="first"><strong>smsfiles/passby.sms</strong> task wrapper has been updated to be compatible in both modes.</p>
</li>
<li><p class="first"><strong>smsfiles/perl.sms</strong> and <strong>smsfiles/python.sms</strong> call an intermediate
function to access the meter child command: call_meter</p>
</li>
<li><p class="first">in the directory include: trap.h, perl_header.h, python_header.h,
endt.h, were modified to enable ecFlow mode.</p>
</li>
<li><p class="first"><strong>include/inc_ecf.h</strong> was added and included from trap.h to add new expected variables, when ECF_PORT variable is not 0.</p>
</li>
<li><p class="first">it may be an interesting exercise to transform into Python code the file skull.def and the related families defined in
their dedicated definition files. The script ./bin/def2ecf.pl can be used to produce a transcoded file. Careful attention
is required to fix the transcoder mistakes and obtain a script that can be parsed with Python.  Then a script that
can be loaded as a proper suite into SMS, or ecFlow.</p>
<ul class="simple">
<li>pydef_example/inc_hostc.py is a Python library used to maintain a definition file syntax close to CDP&#8217;s.</li>
<li>the transcoded file has to be checked for all dollar variables</li>
<li>all CDP functions parameters are transcoded incorrectly: $1, $2 ... They can be transformed into named arguments, with a
default value when needed.</li>
<li>the definition tree is created adding the lines</li>
</ul>
</li>
</ul>
<dl class="docutils">
<dt>::</dt>
<dd><blockquote class="first">
<div>s = suite(SELECTION)
DEFS = Defs()
DEFS.add_suite(s)</div></blockquote>
<ul class="last simple">
<li>choice must be made whether to use &#8220;import library&#8221; or &#8220;from library import *&#8221;.</li>
<li>to maintain code readability, new functions can be created (create_suite)</li>
</ul>
</dd>
</dl>
</div>