"""Update mechanical run's action status to error.""" from lib import constants from lib.utils import ows from tasks.accounting_period_mechanicals import helpers def notify_failure_task(dag_run, **kwargs): """Update mechanical run's action state to 'error'.""" event = helpers.get_event_from_params(dag_run, **kwargs) mechanical_action = helpers.get_mechanical_deduction_state(event.target_id) ows.update_abacus_state( mechanical_action['abacus_state_id'], body=dict( action_status=constants.ABACUS_STATE_STATUSES.ERROR ) )