Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added post ustar_cp sys.exit() #8

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions oneflux/globals.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

def set_exit_trigger(earlyexit):
global early_exit_flag
early_exit_flag = earlyexit
3 changes: 3 additions & 0 deletions oneflux/pipeline/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import numpy
import socket
import fnmatch
import oneflux.globals as globals

from datetime import datetime

Expand Down Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions runoneflux.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down