コード例 #1
0
def create(name=os.getenv("SUITE", "elearning")):
    return Suite(name).add(
        Defstatus("suspended"),  # start immediately or not for this demo
        Clock("real"),
        Edit(ECF_INCLUDE=HOME,  # header files
             ECF_FILES=HOME,  # script template .ecf
             ECF_HOME=HOME),  # job + local output files
        Family("f1").add(
            Task("t1").add(
                Event(1),
                Label("info", ""),
                Meter("step", -1, 100)),
            Task("t2").add(
                Late("-c 01:00"),
                Meter("step", -1, 100),
                Event("a"),
                Event("b"),
                Trigger("t1:step gt 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"))))
コード例 #2
0
def create(name):
    """ suite provider """
    return Suite(name).add(
        Defstatus("suspended"),
        Edit(ECF_INCLUDE=HOME,  # header files
             ECF_FILES=HOME,    # script template .ecf
             ECF_HOME=HOME),    # job + local output files
        Family("f1").add(
            Task("t1").add(
                Label("info", ""),
                Late("-c 01:00"),
                Meter("step", -1, 100)),
            Task("t2").add(
                Meter("step", -1, 100),
                Event("a"),
                Event("b"),
                Trigger("t1:step gt 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"))))
コード例 #3
0
ファイル: fif.py プロジェクト: rolinzcy/debian-ecflow
def family_if():
    """ if block as a family example """
    return (
        Family("if_then_else").add(
            Task("if").add(Event(1)),
            Task("then").add(Trigger("if:1"),
                             Complete("if==complete and not if:1")),
            Task("else").add(Complete("if:1"),
                             Trigger("if eq complete and not if:1"))),
        Family("if").add(  # one script
            Task("model").add(Event(1))),
        Family("then").add(Trigger("if/model:1"),
                           Complete("if eq complete and not if/model:1"),
                           Task("model")),
        Family("else").add(Complete("if/model:1"),
                           Trigger("if eq complete and not if/model:1"),
                           Task("model")))
コード例 #4
0
ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server")
NAME = os.getenv("SUITE", "elearning")
DEFS = ecflow.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(
                Trigger("t2:1")))))

SCRIPT_TEMPLATE = """#!/bin/bash
%include <head.h>
echo "I will now sleep for %SLEEP:1% seconds"
sleep %SLEEP:1%; ecflow_client --event a  # set first event
sleep %SLEEP:!%; ecflow_client --event 1  # set a second event
sleep %SLEEP:1%;  # don't sleep too much anyway
%include <tail.h>
"""
コード例 #5
0
def call_consumer(selection):
    lead = "/%s/consumer/admin/leader:1" % selection
    prod = "/%s/consumer/produce" % selection

    return Family("consumer").add(
        Defstatus("suspended"),

        Edit(SLEEP=10,
             PRODUCE="no",
             CONSUME="no"),

        Family("limit").add(
            Defstatus("complete"),
            Limit("consume", 7),),

        Family("admin").add(
            # set manually with the GUI or alter the event 1 so
            # that producer 1 becomes leader
            # default: producer0 leads
            Task("leader").add(
                Event("1"),  # text this task is dummy task not designed to run
                Defstatus("complete"))),
        
        Edit(PRODUCE="yes",  # default : task does both produce/consume
             CONSUME="yes"),

        call_task("produce", beg, fin, by).add(
            # this task will do both produde/consume serially            
            Label("info", "both produce and consume in one task")),

        Family("produce0").add(
            # loop inside the task, report progress with a Meter
            not_consumer(),
            Label("info", "loop inside the job"),
            call_task("produce", beg, fin, by)),

        Family("produce1").add(
            # choice is to submit a new job for each step, here        
            Label("info", "loop in the suite (repeat), submit one job per step"),
            not_consumer(),
            call_task("produce", '%STEP%', "%STEP%", by).add(
                Repeat("STEP", beg, fin, by, kind="integer"))),

        Family("consume").add(
            Label("info", "use ecflow_client --wait %TRIGGER% in the job"),
            not_producer(),
            Inlimit("limit:consume"),
            Edit(CALL_WAITER=1,
                 # $step will be interpreted in the job!
                 TRIGGER="../produce:step gt consume:$step or " +
                 "../produce eq complete"),
            call_task("consume", beg, fin, by)),

        Family("consume0or1").add(
            Label("info", "an event may indicate the leader to trigger from"),
            not_producer(),
            Inlimit("limit:consume"),
            call_task("consume", "%STEP%", "%STEP%", by),
            Repeat("STEP", beg, fin, by, kind="integer"),
            trigger("(%s and (consume0or1:STEP lt %s1/produce:STEP" % (
                lead, prod) + " or %s==complete)) or " % prod +
                    "(not %s and (consume0or1:STEP lt %s0/produce:step" % (
                        lead, prod) + " or %s0/produce==complete))" % prod)),

        Family("consume1").add(
            Label("info", "spread consumer in multiple families"),
            not_producer(),
            Inlimit("limit:consume"),
            consume1(producer=prod)),

        Family("consume2").add(
            # change manually with the GUI the limit to reduce/increase the load
            Label("info", "one family per step to consume"),
            Inlimit("limit:consume"),
            not_producer(),
            consume2(beg, fin, prod)))
コード例 #6
0
def events():
    return (Event("p"), Event("c"))
コード例 #7
0
from ecf import (Defstatus, Suite, Family, Task, Variables, Trigger, Event,
                 Meter)
ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server")
NAME = os.getenv("SUITE", "elearning")
DEFS = ecflow.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
  ecflow_client --meter step $STEP  # share progress
  msg="The date is now $(date)"; sleep %SLEEP:1%
  (( STEP = STEP + 1))
done
%include <tail.h>
コード例 #8
0
#####################################################################
# suite definition
acq = "acquisition"
deploy("echo acq %TASK%", files + acq + extn)  # create wrapper
post = "postproc"
deploy("ecflow_client --label info %TASK%", files + post + extn)
suite = Suite("course").add(
    Defstatus("suspended"),
    Repeat("YMD", 20180101, 20321212, kind="date"),
    Variables(ECF_HOME=home,  # jobs files are created there by ecflow
              ECF_FILES=home + "/files",  # task-wrappers location
              ECF_INCLUDE=home + "/include",  # include files location
              # ECF_OUT=home,  # output files location on remote systems, 
                               # no directory created there by ecflow...
              ECF_EXTN=extn, ),  # task wrapper extension
    Task(acq).add(Event(1)),
    Family("ensemble").add(  # ENS
        Complete(acq + ":1"),
        [Family("%02d" % num).add(
            Variables(ID=num),
            model(360, dependencies="../../" + acq))  # relative path...
         for num in xrange(0, 10)]),
    model(240, dependencies=acq),  # HRES
    Task(post).add(
        Trigger("model eq complete"),
        Label("info", "")))


#####################################################################
head = """#!/bin/bash
set -e # stop the shell on first error