diff --git a/oneflux/globals.py b/oneflux/globals.py new file mode 100644 index 00000000..69462fa9 --- /dev/null +++ b/oneflux/globals.py @@ -0,0 +1,4 @@ + +def set_exit_trigger(earlyexit): + global early_exit_flag + early_exit_flag = earlyexit \ No newline at end of file diff --git a/oneflux/pipeline/wrappers.py b/oneflux/pipeline/wrappers.py index ca273b3a..ec062c47 100644 --- a/oneflux/pipeline/wrappers.py +++ b/oneflux/pipeline/wrappers.py @@ -17,6 +17,7 @@ import numpy import socket import fnmatch +import oneflux.globals as globals from datetime import datetime @@ -260,6 +261,8 @@ def run(self): for driver in self.drivers: if driver.execute: driver.run() + if (driver == self.ustar_cp) and globals.early_exit_flag: + sys.exit("Exiting after ustar_cp calculation") self.post_validate() except Exception as e: diff --git a/runoneflux.py b/runoneflux.py index 5fcbc03a..3491180b 100644 --- a/runoneflux.py +++ b/runoneflux.py @@ -15,6 +15,7 @@ import logging import argparse import traceback +from oneflux import globals from oneflux import ONEFluxError, log_config, log_trace, VERSION_PROCESSING, VERSION_METADATA from oneflux.tools.partition_nt import run_partition_nt, PROD_TO_COMPARE, PERC_TO_COMPARE @@ -49,6 +50,7 @@ parser.add_argument('--versiond', help="Version of data (hardcoded default)", type=str, dest='versiond', default=str(VERSION_METADATA)) parser.add_argument('--era-fy', help="ERA first year of data (default {y})".format(y=ERA_FIRST_YEAR), type=int, dest='erafy', default=int(ERA_FIRST_YEAR)) parser.add_argument('--era-ly', help="ERA last year of data (default {y})".format(y=ERA_LAST_YEAR), type=int, dest='eraly', default=int(ERA_LAST_YEAR)) + parser.add_argument('--earlyexit', help="Trigger to exit run after ustarcp calculations are complete (default = False)", type = bool, default = False) args = parser.parse_args() # setup logging file and stdout @@ -84,6 +86,9 @@ print os.path.join(args.datadir, args.sitedir) if not os.path.isdir(os.path.join(args.datadir, args.sitedir)): raise ONEFluxError("Site dir not found: {d}".format(d=args.sitedir)) + + #set exit trigger flag + globals.set_exit_trigger(args.earlyexit) # run command log.info("Starting execution: {c}".format(c=args.command))