"""Invoke abacus adjustments apply lambda task method.""" from hooks.lambda_hook import OrchLambdaHook from lib import config from tasks.apply_adjustments.helpers import get_event_from_params def invoke_abacus_adjustments_apply_lambda_task(dag_run, *arg, **kwargs): """Invoke lambda to apply pending adjustments.""" event = get_event_from_params(dag_run, **kwargs) if config.OWS_ENV.lower() == 'qa': hook = OrchLambdaHook(config.ADJUSTMENTS_APPLY_LAMBDA_NAME, aws_conn_id='accounting_qa') else: hook = OrchLambdaHook(config.ADJUSTMENTS_APPLY_LAMBDA_NAME) response = hook.invoke_lambda(event.to_json()) if not response.function_response.succeeded: raise Exception(response.error_message)