"""Update close_period accounting_period status.""" from lib import constants from lib.utils import ows from lib.utils.helpers import get_accounting_period_state from tasks.accounting_period_close.helpers import get_event_from_params def update_abacus_state_task(dag_run: dict, action_status: str, **kwargs): """Update accounting period 'close_period' status. Args: dag_run (dict): config of the DAG this task belongs to action_status (str): one of 'running', 'complete', or 'error' kwargs (dict): any other optional arguments` """ event = get_event_from_params(dag_run, **kwargs) close_period_action = get_accounting_period_state( event.target_id, constants.ACCOUNTING_PERIOD_ACTIONS.CLOSE_PERIOD ) ows.update_abacus_state( close_period_action['abacus_state_id'], body={'action_status': action_status} )