Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix warnings in sphinx docs #100

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ formats:

# Optionally set the version of Python and requirements required to build your docs
python:
version: "3.7"
version: "3.12"
install:
- requirements: docs/requirements.txt
13 changes: 4 additions & 9 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
alabaster==0.7.7
decorator==4.3.0
docopt==0.6.2
docutils==0.16
imagesize==0.7.1
Jinja2==2.9
MarkupSafe==0.23
Sphinx==4.0.2
sphinx-rtd-theme==0.5.2
-e .
sphinx-rtd-theme>=2.0.0
pika
pyzmq
6 changes: 4 additions & 2 deletions docs/source/agents-container.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
========
====================
Agents and container
========
====================

***************
mango container
Expand Down Expand Up @@ -72,6 +72,7 @@ To improve multicore utilization, mango provides a way to distribute agents to p
register the agent in a slightly different way.

.. code-block:: python3

process_handle = await main_container.as_agent_process(
agent_creator=lambda sub_container: TestAgent(
container, aid_main_agent, suggested_aid=f"process_agent1"
Expand All @@ -85,6 +86,7 @@ with the agent directly from the main process. If you want to interact with the
dispatch a task in the agent process using `dispatch_to_agent_process`.

.. code-block:: python3

main_container.dispatch_to_agent_process(
pid,
your_function, # will be called with the mirror container + x as arguments
Expand Down
8 changes: 0 additions & 8 deletions docs/source/api_ref/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,3 @@ Subpackages
mango.messages
mango.modules
mango.util

Module contents
---------------

.. automodule:: mango
:members:
:undoc-members:
:show-inheritance:
11 changes: 0 additions & 11 deletions docs/source/api_ref/mango.agent.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
mango.agent package
===================

Submodules
----------

mango.agent.core module
-----------------------

Expand All @@ -19,11 +16,3 @@ mango.agent.role module
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: mango.agent
:members:
:undoc-members:
:show-inheritance:
11 changes: 0 additions & 11 deletions docs/source/api_ref/mango.container.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
mango.container package
=======================

Submodules
----------

mango.container.core module
---------------------------

Expand Down Expand Up @@ -51,11 +48,3 @@ mango.container.tcp module
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: mango.container
:members:
:undoc-members:
:show-inheritance:
11 changes: 0 additions & 11 deletions docs/source/api_ref/mango.messages.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
mango.messages package
======================

Submodules
----------

mango.messages.acl\_message\_pb2 module
---------------------------------------

Expand Down Expand Up @@ -35,11 +32,3 @@ mango.messages.other\_proto\_msgs\_pb2 module
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: mango.messages
:members:
:undoc-members:
:show-inheritance:
11 changes: 0 additions & 11 deletions docs/source/api_ref/mango.modules.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
mango.modules package
=====================

Submodules
----------

mango.modules.base\_module module
---------------------------------

Expand Down Expand Up @@ -35,11 +32,3 @@ mango.modules.zero\_module module
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: mango.modules
:members:
:undoc-members:
:show-inheritance:
11 changes: 0 additions & 11 deletions docs/source/api_ref/mango.util.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
mango.util package
==================

Submodules
----------

mango.util.clock module
-----------------------

Expand Down Expand Up @@ -43,11 +40,3 @@ mango.util.termination\_detection module
:members:
:undoc-members:
:show-inheritance:

Module contents
---------------

.. automodule:: mango.util
:members:
:undoc-members:
:show-inheritance:
18 changes: 2 additions & 16 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,14 @@
# list see the documentation:
# https://www.sphinx-doc.org/en/master/usage/configuration.html

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath("../../mango"))

# -- Project information -----------------------------------------------------

project = "mango"
copyright = "2023, mango team"
copyright = "2024, mango team"
author = "mango team"

# The full version, including alpha/beta/rc tags
release = "0.1"
version = release = "1.1.4"


# -- General configuration ---------------------------------------------------
Expand Down
24 changes: 12 additions & 12 deletions docs/source/getting_started.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
========
===============
Getting started
========
===============
In this section you will get to know the necessary steps to create a simple multi-agent system
using *mango*. For an introduction to the different features that mango offers, we refer to the
:doc:`tutorial`.

***************
*****************
Creating an agent
***************
*****************
In our first example, we create a very simple agent that simply prints the content of
all messages it receives:

Expand All @@ -30,9 +30,9 @@ Agents must be a subclass of :class:`Agent`. This base class needs
a reference to the container that the agents live in, so you must forward
a *container* argument to it if you override ``__init__()``.

***************
********************
Creating a container
***************
********************

Agents live in a container, so we need to know how to create a mango container.
The container is responsible for message exchange between agents. More information about container and agents can be
Expand All @@ -52,9 +52,9 @@ coroutine__ we need to await its result.

__ https://docs.python.org/3.10/library/asyncio-task.html

***************
*******************************************
Running your first agent within a container
***************
*******************************************
To put it all together we will wrap the creation of a container and the agent into a coroutine
and execute it using :py:meth:`asyncio.run()`.
The following script will create a RepeatingAgent
Expand Down Expand Up @@ -91,9 +91,9 @@ then shutdown the container:
The only output you should see is "Hello world! My id is agent0.", because
the agent does not receive any other messages.

***************
**************************
Creating a proactive Agent
***************
**************************

Let's implement another agent that is able to send a hello world message
to another agent:
Expand All @@ -116,9 +116,9 @@ to another agent:

We are using the scheduling API, which is explained in further detail in the section :doc:`scheduling`.

***************
*********************
Connecting two agents
***************
*********************
We can now connect an instance of a HelloWorldAgent with an instance of
a RepeatingAgent and let them run.

Expand Down
1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Features
agents-container
message exchange
scheduling
ACL messages
codecs
role-api
development
Expand Down
12 changes: 6 additions & 6 deletions docs/source/message exchange.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
========
================
Message exchange
========
================

***************
******************
Receiving messages
***************
******************
Custom agents that inherit from the ``Agent`` class are able to receive messages from
other agents via the method ``handle_message``.
Hence this method has to be overwritten. The structure of this method looks like this:
Expand Down Expand Up @@ -43,9 +43,9 @@ A simple agent, that just prints the content and meta information of incoming me
f'meta {meta}')


***************
****************
Sending messages
***************
****************

Agents are able to send messages to other agents via the container method send_message:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/migration.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Migration
========
=========

Some mango versions will break the API; in this case, we may provide instructions on the migration on this page.

Expand Down
27 changes: 17 additions & 10 deletions mango/agent/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
A role is part of a :class:`RoleAgent` which inherits from :class:`Agent`.

There are essentially two APIs for acting resp reacting:
* [Reacting] :func:`RoleContext.subscribe_message`, which allows you to subscribe to
certain message types and lets you handle the message
* [Acting] :func:`RoleContext.schedule_task`, this allows you to schedule a task with
delay/repeating/...

* [Reacting] :func:`RoleContext.subscribe_message`, which allows you to subscribe to certain message types and lets you handle the message
* [Acting] :func:`RoleContext.schedule_task`, this allows you to schedule a task with delay/repeating/...

To interact with the environment an instance of the role context is provided. This context
provides methods to share data with other roles and to communicate with other agents.
Expand All @@ -27,6 +26,7 @@
If you prefer a lightweight variant you can use :func:`RoleContext.data` to assign/access shared data.

Furthermore there are two lifecycle methods to know about:

* :func:`Role.setup` is called when the Role is added to the agent, so its the perfect place
for initialization and scheduling of tasks
* :func:`Role.on_stop` is called when the container the agent lives in, is shut down
Expand Down Expand Up @@ -71,6 +71,7 @@ class Role(ABC):

Every role
must be added to a :class:`RoleAgent` and is defined by some lifecycle methods:

* :func:`Role.setup` is called when the Role is added to the agent, so its the perfect place for
initialization and scheduling of tasks
* :func:`Role.on_stop` is called when the container the agent lives in, is shut down
Expand Down Expand Up @@ -228,9 +229,12 @@ async def on_stop(self):

def handle_message(self, content, meta: Dict[str, Any]):
"""Handle an incoming message, delegating it to all applicable subscribers
for role, message_condition, method, _ in self._message_subs:
if self._is_role_active(role) and message_condition(content, meta):
method(content, meta)

.. code-block:: python

for role, message_condition, method, _ in self._message_subs:
if self._is_role_active(role) and message_condition(content, meta):
method(content, meta)

:param content: content
:param meta: meta
Expand Down Expand Up @@ -392,9 +396,12 @@ def remove_role(self, role: Role):

def handle_message(self, content, meta: Dict[str, Any]):
"""Handle an incoming message, delegating it to all applicable subscribers
for role, message_condition, method, _ in self._message_subs:
if self._is_role_active(role) and message_condition(content, meta):
method(content, meta)

.. code-block:: python

for role, message_condition, method, _ in self._message_subs:
if self._is_role_active(role) and message_condition(content, meta):
method(content, meta)

:param content: content
:param meta: meta
Expand Down
Loading