Skip to content

Commit 5e56e9c

Browse files
authored
Merge pull request #321 from stratosphereips/add-user-documentation
Add user documentation
2 parents 80a1acc + f3140cc commit 5e56e9c

File tree

12 files changed

+996
-60
lines changed

12 files changed

+996
-60
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Deploy MkDocs site to GitHub Pages
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repo
14+
uses: actions/checkout@v3
15+
16+
- name: Set up Python
17+
uses: actions/setup-python@v4
18+
with:
19+
python-version: '3.12'
20+
21+
- name: Install dependencies
22+
run: |
23+
python -m pip install --upgrade pip
24+
pip install mkdocs-material mkdocstrings pymdown-extensions
25+
26+
- name: Build MkDocs site
27+
run: mkdocs build --strict
28+
29+
- name: Deploy to GitHub Pages
30+
uses: peaceiris/actions-gh-pages@v4
31+
with:
32+
github_token: ${{ secrets.GITHUB_TOKEN }}
33+
publish_dir: ./site

AIDojoCoordinator/coordinator.py

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,24 @@
1414

1515
class AgentServer(asyncio.Protocol):
1616
"""
17-
Class used for serving the agents when conneting to the game run by th GameCoordinator.
17+
Class used for serving the agents when connecting to the game run by the GameCoordinator.
18+
19+
Attributes:
20+
actions_queue (asyncio.Queue): Queue for actions from agents.
21+
answers_queues (dict): Mapping of agent addresses to their response queues.
22+
max_connections (int): Maximum allowed concurrent agent connections.
23+
current_connections (int): Current number of connected agents.
24+
logger (logging.Logger): Logger for the AgentServer.
1825
"""
1926
def __init__(self, actions_queue, agent_response_queues, max_connections):
27+
"""
28+
Initialize the AgentServer.
29+
30+
Args:
31+
actions_queue (asyncio.Queue): Queue for actions from agents.
32+
agent_response_queues (dict): Mapping of agent addresses to their response queues.
33+
max_connections (int): Maximum allowed concurrent agent connections.
34+
"""
2035
self.actions_queue = actions_queue
2136
self.answers_queues = agent_response_queues
2237
self.max_connections = max_connections
@@ -26,6 +41,9 @@ def __init__(self, actions_queue, agent_response_queues, max_connections):
2641
async def handle_agent_quit(self, peername:tuple):
2742
"""
2843
Helper function to handle agent disconnection.
44+
45+
Args:
46+
peername (tuple): The address of the disconnecting agent.
2947
"""
3048
# Send a quit message to the Coordinator
3149
self.logger.info(f"\tHandling agent quit for {peername}.")
@@ -35,6 +53,10 @@ async def handle_agent_quit(self, peername:tuple):
3553
async def handle_new_agent(self, reader, writer):
3654
"""
3755
Handle a new agent connection.
56+
57+
Args:
58+
reader (asyncio.StreamReader): Stream reader for the agent.
59+
writer (asyncio.StreamWriter): Stream writer for the agent.
3860
"""
3961
# get the peername of the writer
4062
peername = writer.get_extra_info("peername")
@@ -102,6 +124,13 @@ async def handle_new_agent(self, reader, writer):
102124
# swallow exceptions on close to avoid crash on cleanup
103125
pass
104126
async def __call__(self, reader, writer):
127+
"""
128+
Allow the server instance to be called as a coroutine.
129+
130+
Args:
131+
reader (asyncio.StreamReader): Stream reader for the agent.
132+
writer (asyncio.StreamWriter): Stream writer for the agent.
133+
"""
105134
await self.handle_new_agent(reader, writer)
106135

107136
class GameCoordinator:

0 commit comments

Comments
 (0)