diff --git a/app/api/v2/managers/operation_api_manager.py b/app/api/v2/managers/operation_api_manager.py index 368661f8e..d5eece127 100644 --- a/app/api/v2/managers/operation_api_manager.py +++ b/app/api/v2/managers/operation_api_manager.py @@ -87,6 +87,8 @@ async def update_operation_link(self, operation_id: str, link_id: str, link_data if not link.is_valid_status(link_status): raise JsonHttpBadRequest(f'Cannot update link {link_id} due to invalid link status.') link.status = link_status + if link.can_ignore(): + operation.add_ignored_link(link.id) return link.display async def create_potential_link(self, operation_id: str, data: dict, access: BaseWorld.Access): diff --git a/app/objects/c_operation.py b/app/objects/c_operation.py index 647a3437e..579824725 100644 --- a/app/objects/c_operation.py +++ b/app/objects/c_operation.py @@ -234,7 +234,7 @@ async def wait_for_links_completion(self, link_ids): for link_id in link_ids: link = [link for link in self.chain if link.id == link_id][0] if link.can_ignore(): - self.ignored_links.add(link.id) + self.add_ignored_link(link.id) member = [member for member in self.agents if member.paw == link.paw][0] while not (link.finish or link.can_ignore()): await asyncio.sleep(5) @@ -256,6 +256,9 @@ async def is_finished(self): def link_status(self): return -3 if self.autonomous else -1 + def add_ignored_link(self, link_id): + self.ignored_links.add(link_id) + async def active_agents(self): active = [] for agent in self.agents: @@ -272,7 +275,7 @@ async def get_skipped_abilities_by_agent(self, data_svc): for agent in self.agents: agent_skipped = defaultdict(dict) agent_executors = agent.executors - agent_ran = set([link.ability.ability_id for link in self.chain if link.paw == agent.paw]) + agent_ran = set([link.ability.ability_id for link in self.chain if link.paw == agent.paw and link.finish]) for ab in abilities_by_agent[agent.paw]['all_abilities']: skipped = self._check_reason_skipped(agent=agent, ability=ab, agent_executors=agent_executors, op_facts=[f.trait for f in await self.all_facts()], @@ -437,9 +440,11 @@ async def _unfinished_links_for_agent(self, paw): return [link for link in self.chain if link.paw == paw and not link.finish and not link.can_ignore()] async def _get_all_possible_abilities_by_agent(self, data_svc): - abilities = {'all_abilities': [ab for ab_id in self.adversary.atomic_ordering - for ab in await data_svc.locate('abilities', match=dict(ability_id=ab_id))]} - return {a.paw: abilities for a in self.agents} + abilities_by_agent = {a.paw: {'all_abilities': []} for a in self.agents} + for link in self.chain: + matching_abilities = await data_svc.locate('abilities', match=dict(ability_id=link.ability.ability_id)) + abilities_by_agent[link.paw]['all_abilities'].extend(matching_abilities) + return abilities_by_agent def _check_reason_skipped(self, agent, ability, op_facts, state, agent_executors, agent_ran): if ability.ability_id in agent_ran: