"""Lambda correction_stage function module.""" from datetime import datetime from lambdacommon.common_config import logger import sentry_sdk from sentry_sdk.integrations.aws_lambda import AwsLambdaIntegration from snowflake_connector.etl_connector import SnowflakeSQLExecutor import config from correction_stage.processor import CorrectionStageProcessor if config.SENTRY_DSN: sentry_sdk.init( dsn=config.SENTRY_DSN, environment=config.ENVIRONMENT, integrations=[AwsLambdaIntegration(timeout_warning=True)] ) def handler(event, context): """Lambda entry point.""" try: # write your code here with SnowflakeSQLExecutor(config.SNOWFLAKE_CONFIG) as sf_executor: processor = CorrectionStageProcessor(event, sf_executor) start_time = datetime.now() processor.process() end_time = datetime.now() diff = end_time - start_time logger.info(f'Finished processing in {diff}') except Exception as e: logger.exception(str(e)) raise e return {'status': 'OK'}