FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit cdc5c41a authored by L. Bower's avatar L. Bower
Browse files

adding main functions to all the processor components (except the scraper)

parent 870b48af
No related branches found
No related tags found
No related merge requests found
......@@ -255,14 +255,14 @@ class Processor:
# positional arguments do not start with - or -- and are always required
# optional arguments start with - or -- and default is required = False
my_parser.add_argument(
'-p', '--component',
type = str,
choices = list(short_name.keys()),
required = True,
dest = 'component',
help = '''Name of EWS component to process, which must be present
in the config file.''')
# my_parser.add_argument(
# '-p', '--component',
# type = str,
# choices = list(short_name.keys()),
# required = True,
# dest = 'component',
# help = '''Name of EWS component to process, which must be present
# in the config file.''')
my_parser.add_argument(
'-c', '--config',
......@@ -365,9 +365,9 @@ class Processor:
if not universal_config:
universal_config = {
'WorkspacePathout': set(),
'ProcessPreJob': set(),
'ProcessInJob': set(),
'ProcessEWSPlotting': set(),
# 'ProcessPreJob': set(),
# 'ProcessInJob': set(),
# 'ProcessEWSPlotting': set(),
'ServerPath': set(),
'ServerName': set(),
'ServerKey': set()}
......@@ -517,11 +517,11 @@ class Processor:
with open(f"{jobPath}/{configFileName}.json", 'w') as write_file:
json.dump(configjson, write_file, indent = 4)
proc_description = universal_config['ProcessInJob']
# proc_description = universal_config['ProcessInJob']
try:
proc_out = self.process_in_job(jobPath, status, configjson, component)
except:
self.logger.exception(f"Some error in {proc_description}()")
self.logger.exception(f"Error in process_in_job")
status.reset('ERROR')
endJob(status, premature = True)
......@@ -632,7 +632,7 @@ class Processor:
raise NotImplementedError
def run_processor(self):
def run_processor(self, component: str):
print("Make sure to `conda activate py3EWSepi` environment!")
print("Make sure that flagdir package is available (on PYTHONPATH)")
try:
......@@ -640,6 +640,7 @@ class Processor:
self.logger.info(f"Logging started at {datetime.datetime.now().strftime('%Y %b %d %H:%M:%S')}")
# load configurations
args_dict: dict = self.parse_and_check_args()
args_dict["component"] = component
self.set_log_level(args_dict['log_level'])
self.run_process(args_dict)
except SystemExit as e:
......
......@@ -65,3 +65,8 @@ class ProcessorAdvisory(Processor):
proc_out['clearup'] = None
return proc_out
if __name__ == '__main__':
processor = ProcessorAdvisory()
processor.run_processor("Advisory")
\ No newline at end of file
......@@ -22,6 +22,8 @@ from ews_postprocessing.deposition.deposition_post_processor import DepositionPo
class ProcessorDeposition(Processor):
""" LIFECYCLE FUNCTIONS INHERITED FROM PROCESSOR.PY """
def process_pre_job(self, args):
return process_pre_job_server_download(args)
......@@ -39,6 +41,7 @@ class ProcessorDeposition(Processor):
logger = logging.getLogger('Processor.Deposition')
add_filters_to_sublogger(logger)
""" LIFECYCLE FUNCTIONS INHERITED FROM PROCESSOR.PY """
def process_in_job_dep(self, jobPath, status, config, component):
self.logger.info('started process_in_job_dep()')
......@@ -181,4 +184,4 @@ class ProcessorDeposition(Processor):
if __name__ == '__main__':
processor = ProcessorDeposition()
processor.run_processor()
processor.run_processor("Deposition")
......@@ -237,3 +237,8 @@ class ProcessorEnvironment(Processor):
EWSPlottingOutputs = sorted([file for glob_str in EWSPlottingOutputGlobs for file in glob(glob_str)])
return EWSPlottingOutputs
if __name__ == '__main__':
processor = ProcessorEnvironment()
processor.run_processor("Environment")
......@@ -831,3 +831,8 @@ class ProcessorEpidemiology(Processor):
EWSPlottingOutputs = [item for EWSPlottingOutput in EWSPlottingOutputGlobs for item in glob(EWSPlottingOutput)]
return EWSPlottingOutputs
if __name__ == '__main__':
processor = ProcessorEpidemiology()
processor.run_processor("Epidemiology")
\ No newline at end of file
......@@ -459,3 +459,8 @@ class ProcessorSurveys(Processor):
pass
return []
if __name__ == '__main__':
processor = ProcessorSurveys()
processor.run_processor("Survey")
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment