Beispiel #1
0
            Task("t3").add(Trigger("t2:a")),
            Task("t4").add(Complete("t2:b"),
                           Trigger("t2 eq complete and not t2:b"))),
        Family("f2").add(
            Task("t1").add(Time("00:30 23:30 00:30")),
            Task("t2").add(Day("sunday")),
            Task("t3").add(Time("12:00"), Date("1.*.*")),
            Task("t4").add(Time("+00:02")),
            Task("t5").add(Time("00:02"))))


if __name__ == "__main__":
    SUITE = create()
    if True:
        import fif
        import el52_block_case as case
        import el53_block_daily as daily
        import el54_block_for as ffor
        SUITE.add(
            Family("visualise").add(fif.family_if(), case.family_case(),
                                    daily.process(), ffor.family_for()))
    DEFS = Defs()
    DEFS.add_suite(SUITE)
    CLIENT = ecflow.Client(os.getenv("ECF_HOST", "localhost"),
                           os.getenv("ECF_PORT", 2500))
    DEFS.generate_scripts()
    RESULT = DEFS.simulate()
    print(RESULT)
    NODE = '/' + SUITE.name()
    CLIENT.replace("/%s" % NODE, DEFS)
Beispiel #2
0
#!/usr/bin/env python2.7
""" back archive example """
from __future__ import print_function
import os
import ecf as ecflow
from ecf import (Defs, Defstatus, Suite, Family, Task, Variables, Label,
                 Limit, Inlimit, Repeat, Trigger)
HOME = os.getenv("HOME") + "/ecflow_server"
NAME = "back_archiving"; FILES = HOME + "/back"; DEFS = Defs()
DEFS.add(Suite(NAME).add(
    Defstatus("suspended"),  # so that jobs do not start immediately
    Repeat(kind="day", step=1),
    Variables(ECF_HOME=HOME, ECF_INCLUDE=HOME, ECF_FILES=FILES, SLEEP=2),
    Limit("access", 2),
    [Family(kind).add(
        Repeat("DATE", 19900101, 19950712, kind="date"),
        Variables(KIND=kind),
        Task("get_old").add(Inlimit("access"), Label("info", "")),
        Task("convert").add(Trigger("get_old == complete")),
        Task("save_new").add(Trigger("convert eq complete"))
    ) for kind in ("analysis", "forecast", "climatology", "observations", "images")]))
# print(DEFS); DEFS.generate_scripts(); 
RESULT = DEFS.simulate(); print(RESULT)
CLIENT = ecflow.Client(os.getenv("ECF_HOST", "localhost"),
                       os.getenv("ECF_PORT", 2500))
CLIENT.replace("/%s" % NAME, DEFS)
Beispiel #3
0
   ecflow_client --abort=trap  # Notify ecFlow that something went
                               # wrong, using 'trap' as the reason
   trap 0                      # Remove the trap
   exit 0                      # End the script
}

# Trap any calls to exit and errors caught by the -e flag
trap ERROR 0

# Trap any signal that may cause the script to fail
trap '{ echo "Killed by a signal"; ERROR ; }' 1 2 3 4 5 6 7 8 10 12 13 15"""
deploy(head, include + "head.h")

#####################################################################
tail = """wait            # wait for background process to stop
ecflow_client --complete  # Notify ecFlow of a normal end
trap 0                    # Remove all traps
exit 0                    # End the shell"""
deploy(tail, include + "tail.h")

#####################################################################
# loading a node into ecflow server
defs = Defs()
defs.add_suite(suite)
HOST = os.getenv("ECF_HOST", "localhost")
PORT = os.getenv("ECF_PORT", "2500")
client = Client(HOST, PORT)
path = '/%s' % suite.name() 
client.replace(path, defs)
print("#\n#MSG: node", path, "is now replaced on", HOST, PORT)
#!/usr/bin/env python2.7
from __future__ import print_function
""" add another task, another manual """
import os
from ecf import (Defs, Defstatus, Suite, Variable, Task, Client)
print("Creating suite definition")
ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server")
NAME = os.getenv("SUITE", "elearning")
DEFS = Defs()
DEFS.add(  # suite definition
    Suite(NAME).add(
        Defstatus("suspended"),  # so that jobs do not start immediately
        Variable("ECF_HOME", ECF_HOME),
        Task("t1"),  # first task
        Task("t2"),  # second task
    ))
SCRIPT_TEMPLATE = """%manual
  Manual for task t2
  Operations: if this task fails, set it to complete, report next working day
  Analyst:    Check something ...
%end
%include <head.h>
echo "I am part of a suite that lives in %ECF_HOME%"
%include <tail.h>

%manual
  There can be multiple manual pages in the same file.
  When viewed they are simply concatenated.
%end
"""
#!/usr/bin/env python
from __future__ import print_function
import os
import ecf as ecflow
from ecf import (Defstatus, Suite, Family, Task, Variables, Trigger, Event,
                 Meter, Defs, Client)
ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server")
NAME = os.getenv("SUITE", "elearning")
DEFS = Defs()
DEFS.add(  # suite definition
    Suite(NAME).add(
        Defstatus("suspended"),  # so that jobs do not start immediately
        Variables(  # add multiple variables at once
            ECF_HOME=ECF_HOME,  # where job files are created by ecflow
            ECF_FILES=ECF_HOME + "/files",  # where to find script templates
            ECF_INCLUDE=ECF_HOME + "/include",  # where to find head.h tail.h
            SLEEP=2),
        Family("f2").add(
            Task("t1").add(Meter("step", -1, 240)),
            Task("t2").add(Trigger("t1 eq complete"), Event("a"), Event("b")),
            Task("t3").add(Trigger("t2:a")),
            Task("t4").add(Trigger("t2:b")),
            Task("t5").add(Trigger("t1:step ge 24")),
            Task("t6").add(Trigger("t1:step ge 48")),
            Task("t7").add(Trigger("t1:step ge 120")),
        )))

SCRIPT_TEMPLATE = """#!/bin/bash
%include <head.h>
STEP=0
while [[ $STEP -le 240 ]] ; do
#!/usr/bin/env python2.7
""" add late attribute """
from __future__ import print_function
import os
import ecf as ecflow
from ecf import (Defs, Defstatus, Suite, Family, Task, Variables, Late, Limit,
                 Inlimit)

ecflow.USE_LATE = True
ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server")
DEFS = Defs()
NAME = os.getenv("SUITE", "elearning")


def create_family_f5():
    return Family("f5").add(Limit(
        "l1", 2), Inlimit("l1"), Variables(SLEEP=2), [
            Task("t%d" % idn).add(Late("-s 00:03 -a 00:10"))
            for idn in xrange(1, 10)
        ])


DEFS.add(  # suite definition
    Suite(NAME).add(
        Defstatus("suspended"),  # so that jobs do not start immediately
        Variables(  # we can add multiple variables at once
            ECF_HOME=ECF_HOME,  # where job files are created by ecflow
            ECF_FILES=ECF_HOME + "/files",  # where to find script templates
            ECF_INCLUDE=ECF_HOME + "/include",  # where to find head.h tail.h
            SLEEP=2,
        ),
Beispiel #7
0
#!/usr/bin/env python
from __future__ import print_function
import os
import ecf as ecflow
from ecf import (Defstatus, Suite, Family, Task, Variables, Trigger, Event,
                 Complete, Defs, Client)
ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server")
NAME = os.getenv("SUITE", "elearning")
DEFS = Defs()
DEFS.add(  # suite definition
    Suite(NAME).add(
        Defstatus("suspended"),  # so that jobs do not start immediately
        Variables(  # add multiple variables at once:
            ECF_HOME=ECF_HOME,  # where job files are created by ecflow
            ECF_FILES=ECF_HOME + "/files",  # where to find script template
            ECF_INCLUDE=ECF_HOME + "/include",  # where to find head.h tail.h
            SLEEP=5),
        Family("f1").add(
            Task("t1"),
            Task("t2").add(Trigger("t1 eq complete"), Event("a"), Event("1")),
            Task("t3").add(Trigger("t2:a")),
            Task("t4").add(
                Complete("t2:1"),
                Trigger("t2 eq complete"),
            ))))

if __name__ == '__main__':
    HOST = os.getenv("ECF_HOST", "localhost")
    PORT = int(os.getenv("ECF_PORT", "%d" % (1500 + os.getuid())))
    CLIENT = Client(HOST, PORT)
    NODE = "/" + NAME  # replace top
#!/usr/bin/env python
""" data acquisition suite example """
from __future__ import print_function
import os
import ecf as ecflow
from ecf import (Date, Day, Defs, Defstatus, Suite, Family, Task,
                 If,  # If attribute in use example
                 Edit, Label, Repeat, Time, Trigger, Defs, Client)
HOME = os.getenv("HOME") + "/ecflow_course"; NAME = "data_acquisition"; DEFS = Defs()
DEFS.add(Suite(NAME).add(
    Defstatus("suspended"),  # so that jobs do not start immediately
    Repeat(kind="day", step=1),
    Edit(ECF_HOME=HOME, ECF_INCLUDE=HOME, ECF_FILES=HOME + "/acq", SLEEP=2),
    [Family(city).add(
        Family("archive").add(
            [Family(obs_type).add(
                If(test=city in ("Exeter", "Toulouse", "Offenbach"), then=Time("00:00 23:00 01:00")),
                If(city in ("Washington"), Time("00:00 23:00 03:00")),
                If(city in ("Tokyo"), Time("12:00")),
                If(city in ("Melbourne"), Day("monday")),
                If(city in ("Montreal"), Date("1.*.*")),
                Task("get").add(Label("info", "")),
                Task("process").add(Trigger("get eq complete")),
                Task("store").add(Trigger("get eq complete")))
             for obs_type in ("observations", "fields", "images")]))
        for city in ("Exeter", "Toulouse", "Offenbach", "Washington",
                     "Tokyo", "Melbourne", "Montreal")]))
# print(DEFS); DEFS.generate_scripts(); 
RESULT = DEFS.simulate(); # print(RESULT)
CLIENT = Client(os.getenv("ECF_HOST", "localhost"),
                       os.getenv("ECF_PORT", 2500))
#!/usr/bin/env python
from __future__ import print_function
import os
import ecf as ecflow
from ecf import (Defstatus, Suite, Family, Task, Edit,
                 Time, Date, Day, Clock, Defs, Client)
ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server")
NAME = os.getenv("SUITE", "elearning")
DEFS = Defs()
DEFS.add(  # suite definition
    Suite(NAME).add(
        Clock("real"),
        Defstatus("suspended"),  # so that jobs do not start immediately
        Edit(  # we can add multiple variables at once
            ECF_HOME=ECF_HOME,  # where job files are created by ecflow
            ECF_FILES=ECF_HOME + "/files",  # where to find script templates
            ECF_INCLUDE=ECF_HOME + "/include",  # where to find head.h tail.h
            SLEEP=2, ),
        Family("f2").add(
            Task("t1").add(Time("00:30 23:30 00:30")),
            Task("t2").add(Day("sunday")),
            Task("t3").add(Date("16.01.2018"),
                           Time("12:00")),
            Task("t4").add(Time("+00:02")),
            Task("t5").add(Time("00:02")))))

SCRIPT_TEMPLATE = """#!/bin/bash
%include <head.h>
STEP=0
while [[ $STEP -le 240 ]] ; do
  sleep %SLEEP:1%; ecflow_client --meter step $STEP  # share progress
else:  # except ImportError, err:
    v = "2.7"
    v = "3.5"
    INST = "/usr/local/apps/ecflow/lib/python%s/site-packages/ecflow:" % v
    sys.path.append(INST)
    INST = "/usr/local/lib/python%s/site-packages/ecflow" % v
    sys.path.append(INST)
    from ecf import (Defs, Suite, Defstatus, Edit, Task)
    if 0:
        raise Exception(  #ERR: could not import ecf. Does the following line help?"+
            "\nexport PYTHONPATH=$PYTHONPATH:%s" % INST)

print("Creating suite definition")
ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server")
NAME = os.getenv("SUITE", "elearning")
DEFS = Defs()
DEFS.add(
    Suite(NAME).add(  # simplest suite definition
        Defstatus("suspended"),  # so that jobs do not start immediately
        Edit(
            ECF_HOME=ECF_HOME,  # where to find jobs + output files
            ECF_FILES=ECF_HOME + "/files",  # script template .ecf
            ECF_INCLUDE=ECF_HOME + "/include"),  # include files .h
        Task("t1")))  # a first task

if __name__ == '__main__':
    print(DEFS)
    NAME = ECF_HOME + NAME
    print("Saving definition to file '%s.def'" % NAME)
    os.system("mkdir -p %s" % NAME)
    DEFS.save_as_defs("%s.def" % NAME)  # an external client can use it
Beispiel #11
0
                 Repeat, Trigger)
HOME = os.getenv("HOME") + "/ecflow_server"
LAST_STEP = {
    "12": 240,
    "00": 24,
}
NAME = "operational_suite"


def cycle_trigger(cyc):
    if cyc == "12":
        return Trigger("./00==complete")
    return None


DEFS = Defs()
DEFS.add(
    Suite(NAME).add(
        Defstatus("suspended"),  # so that jobs do not start immediately
        Repeat(kind="day", step=1),
        Variables(ECF_HOME=HOME,
                  ECF_INCLUDE=HOME + "/include",
                  ECF_FILES=HOME + "/files"),
        [
            Family(str(cycle)).add(
                Variables(CYCLE=cycle, LAST_STEP=LAST_STEP[cycle]),
                cycle_trigger(cycle),
                Family("analysis").add(
                    Task("get_observations"),
                    Task("run_analysis").add(Trigger([
                        "get_observations",
Beispiel #12
0
#!/usr/bin/env python
from __future__ import print_function
import os
import ecf as ecflow
from ecf import (Defstatus, Suite, Family, Task, Variables, Label, Meter, Defs,
                 Client)
ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server")
ECF_INCLUDE = ECF_HOME + "/include"
NAME = os.getenv("SUITE", "elearning")
DEFS = Defs()
DEFS.add(  # suite definition
    Suite(NAME).add(
        Defstatus("suspended"),  # so that jobs do not start immediately
        Variables(  # we can add multiple variables at once
            ECF_HOME=ECF_HOME,  # where job files are created by ecflow
            ECF_FILES=ECF_HOME + "/files",  # where to find script template
            ECF_INCLUDE=ECF_INCLUDE,  # where to find head.h tail.h
            SLEEP=2,
        ),
        Family("f3").add(
            Task("t1").add(Label("info", "none"), Meter("step", -1, 240)))))

SCRIPT_TEMPLATE = """#!/bin/bash
%include <head.h>
STEP=0
while [[ $STEP -le 240 ]] ; do
  sleep %SLEEP:1%; ecflow_client --meter step $STEP  # share progress
  msg="The date is now $(date)"
  ecflow_client --label info "$msg"
  (( STEP = STEP + 1))
done
Beispiel #13
0
            Task("t1").add(
                Time("00:30 23:30 00:30")),
            Task("t2").add(
                Day("sunday")),
            Task("t3").add(
                Time("12:00"),
                Date("1.*.*")),
            Task("t4").add(
                Time("+00:02")),
            Task("t5").add(
            Time("00:02"))))


if __name__ == "__main__":
    NAME = os.getenv("SUITE", "elearning")
    DEFS = Defs()
    SUITE = create(NAME)
    if True:
        import ex1, ex1s, ex2, ex2s, ex3, ex4
        SUITE.add(Family("exercises").add(
            ex1.time_and_dates(),
            ex2.cron_clean(),
            ex3.time_event(),
            Family("priorityP").add(ex4.priority()),
            Family("priorityS").add(ex4.priority_limit()), ))
        DEFS.add_suite(ex2s.ex2("repeat_clean"))
    if True:
        import limit, limit2, fif, ffor, case
        import el58_produce_consume as produce
        SUITE.add(
            Family("visualise").add(