diff --git a/coordinator/Processor.py b/coordinator/Processor.py index c5c2558a4335b3383e66591deb1ded89c4f12aa2..c65cbf6a94f60df0085019b6cf0dc70d375bae37 100755 --- a/coordinator/Processor.py +++ b/coordinator/Processor.py @@ -54,10 +54,10 @@ class Processor: __metaclass__ = ABCMeta - logger = None + ### CLASS LEVEL VARIABLES - WILL BE SHARED BY ALL INSTANCES OF THIS CLASS log_path_default = None loglevels = None - todayString = None + #### def __init__(self) -> None: @@ -408,7 +408,7 @@ class Processor: return universal_config - def run_Process(self, args: dict): + def run_process(self, args: dict): # check initial state of each config file, and gather terms that must apply # across all provided configs @@ -632,20 +632,19 @@ class Processor: raise NotImplementedError -if __name__ == '__main__': - print("Make sure to `conda activate py3EWSepi` environment!") - print("Make sure that flagdir package is available (on PYTHONPATH)") - processor = Processor() - try: - processor.logger.info("==========") - processor.logger.info(f"Logging started at {datetime.datetime.now().strftime('%Y %b %d %H:%M:%S')}") - # load configurations - args_dict: dict = processor.parse_and_check_args() - processor.set_log_level(args_dict['log_level']) - processor.run_Process(args_dict) - except SystemExit as e: - print("caught with code " + str(e.code)) - processor.logger.info('run_process() exited') - sys.exit(e.code) - except: - processor.logger.exception('Uncaught exception in run_Process:') + def run_processor(self): + print("Make sure to `conda activate py3EWSepi` environment!") + print("Make sure that flagdir package is available (on PYTHONPATH)") + try: + self.logger.info("==========") + 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() + self.set_log_level(args_dict['log_level']) + self.run_process(args_dict) + except SystemExit as e: + print("caught with code " + str(e.code)) + self.logger.info('run_process() exited') + sys.exit(e.code) + except: + self.logger.exception('Uncaught exception in run_Process:') diff --git a/coordinator/ProcessorDeposition.py b/coordinator/ProcessorDeposition.py index 1adfa69f441ccd939d5746211e63cc98e07434b9..6a93c1ce1d880b3614a66ba4ec6dac51f15e37e8 100644 --- a/coordinator/ProcessorDeposition.py +++ b/coordinator/ProcessorDeposition.py @@ -181,5 +181,4 @@ class ProcessorDeposition(Processor): if __name__ == '__main__': processor = ProcessorDeposition() - args_dict: dict = processor.parse_and_check_args() - processor.run_Process(args_dict) + processor.run_processor() diff --git a/tests/integration/full/full_test_advisory.py b/tests/integration/full/full_test_advisory.py index 372e5526326e6a7be894518de364ea74b4379088..c2530ad46b677926861b601ab2191301fcc15a1a 100644 --- a/tests/integration/full/full_test_advisory.py +++ b/tests/integration/full/full_test_advisory.py @@ -2,6 +2,8 @@ import copy import os import sys +from ProcessorAdvisory import ProcessorAdvisory +from ProcessorDeposition import ProcessorDeposition from integration.partial.integration_test_utils import IntegrationTestUtils from integration.test_suites.advisory_test_suite import BaseAdvisoryTestSuite @@ -56,24 +58,35 @@ class FullTestAdvisory(BaseAdvisoryTestSuite.AdvisoryTestSuite): @staticmethod def run_dependent_pipelines(): + # need EMAIL_CRED in the environment before we import Processor + os.environ["EMAIL_CRED"] = IntegrationTestUtils.EMAIL_CRED_PATH + + depo_processor = ProcessorDeposition() IntegrationTestUtils.run_external_pipeline("Deposition", IntegrationTestUtils.TEST_START_DATE, - IntegrationTestUtils.EMAIL_CRED_PATH) + depo_processor) + + env_processor = ProcessorDeposition() IntegrationTestUtils.run_external_pipeline("Environment", IntegrationTestUtils.TEST_START_DATE, - IntegrationTestUtils.EMAIL_CRED_PATH) + env_processor) + survey_processor = ProcessorDeposition() previous_day_string: str = IntegrationTestUtils.get_day_before_as_string(IntegrationTestUtils.TEST_START_DATE) IntegrationTestUtils.run_external_pipeline("Survey", previous_day_string, - IntegrationTestUtils.EMAIL_CRED_PATH) + survey_processor) pass @staticmethod def run_advisory_pipeline(): + # need EMAIL_CRED in the environment before we import Processor + os.environ["EMAIL_CRED"] = IntegrationTestUtils.EMAIL_CRED_PATH + + advisory_processor = ProcessorAdvisory() IntegrationTestUtils.run_external_pipeline(BaseAdvisoryTestSuite.AdvisoryTestSuite.ADVISORY_COMPONENT_NAME, IntegrationTestUtils.TEST_START_DATE, - IntegrationTestUtils.EMAIL_CRED_PATH) + advisory_processor) if __name__ == '__main__': diff --git a/tests/integration/full/full_test_deposition.py b/tests/integration/full/full_test_deposition.py index 0402e79d1200a94170b67da7453e114efae3801c..c594f51e59fc820823d0419b8beef6401de731ff 100644 --- a/tests/integration/full/full_test_deposition.py +++ b/tests/integration/full/full_test_deposition.py @@ -2,6 +2,7 @@ import copy import os import sys +from ProcessorDeposition import ProcessorDeposition from integration.partial.integration_test_utils import IntegrationTestUtils from integration.test_suites.depo_test_suite import BaseDepoTestSuite @@ -45,9 +46,12 @@ class FullTestDeposition(BaseDepoTestSuite.DepoTestSuite): @staticmethod def run_depo_pipeline(): + # need EMAIL_CRED in the environment before we import Processor + os.environ["EMAIL_CRED"] = IntegrationTestUtils.EMAIL_CRED_PATH + depo_processor = ProcessorDeposition() IntegrationTestUtils.run_external_pipeline(BaseDepoTestSuite.DepoTestSuite.DEPO_COMPONENT_NAME, IntegrationTestUtils.TEST_START_DATE, - IntegrationTestUtils.EMAIL_CRED_PATH) + depo_processor) if __name__ == '__main__': diff --git a/tests/integration/full/full_test_env_suit.py b/tests/integration/full/full_test_env_suit.py index aa4d5cbb60db37bda46d858db4503a7c34e1af4c..d6a9f390e44fb159e777dafd4d55c63e51bf3591 100644 --- a/tests/integration/full/full_test_env_suit.py +++ b/tests/integration/full/full_test_env_suit.py @@ -2,6 +2,7 @@ import copy import os import sys +from ProcessorEnvironment import ProcessorEnvironment from integration.partial.integration_test_utils import IntegrationTestUtils from integration.test_suites.env_suit_test_suite import BaseEnvSuitTestSuite @@ -46,9 +47,12 @@ class FullTestEnvSuit(BaseEnvSuitTestSuite.EnvSuitTestSuite): @staticmethod def run_env_pipeline(): + # need EMAIL_CRED in the environment before we import Processor + os.environ["EMAIL_CRED"] = IntegrationTestUtils.EMAIL_CRED_PATH + env_processor = ProcessorEnvironment() IntegrationTestUtils.run_external_pipeline(BaseEnvSuitTestSuite.EnvSuitTestSuite.ENV_COMPONENT_NAME, IntegrationTestUtils.TEST_START_DATE, - IntegrationTestUtils.EMAIL_CRED_PATH) + env_processor) if __name__ == '__main__': _success: bool = IntegrationTestUtils.run_full_integration_test_pipeline(FullTestEnvSuit, diff --git a/tests/integration/full/full_test_epi.py b/tests/integration/full/full_test_epi.py index 71561f282fa9f6621a04cc29addac584e574eef8..76fef605a20030f1665314cc110a94f6766a430f 100644 --- a/tests/integration/full/full_test_epi.py +++ b/tests/integration/full/full_test_epi.py @@ -2,6 +2,8 @@ import copy import os import sys +from ProcessorDeposition import ProcessorDeposition +from ProcessorEnvironment import ProcessorEnvironment from integration.partial.integration_test_utils import IntegrationTestUtils from integration.test_suites.epi_test_suite import BaseEpiTestSuite @@ -57,17 +59,18 @@ class FullTestEpi(BaseEpiTestSuite.EpiTestSuite): @staticmethod def run_dependent_pipelines(): + # need EMAIL_CRED in the environment before we import Processor + os.environ["EMAIL_CRED"] = IntegrationTestUtils.EMAIL_CRED_PATH + + depo_processor = ProcessorDeposition() IntegrationTestUtils.run_external_pipeline("Deposition", IntegrationTestUtils.TEST_START_DATE, - IntegrationTestUtils.EMAIL_CRED_PATH) + depo_processor) + env_processor = ProcessorEnvironment() IntegrationTestUtils.run_external_pipeline("Environment", IntegrationTestUtils.TEST_START_DATE, - IntegrationTestUtils.EMAIL_CRED_PATH) + env_processor) - # previous_day_string: str = IntegrationTestUtils.get_day_before_as_string(IntegrationTestUtils.TEST_START_DATE) - # IntegrationTestUtils.run_external_pipeline("Survey", - # previous_day_string, - # IntegrationTestUtils.EMAIL_CRED_PATH) pass @staticmethod diff --git a/tests/integration/full/full_test_survey.py b/tests/integration/full/full_test_survey.py index 610cca52769ac4216c1d7d9bab8662874cda5d35..f38bcd7fe1bdaf9ca61b10cef778a82e5702cda3 100644 --- a/tests/integration/full/full_test_survey.py +++ b/tests/integration/full/full_test_survey.py @@ -2,6 +2,7 @@ import copy import os import sys +from ProcessorSurveys import ProcessorSurveys from integration.partial.integration_test_utils import IntegrationTestUtils from integration.test_suites.survey_test_suite import BaseSurveyTestSuite @@ -40,9 +41,13 @@ class FullTestSurvey(BaseSurveyTestSuite.SurveyTestSuite): @staticmethod def run_survey_pipeline(): + # need EMAIL_CRED in the environment before we import Processor + os.environ["EMAIL_CRED"] = IntegrationTestUtils.EMAIL_CRED_PATH + + survey_processor = ProcessorSurveys() IntegrationTestUtils.run_external_pipeline(BaseSurveyTestSuite.SurveyTestSuite.SURVEY_COMPONENT_NAME, IntegrationTestUtils.TEST_START_DATE, - IntegrationTestUtils.EMAIL_CRED_PATH) + survey_processor) if __name__ == '__main__': diff --git a/tests/integration/partial/integration_test_utils.py b/tests/integration/partial/integration_test_utils.py index c52d32f060f2925f8512962bb9d607386765382e..9903274e81c3eecb127359666ecc018a3c5dc606 100644 --- a/tests/integration/partial/integration_test_utils.py +++ b/tests/integration/partial/integration_test_utils.py @@ -201,7 +201,7 @@ class IntegrationTestUtils: processor.set_log_level(log_level) try: - processor.run_Process(args_dict) + processor.run_process(args_dict) except SystemExit: # we will eventually want to throw these to the calling class to be dealt with pass @@ -209,14 +209,9 @@ class IntegrationTestUtils: @staticmethod def run_external_pipeline(component: str, start_date: str, - email_cred_path: str, + processor: Processor, **kwargs): - # need EMAIL_CRED in the environment before we import Processor - os.environ["EMAIL_CRED"] = email_cred_path - - processor = ProcessorDeposition() - args_dict: dict = {} # note, possible to override these values in the kwargs loop below @@ -235,7 +230,7 @@ class IntegrationTestUtils: processor.set_log_level(log_level) try: - processor.run_Process(args_dict) + processor.run_process(args_dict) except SystemExit: # we will eventually want to throw these to the calling class to be dealt with pass