Skip to content

Commit

Permalink
Added inline comment to hook purpose and fixed style issue with unuse…
Browse files Browse the repository at this point in the history
…d dictionary key.
  • Loading branch information
bjeffries committed Dec 18, 2024
1 parent 0afaf2a commit 9654088
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/api/v2/managers/operation_api_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ async def create_potential_link(self, operation_id: str, data: dict, access: Bas
raise JsonHttpBadRequest(f'Agent {agent.paw} missing specified executor')
executor = self.build_executor(data=data.pop('executor', {}), agent=agent)
ability = self.build_ability(data=data.pop('ability', {}), executor=executor)
for hook, fcall in executor.HOOKS.items():
"""This dictionary provides plugins a way to hook into abilities at runtime"""
for _hook, fcall in executor.HOOKS.items():
await fcall(ability, executor)
encoded_command = self._encode_string(agent.replace(self._encode_string(data['executor']['command']),
file_svc=self.services['file_svc']))
file_svc=self.services['file_svc']))
link = Link.load(dict(command=encoded_command, plaintext_command=encoded_command, paw=agent.paw, ability=ability, executor=executor,
status=operation.link_status(), score=data.get('score', 0), jitter=data.get('jitter', 0),
cleanup=data.get('cleanup', 0), pin=data.get('pin', 0),
Expand Down
4 changes: 2 additions & 2 deletions app/service/planning_svc.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,8 @@ async def _generate_new_links(self, operation, agent, abilities, link_status):
executor = await agent.get_preferred_executor(ability)
if not executor:
continue

for hook, fcall in executor.HOOKS.items():
"""This dictionary provides plugins a way to hook into abilities at runtime"""
for _hook, fcall in executor.HOOKS.items():
await fcall(ability, executor)
if executor.command:
link = Link.load(dict(command=self.encode_string(executor.test), paw=agent.paw, score=0,
Expand Down

0 comments on commit 9654088

Please sign in to comment.