def create_family_house_keeping(): return Family("house_keeping", Task("clear_log", Cron("22:30", days_of_week=[0]))) def create_family_f3(): return Family("f3", Task("t1", Label("info", ""))) print("Creating suite definition") home = os.path.abspath(Path(Path(__file__).parent, "../../../build/course")) defs = Defs( Suite('test', Edit(ECF_INCLUDE=home, ECF_HOME=home), create_family_f1(), create_family_house_keeping(), create_family_f3())) print(defs) print("Checking job creation: .ecf -> .job0") print(defs.check_job_creation()) print("Saving definition to file 'test.def'") defs.save_as_defs(str(Path(home, "test.def"))) # To restore the definition from file 'test.def' we can use: # restored_defs = ecflow.Defs("test.def")
import os from pathlib import Path from ecflow import Defs, Suite, Task, Edit print("Creating suite definition") home = os.path.abspath(Path(Path(__file__).parent, "../../../build/course")) defs = Defs(Suite('test', Edit(ECF_HOME=home), Task('t1'))) print(defs)
import os from pathlib import Path from ecflow import Defs, Suite, Task, Edit print("Creating suite definition") home = os.path.abspath(Path(Path(__file__).parent, "../../../build/course")) defs = Defs(Suite('test', Edit(ECF_HOME=home), Task('t1'))) print(defs) print("Checking job creation: .ecf -> .job0") print(defs.check_job_creation()) print("Saving definition to file 'test.def'") defs.save_as_defs(str(Path(home, "test.def"))) # To restore the definition from file 'test.def' we can use: # restored_defs = ecflow.Defs("test.def")
#!/usr/bin/env python from __future__ import print_function import os import ecflow from ecflow import Client, Defs # When no arguments is specified, Client uses bash variables ECF_HOST, ECF_PORT HOST = os.getenv("ECF_HOST", "localhost") PORT = int(os.getenv("ECF_PORT", "%d" % (1500 + os.getuid()))) NAME = os.getenv("SUITE", "elearning") # ecflow_start.sh gives port number 1500+uid: CLIENT = Client(HOST + ":%d" % PORT) # multiple ways to create a client: # python -c "import ecflow; help(ecflow.Client)" ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server") + "/" try: CLIENT.ping() except RuntimeError as err: print("#ERR: ping failed: " + str(err)) ECF_HOME = os.path.join(os.getenv("HOME"), "ecflow_server") DEFS = ECF_HOME + "/%s.def" % NAME try: # read definition from disk and load into the server: CLIENT.load("%s.def" % ECF_HOME + NAME) except RuntimeError as err: CLIENT.replace("/%s" % NAME, ECF_HOME + "%s.def" % NAME) DEBUG = True # DEBUG = False if DEBUG: print("Checking job creation: .ecf -> .job0") print(Defs(DEFS).check_job_creation())
ensemble_family.add_variable("EXEC_DIR", '/home/michael/execute') ensemble_family.add_variable("SUBPROCESS_DIR", '/home/michael/subprocess_logs') ensemble_family += [Task(f"ens_member_52").add_variable("JOB_INDEX", 0)] ensemble_family += [ Task(f"ens_member_{j}").add_variable( "JOB_INDEX", 52 - j).add_trigger(f"ens_member_{j + 1} == complete") for j in reversed(range(1, 52)) ] return ensemble_family print("Creating suite definition") home = os.path.join(os.getenv("HOME"), "host_share", "rapid_run", "ecflow") defs = Defs() suite = defs.add_suite('run_rapid') suite.add_variable("ECF_INCLUDE", home) suite.add_variable("ECF_FILES", os.path.join(home, 'run_rapid')) suite.add_variable("ECF_HOME", home) prep_task = suite.add_task('prep_task') prep_task.add_variable("PYSCRIPT", os.path.join(home, 'iprep_ecf.py')) prep_task.add_variable("IO_LOCATION", "/home/michael/host_share/japan-io") prep_task.add_variable("RUNOFF_LOCATION", "/home/michael/host_share/ecmwf") suite += create_ensemble_family() plain_table_task = suite.add_task('plain_table_task') plain_table_task.add_trigger("ensemble_family == complete") plain_table_task.add_variable("PYSCRIPT",
import os from pathlib import Path from ecflow import Defs, Suite, Task, Edit print("Creating suite definition") home = os.path.abspath(Path(Path(__file__).parent, "../../../build/course")) defs = Defs(Suite('test', Edit(ECF_HOME=home), Task('t1'))) print(defs) print("Checking job creation: .ecf -> .job0") print(defs.check_job_creation()) # We can assert, so that we only progress once job creation works # assert len(defs.check_job_creation()) == 0, "Job generation failed"