17 """!Is this task done?
18 @param task a produtil.datastore.Task
19 @returns True if the task's state is equal to
20 produtil.datastore.COMPLETED or produtil.datastore.FAILED. Will
21 return False for any other status."""
23 return state == COMPLETED
or state==FAILED
26 """!Runs the post-processor"""
28 jlogger.info(
'starting post')
32 run_copier=hwrf_expt.conf.getbool(
'config',
'post_runs_wrfcopier',
False)
33 run_satpost=hwrf_expt.conf.getbool(
'config',
'run_satpost',
True)
36 hwrf_expt.nonsatpost.state=UNSTARTED
37 hwrf_expt.satpost.state=UNSTARTED
40 hwrf_expt.wrfcopier.state=UNSTARTED
42 logger=logging.getLogger(
'exhwrf_post')
45 with
NamedDir(hwrf_expt.WORKhwrf,logger=logger)
as t:
49 before=int(time.time())
51 if not done(hwrf_expt.wrfcopier):
52 hwrf_expt.wrfcopier.runpart()
53 if not done(hwrf_expt.nonsatpost): hwrf_expt.nonsatpost.runpart()
54 if not done(hwrf_expt.nonsatpost): hwrf_expt.nonsatpost.runpart()
56 if not done(hwrf_expt.satpost): hwrf_expt.satpost.runpart()
57 if not done(hwrf_expt.nonsatpost): hwrf_expt.nonsatpost.runpart()
58 alldone = (
done(hwrf_expt.satpost)
or not run_satpost ) \
59 and done(hwrf_expt.nonsatpost) \
60 and (
not run_copier
or done(hwrf_expt.wrfcopier) )
61 after=int(time.time())
67 'Post loop iteration took only %d seconds, which is '
68 'less than the threshold of %d seconds. Will sleep '
69 '%d seconds.'%(took,threshold,sleeptime))
72 logger.info(
'Post loop iteration took %d seconds, '
73 'which is above the threshold of %d. '
74 'Sleeping only one second.'%(took,threshold))
76 logger.info(
'Done sleeping.')
78 jlogger.info(
'completed post')
80 if __name__==
'__main__':
Change directory, handle temporary directories.
Contains setup(), which initializes the produtil package.
def done(task)
Is this task done?
Sets up signal handlers to ensure a clean exit.
def init_module
Initializes the HWRF object structure.
def setup(ignore_hup=False, dbnalert_logger=None, jobname=None, cluster=None, send_dbn=None, thread_logger=False, thread_stack=2 **24, kwargs)
Initializes the produtil package.
Stores products and tasks in an sqlite3 database file.
This subclass of TempDir takes a directory name, instead of generating one automatically.
def post()
Runs the post-processor.