Skip to content

Commit

Permalink
Added --time option to fre pp wrapper, and standalone fre pp trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Blanton authored and Chris Blanton committed Nov 26, 2024
1 parent 01023ef commit bdfa7f5
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
29 changes: 26 additions & 3 deletions fre/pp/frepp.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from .validate import _validate_subtool
from .install import install_subtool
from .run import pp_run_subtool
from .trigger import _trigger
from .status import status_subtool
from .wrapper import runFre2pp

Expand Down Expand Up @@ -187,21 +188,43 @@ def configure_xml(context, xml, platform, target, experiment, do_analysis, histo
@click.option("-p", "--platform", type=str,
help="Platform name",
required=True)
@click.option("-t", "--target", type=str,
@click.option("-T", "--target", type=str,
help="Target name",
required=True)
@click.option("-c", "--config-file", type=str,
help="Path to a configuration file in either XML or YAML",
required=True)
@click.option("-t", "--time",
required=False,
help="Time whose history files are ready")
@click.option("-b", "--branch",
show_default=True,
required=False,
help="fre-workflows branch/tag to clone; default is $(fre --version)")
@click.pass_context
def wrapper(context, experiment, platform, target, config_file, branch=None):
def wrapper(context, experiment, platform, target, config_file, time=None, branch=None):
# pylint: disable=unused-argument
""" - Execute fre pp steps in order """
context.forward(runFre2pp)

@pp_cli.command()
@click.option("-e", "--experiment", type=str,
help="Experiment name",
required=True)
@click.option("-p", "--platform", type=str,
help="Platform name",
required=True)
@click.option("-T", "--target", type=str,
help="Target name",
required=True)
@click.option("-t", "--time",
required=True,
help="Time whose history files are ready")
@click.pass_context
def trigger(context, experiment, platform, target, time):
# pylint: disable=unused-argument
""" - Start postprocessing for a particular time """
context.forward(_trigger)

if __name__ == "__main__":
''' entry point for click to fre pp commands '''
pp_cli()
20 changes: 20 additions & 0 deletions fre/pp/trigger.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
''' fre pp trigger '''

import subprocess
import click

def trigger(experiment, platform, target, time):
"""
Trigger the pp-starter task for the time indicated
"""

name = experiment + '__' + platform + '__' + target
cmd = f"cylc trigger {name}//{time}/pp-starter"
subprocess.run(cmd, shell=True, check=True, timeout=30)


@click.command()
def _trigger(experiment, platform, target, time):
''' entry point to trigger for click '''
return trigger(experiment, platform, target, time)
7 changes: 5 additions & 2 deletions fre/pp/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
from .configure_script_yaml import yamlInfo
from .install import install_subtool
from .run import pp_run_subtool
from .trigger import trigger
from .status import status_subtool

@click.command()
def runFre2pp(experiment, platform, target, config_file, branch):
def runFre2pp(experiment, platform, target, config_file, branch, time):
'''
Wrapper script for calling a FRE2 pp experiment with the canopy-style
infrastructure and fre-cli
time=0000
'''

config_file = os.path.abspath(config_file)
Expand All @@ -40,6 +40,9 @@ def runFre2pp(experiment, platform, target, config_file, branch):

pp_run_subtool(experiment, platform, target)

if time:
trigger(experiment, platform, target, time)

status_subtool(experiment, platform, target)

if __name__ == '__main__':
Expand Down

0 comments on commit bdfa7f5

Please sign in to comment.