In command_functions.py there is duplication of setting up an ecflow server from a config object. In addition is also the server object construction in https://github.com/ACCORD-NWP/tactus/blob/develop/tactus/scheduler.py#L86 also using the configuration. It should be combined to one object using the tactus configuration.
command_functions.py
tactus_home = set_tactus_home(config, args.tactus_home)
config = config.copy(update={"platform": {"tactus_home": tactus_home}})
config = config.copy(update=set_times(config))
platform = Platform(config)
ecfvars = {
key: platform.substitute(val) for key, val in config["scheduler.ecfvars"].items()
}
update = {"scheduler": {"ecfvars": ecfvars}}
config = config.copy(update=update)
logger.info("Starting suite...")
logger.info("Config file: {}", args.config_file)
logger.info("Ecflow settings: ")
# Assign Ecfvars
joboutdir = config["scheduler.ecfvars.ecf_jobout"]
ecf_files = config["scheduler.ecfvars.ecf_files"]
ecf_files_remotely = config["scheduler.ecfvars.ecf_files_remotely"]
ecf_home = config["scheduler.ecfvars.ecf_home"]
ecf_host = config["scheduler.ecfvars.ecf_host"]
ecf_port = config["scheduler.ecfvars.ecf_port"]
ecf_user = config["scheduler.ecfvars.ecf_user"]
ecf_remoteuser = config["scheduler.ecfvars.ecf_remoteuser"]
suite_def = config.get("suite_control.suite_definition", "TactusSuiteDefinition")
logger.info("ecf_host: {}", ecf_host)
logger.info("ecf_jobout: {}", joboutdir)
logger.info("ecf_files: {}", ecf_files)
logger.info("ecf_files_remotely: {}", ecf_files_remotely)
logger.info("ecf_home: {}", ecf_home)
logger.info("ecf_user: {}", ecf_user)
logger.info("ecf_remoteuser: {}", ecf_remoteuser)
logger.info("suite definition: {}", suite_def)
os.environ["ECF_HOST"] = ecf_host
os.environ["ECF_PORT"] = str(ecf_port)
if ecf_user:
os.environ["ECF_USER"] = ecf_user
server = EcflowServer(config, start_command=args.start_command)
scheduler.py:
class EcflowServer(Server):
"""Ecflow server."""
def __init__(self, config, start_command=None):
"""Construct the EcflowServer.
The values for ecf_host and ecf_port are taken from config as
strings/integer or the two functions _select_host_from_list()
or _set_port_from_user() defined below.
Args:
config (str): configuration settings.
start_command (str): Ecflow start server command.
Raises:
ModuleNotFoundError: If ecflow is not found.
RuntimeError: If ecf_port is not set
"""
if ecflow is None:
raise ModuleNotFoundError("Ecflow not found")
Server.__init__(self, config)
platform = Platform(config)
ecf_host = self.config["scheduler.ecfvars.ecf_host"]
ecf_host = platform.substitute(ecf_host)
self.ecf_host = platform.evaluate(ecf_host, object_=SelectHost)
ecf_port = self.config["scheduler.ecfvars.ecf_port"]
try:
self.ecf_port = int(ecf_port)
except ValueError:
ecf_port = platform.substitute(ecf_port)
self.ecf_port = platform.evaluate(ecf_port, object_=EcflowServer)
self.start_command = start_command
logger.debug("self.ecf_host={} self.ecf_port={}", self.ecf_host, self.ecf_port)
self.ecf_client = ecflow.Client(self.ecf_host, self.ecf_port)
logger.debug("self.ecf_client {}", self.ecf_client)
self.settings = {"ECF_HOST": self.ecf_host, "ECF_PORT": self.ecf_port}
In command_functions.py there is duplication of setting up an ecflow server from a config object. In addition is also the server object construction in https://github.com/ACCORD-NWP/tactus/blob/develop/tactus/scheduler.py#L86 also using the configuration. It should be combined to one object using the tactus configuration.
command_functions.py
scheduler.py: